diff options
| author | Fuwn <[email protected]> | 2026-02-12 22:33:32 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2026-02-12 22:33:32 -0800 |
| commit | c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9 (patch) | |
| tree | df9f48bf128a6c0186a8e91857d6ff30fe0e9f18 /NET/worlds/scape/BoxBumpCalc.java | |
| download | worldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.tar.xz worldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.zip | |
Initial commit
Diffstat (limited to 'NET/worlds/scape/BoxBumpCalc.java')
| -rw-r--r-- | NET/worlds/scape/BoxBumpCalc.java | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/NET/worlds/scape/BoxBumpCalc.java b/NET/worlds/scape/BoxBumpCalc.java new file mode 100644 index 0000000..06e6c50 --- /dev/null +++ b/NET/worlds/scape/BoxBumpCalc.java @@ -0,0 +1,61 @@ +package NET.worlds.scape; + +import java.io.IOException; + +public class BoxBumpCalc extends BumpCalc { + private static Object classCookie = new Object(); + + @Override + public void detectBump(BumpEventTemp b, WObject owner) { + BoundBoxTemp box = owner.getBoundBox(); + BoundBoxTemp sourceBox = ((WObject)b.source).getBoundBox(); + box.lo.minus(sourceBox.hi.minus(b.sourceAt)); + box.hi.minus(sourceBox.lo.minus(b.sourceAt)); + Point3Temp pos = Point3Temp.make(); + pos.x = box.lo.x; + pos.y = box.lo.y; + float xExtent = box.hi.x - box.lo.x; + float yExtent = box.hi.y - box.lo.y; + Point3Temp d = Point3Temp.make(xExtent, 0.0F, 0.0F); + Point3Temp extent = Point3Temp.make(0.0F, yExtent / 2.0F, 0.0F); + if (!b.hitTriRegion(owner, pos, d, extent)) { + pos.x = box.hi.x; + pos.y = box.hi.y; + d.x = -d.x; + extent.y = -extent.y; + if (!b.hitTriRegion(owner, pos, d, extent)) { + pos.y = box.lo.y; + d.y = yExtent; + d.x = 0.0F; + extent.x = -xExtent / 2.0F; + extent.y = 0.0F; + if (!b.hitTriRegion(owner, pos, d, extent)) { + pos.x = box.lo.x; + pos.y = box.hi.y; + d.y = -d.y; + extent.x = -extent.x; + if (!b.hitTriRegion(owner, pos, d, extent)) { + ; + } + } + } + } + } + + @Override + public void saveState(Saver s) throws IOException { + s.saveVersion(0, classCookie); + super.saveState(s); + } + + @Override + public void restoreState(Restorer r) throws IOException, TooNewException { + switch (r.restoreVersion(classCookie)) { + case 0: + super.restoreState(r); + return; + default: + throw new TooNewException(); + } + } +} |