From c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9 Mon Sep 17 00:00:00 2001 From: Fuwn Date: Thu, 12 Feb 2026 22:33:32 -0800 Subject: Initial commit --- NET/worlds/scape/BoxBumpCalc.java | 61 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 NET/worlds/scape/BoxBumpCalc.java (limited to 'NET/worlds/scape/BoxBumpCalc.java') 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(); + } + } +} -- cgit v1.2.3