From 3a1c61134dfaee7a9a530b53db84e10120435e9e Mon Sep 17 00:00:00 2001 From: RandomityGuy <31925790+RandomityGuy@users.noreply.github.com> Date: Mon, 6 Apr 2026 01:23:21 +0100 Subject: [PATCH] remove some more stuff --- src/MarbleWorld.hx | 146 ---------------------------- src/rewind/RewindFrame.hx | 89 ----------------- src/rewind/RewindManager.hx | 14 --- src/shapes/Blast.hx | 37 ------- src/shapes/Checkpoint.hx | 37 ------- src/shapes/MegaMarble.hx | 47 --------- src/triggers/CheckpointTrigger.hx | 33 ------- src/triggers/DestinationTrigger.hx | 5 - src/triggers/TeleportTrigger.hx | 151 ----------------------------- 9 files changed, 559 deletions(-) delete mode 100644 src/shapes/Blast.hx delete mode 100644 src/shapes/Checkpoint.hx delete mode 100644 src/shapes/MegaMarble.hx delete mode 100644 src/triggers/CheckpointTrigger.hx delete mode 100644 src/triggers/DestinationTrigger.hx delete mode 100644 src/triggers/TeleportTrigger.hx diff --git a/src/MarbleWorld.hx b/src/MarbleWorld.hx index 946417ea..0ccac5c9 100644 --- a/src/MarbleWorld.hx +++ b/src/MarbleWorld.hx @@ -38,14 +38,8 @@ import gui.ReplayCenterGui; #end import gui.MessageBoxOkDlg; import collision.Collision; -import shapes.MegaMarble; -import shapes.Blast; -import shapes.Checkpoint; -import triggers.CheckpointTrigger; import shapes.EasterEgg; import shapes.Sign; -import triggers.TeleportTrigger; -import triggers.DestinationTrigger; import shapes.Magnet; import src.Replay; import gui.Canvas; @@ -190,14 +184,6 @@ class MarbleWorld extends Scheduler { public var newOrientationQuat = new Quat(); - // Checkpoint - var currentCheckpoint:{obj:DtsObject, elem:MissionElementBase} = null; - var currentCheckpointTrigger:CheckpointTrigger = null; - var checkpointCollectedGems:Map = []; - var checkpointHeldPowerup:PowerUp = null; - var checkpointUp:Vector = null; - var cheeckpointBlast:Float = 0; - // Replay public var replay:Replay; public var isWatching:Bool = false; @@ -608,10 +594,6 @@ class MarbleWorld extends Scheduler { public function restart(marble:Marble, full:Bool = false) { Console.log("LEVEL RESTART"); - if (!full && this.currentCheckpoint != null) { - this.loadCheckpointState(); - return 0; // Load checkpoint - } if (!full) { var respawnT = this.gameMode.getRespawnTransform(marble); @@ -643,13 +625,6 @@ class MarbleWorld extends Scheduler { this.marble.outOfBoundsTime = null; this.finishTime = null; - this.currentCheckpoint = null; - this.currentCheckpointTrigger = null; - this.checkpointCollectedGems.clear(); - this.checkpointHeldPowerup = null; - this.checkpointUp = null; - this.cheeckpointBlast = 0; - if (this.endPad != null) this.endPad.inFinish = false; if (this.totalGems > 0) { @@ -2420,125 +2395,6 @@ class MarbleWorld extends Scheduler { } } - /** Sets a new active checkpoint. */ - public function saveCheckpointState(shape:{obj:DtsObject, elem:MissionElementBase}, trigger:CheckpointTrigger = null) { - if (this.currentCheckpoint != null) - if (this.currentCheckpoint.obj == shape.obj) - return; - var disableOob = false; - if (shape != null) { - if (shape.elem.fields.exists('disableOob')) { - disableOob = MisParser.parseBoolean(shape.elem.fields.get('disableOob')[0]); - } - } - if (trigger != null) { - disableOob = trigger.disableOOB; - } - // (shape.srcElement as any) ?.disableOob || trigger?.element.disableOob; - if (disableOob && this.marble.outOfBounds) - return; // The checkpoint is configured to not work when the player is already OOB - this.currentCheckpoint = shape; - this.currentCheckpointTrigger = trigger; - this.checkpointCollectedGems.clear(); - this.checkpointUp = this.marble.currentUp.clone(); - this.cheeckpointBlast = this.marble.blastAmount; - // Remember all gems that were collected up to this point - for (gem in this.gems) { - if (gem.pickedUp) - this.checkpointCollectedGems.set(gem, true); - } - this.checkpointHeldPowerup = this.marble.heldPowerup; - this.displayAlert("Checkpoint reached!"); - AudioManager.playSound(ResourceLoader.getResource('data/sound/checkpoint.wav', ResourceLoader.getAudio, this.soundResources)); - } - - /** Resets to the last stored checkpoint state. */ - public function loadCheckpointState() { - var marble = this.marble; - // Determine where to spawn the marble - var offset = new Vector(0, 0, 3); - var add = ""; // (this.currentCheckpoint.srcElement as any)?.add || this.currentCheckpointTrigger?.element.add; - if (this.currentCheckpoint.elem.fields.exists('add')) { - add = this.currentCheckpoint.elem.fields.get('add')[0]; - } - var sub = ""; - if (this.currentCheckpoint.elem.fields.exists('sub')) { - sub = this.currentCheckpoint.elem.fields.get('sub')[0]; - } - if (this.currentCheckpointTrigger != null) { - if (this.currentCheckpointTrigger.add != null) - offset = this.currentCheckpointTrigger.add; - } - if (add != "") { - offset = MisParser.parseVector3(add); - offset.x = -offset.x; - } - if (sub != "") { - offset = MisParser.parseVector3(sub).multiply(-1); - offset.x = -offset.x; - } - var mpos = this.currentCheckpoint.obj.getAbsPos().getPosition().add(offset); - this.marble.setMarblePosition(mpos.x, mpos.y, mpos.z); - marble.velocity.load(new Vector(0, 0, 0)); - marble.omega.load(new Vector(0, 0, 0)); - Console.log('Respawn:'); - Console.log('Marble Position: ${mpos.x} ${mpos.y} ${mpos.z}'); - Console.log('Marble Velocity: ${marble.velocity.x} ${marble.velocity.y} ${marble.velocity.z}'); - Console.log('Marble Angular: ${marble.omega.x} ${marble.omega.y} ${marble.omega.z}'); - // Set camera orientation - var euler = this.currentCheckpoint.obj.getRotationQuat().toEuler(); - this.marble.camera.CameraYaw = euler.z + Math.PI / 2; - this.marble.camera.CameraPitch = 0.45; - this.marble.camera.nextCameraYaw = this.marble.camera.CameraYaw; - this.marble.camera.nextCameraPitch = this.marble.camera.CameraPitch; - this.marble.camera.oob = false; - @:privateAccess this.marble.superBounceEnableTime = -1e8; - @:privateAccess this.marble.shockAbsorberEnableTime = -1e8; - @:privateAccess this.marble.helicopterEnableTime = -1e8; - @:privateAccess this.marble.megaMarbleEnableTime = -1e8; - this.marble.blastAmount = this.cheeckpointBlast; - if (this.isRecording) { - this.replay.recordCameraState(this.marble.camera.CameraYaw, this.marble.camera.CameraPitch); - this.replay.recordMarbleInput(0, 0); - this.replay.recordMarbleState(mpos, marble.velocity, marble.getRotationQuat(), marble.omega); - this.replay.recordMarbleStateFlags(false, false, true, false); - } - var gravityField = ""; // (this.currentCheckpoint.srcElement as any) ?.gravity || this.currentCheckpointTrigger?.element.gravity; - if (this.currentCheckpoint.elem.fields.exists('gravity')) { - gravityField = this.currentCheckpoint.elem.fields.get('gravity')[0]; - } - if (this.currentCheckpointTrigger != null) { - if (@:privateAccess this.currentCheckpointTrigger.element.fields.exists('gravity')) { - gravityField = @:privateAccess this.currentCheckpointTrigger.element.fields.get('gravity')[0]; - } - } - if (MisParser.parseBoolean(gravityField)) { - // In this case, we set the gravity to the relative "up" vector of the checkpoint shape. - var up = new Vector(0, 0, 1); - up.transform(this.currentCheckpoint.obj.getRotationQuat().toMatrix()); - this.setUp(this.marble, up, this.timeState, true); - } else { - // Otherwise, we restore gravity to what was stored. - this.setUp(this.marble, this.checkpointUp, this.timeState, true); - } - // Restore gem states - for (gem in this.gems) { - if (gem.pickedUp && !this.checkpointCollectedGems.exists(gem)) { - gem.reset(); - this.gemCount--; - } - } - this.playGui.formatGemCounter(this.gemCount, this.totalGems); - this.playGui.setCenterText('none'); - this.clearSchedule(); - this.marble.outOfBounds = false; - this.deselectPowerUp(this.marble); // Always deselect first - // Wait a bit to select the powerup to prevent immediately using it incase the user skipped the OOB screen by clicking - if (this.checkpointHeldPowerup != null) - this.schedule(this.timeState.currentAttemptTime + 0.5, () -> this.pickUpPowerUp(this.marble, this.checkpointHeldPowerup)); - AudioManager.playSound(ResourceLoader.getResource('data/sound/spawn.wav', ResourceLoader.getAudio, this.soundResources)); - } - public function setCursorLock(enabled:Bool) { this.cursorLock = enabled; if (enabled) { @@ -2652,8 +2508,6 @@ class MarbleWorld extends Scheduler { collisionWorld = null; particleManager = null; namedObjects = null; - currentCheckpoint = null; - checkpointCollectedGems = null; marble = null; this._disposed = true; diff --git a/src/rewind/RewindFrame.hx b/src/rewind/RewindFrame.hx index d2ad48ae..2ed34e93 100644 --- a/src/rewind/RewindFrame.hx +++ b/src/rewind/RewindFrame.hx @@ -5,7 +5,6 @@ import haxe.io.Bytes; import haxe.io.BytesBuffer; import dif.io.BytesWriter; import mis.MissionElement.MissionElementBase; -import triggers.CheckpointTrigger; import src.PathedInterior.PIState; import shapes.PowerUp; import h3d.Vector; @@ -61,15 +60,6 @@ class RewindFrame { timeState:TimeState }; - var checkpointState:{ - currentCheckpoint:{obj:DtsObject, elem:MissionElementBase}, - currentCheckpointTrigger:CheckpointTrigger, - checkpointCollectedGems:Map, - checkpointHeldPowerup:PowerUp, - checkpointUp:Vector, - checkpointBlast:Float - }; - inline public function new() {} public inline function clone() { @@ -102,17 +92,6 @@ class RewindFrame { oob: oobState.oob, timeState: oobState.timeState != null ? oobState.timeState.clone() : null }; - c.checkpointState = { - currentCheckpoint: checkpointState.currentCheckpoint != null ? { - obj: checkpointState.currentCheckpoint.obj, - elem: checkpointState.currentCheckpoint.elem, - } : null, - currentCheckpointTrigger: checkpointState.currentCheckpointTrigger, - checkpointCollectedGems: checkpointState.checkpointCollectedGems.copy(), - checkpointHeldPowerup: checkpointState.checkpointHeldPowerup, - checkpointUp: checkpointState.checkpointUp != null ? checkpointState.checkpointUp.clone() : null, - checkpointBlast: checkpointState.checkpointBlast, - }; return c; } @@ -154,21 +133,6 @@ class RewindFrame { if (oobState.oob) framesize += 1; // oobState.oob framesize += 32; // oobState.timeState - framesize += 1; // Null - if (checkpointState != null) { - framesize += 4; // checkpointState.currentCheckpoint - } - framesize += 2; // checkpointState.currentCheckpointTrigger - framesize += 2; // checkpointState.checkpointCollectedGems.length - for (gem in checkpointState.checkpointCollectedGems.keys()) { - framesize += 2; // gem - framesize += 1; // checkpointState.checkpointCollectedGems[gem] - } - framesize += 2; // checkpointState.checkpointHeldPowerup - framesize += 1; // Null - if (checkpointState.checkpointUp != null) - framesize += 24; // checkpointState.checkpointUp - framesize += 8; // checkpointState.checkpointBlast bb.prepare(framesize); // Now actually write bb.writeDouble(timeState.currentAttemptTime); @@ -247,29 +211,6 @@ class RewindFrame { bb.writeDouble(oobState.timeState.gameplayClock); bb.writeDouble(oobState.timeState.dt); } - bb.writeByte(checkpointState.currentCheckpoint == null ? 0 : 1); - if (checkpointState.currentCheckpoint != null) { - bb.writeInt16(rm.allocGO(checkpointState.currentCheckpoint.obj)); - bb.writeInt16(rm.allocME(checkpointState.currentCheckpoint.elem)); - } - bb.writeInt16(rm.allocGO(checkpointState.currentCheckpointTrigger)); - var chkgemcount = 0; - for (g in checkpointState.checkpointCollectedGems) { - chkgemcount++; - } - bb.writeInt16(chkgemcount); - for (gem in checkpointState.checkpointCollectedGems.keys()) { - bb.writeInt16(rm.allocGO(gem)); - bb.writeByte(checkpointState.checkpointCollectedGems[gem] ? 1 : 0); - } - bb.writeInt16(rm.allocGO(checkpointState.checkpointHeldPowerup)); - bb.writeByte(checkpointState.checkpointUp == null ? 0 : 1); - if (checkpointState.checkpointUp != null) { - bb.writeDouble(checkpointState.checkpointUp.x); - bb.writeDouble(checkpointState.checkpointUp.y); - bb.writeDouble(checkpointState.checkpointUp.z); - } - bb.writeDouble(checkpointState.checkpointBlast); return bb.getBytes(); } @@ -380,35 +321,5 @@ class RewindFrame { oobState.timeState.gameplayClock = br.readDouble(); oobState.timeState.dt = br.readDouble(); } - var hasCheckpoint = br.readByte() != 0; - checkpointState = { - currentCheckpoint: null, - currentCheckpointTrigger: null, - checkpointCollectedGems: new Map(), - checkpointHeldPowerup: null, - checkpointUp: null, - checkpointBlast: 0.0, - }; - if (hasCheckpoint) { - var co = rm.getGO(br.readInt16()); - var ce = rm.getME(br.readInt16()); - checkpointState.currentCheckpoint = {obj: cast co, elem: ce}; - } - checkpointState.currentCheckpointTrigger = cast rm.getGO(br.readInt16()); - var checkpointState_checkpointCollectedGems_len = br.readInt16(); - for (i in 0...checkpointState_checkpointCollectedGems_len) { - var gem = cast rm.getGO(br.readInt16()); - var c = br.readByte() != 0; - checkpointState.checkpointCollectedGems.set(cast gem, c); - } - checkpointState.checkpointHeldPowerup = cast rm.getGO(br.readInt16()); - var checkpointState_checkpointUp_has = br.readByte() != 0; - if (checkpointState_checkpointUp_has) { - checkpointState.checkpointUp = new Vector(); - checkpointState.checkpointUp.x = br.readDouble(); - checkpointState.checkpointUp.y = br.readDouble(); - checkpointState.checkpointUp.z = br.readDouble(); - } - checkpointState.checkpointBlast = br.readDouble(); } } diff --git a/src/rewind/RewindManager.hx b/src/rewind/RewindManager.hx index ce17171c..87781791 100644 --- a/src/rewind/RewindManager.hx +++ b/src/rewind/RewindManager.hx @@ -97,14 +97,6 @@ class RewindManager { oob: level.marble.outOfBounds, timeState: level.marble.outOfBoundsTime != null ? level.marble.outOfBoundsTime.clone() : null }; - rf.checkpointState = { - currentCheckpoint: @:privateAccess level.currentCheckpoint, - currentCheckpointTrigger: @:privateAccess level.currentCheckpointTrigger, - checkpointBlast: @:privateAccess level.cheeckpointBlast, - checkpointCollectedGems: @:privateAccess level.checkpointCollectedGems.copy(), - checkpointHeldPowerup: @:privateAccess level.checkpointHeldPowerup, - checkpointUp: @:privateAccess level.checkpointUp != null ? @:privateAccess level.checkpointUp.clone() : null, - }; frameElapsedTimes.push(level.timeState.currentAttemptTime); frameDataOffsets.push(frameData.length); var frameDataSerialized = rf.serialize(this); @@ -218,12 +210,6 @@ class RewindManager { level.marble.camera.oob = rf.oobState.oob; level.marble.outOfBoundsTime = rf.oobState.timeState != null ? rf.oobState.timeState.clone() : null; level.marble.blastAmount = rf.blastAmt; - @:privateAccess level.checkpointUp = rf.checkpointState.checkpointUp; - @:privateAccess level.checkpointCollectedGems = rf.checkpointState.checkpointCollectedGems; - @:privateAccess level.cheeckpointBlast = rf.checkpointState.checkpointBlast; - @:privateAccess level.checkpointHeldPowerup = rf.checkpointState.checkpointHeldPowerup; - @:privateAccess level.currentCheckpoint = rf.checkpointState.currentCheckpoint; - @:privateAccess level.currentCheckpointTrigger = rf.checkpointState.currentCheckpointTrigger; } public function getNextRewindFrame(absTime:Float):RewindFrame { diff --git a/src/shapes/Blast.hx b/src/shapes/Blast.hx deleted file mode 100644 index 1ee1fb50..00000000 --- a/src/shapes/Blast.hx +++ /dev/null @@ -1,37 +0,0 @@ -package shapes; - -import src.MarbleWorld; -import src.ResourceLoader; -import src.TimeState; -import mis.MissionElement.MissionElementItem; - -class Blast extends PowerUp { - public function new(element:MissionElementItem) { - super(element); - this.dtsPath = "data/shapes/items/blast.dts"; - this.isCollideable = false; - this.isTSStatic = false; - this.showSequences = true; - this.identifier = "Blast"; - this.pickUpName = "Blast PowerUp"; - this.autoUse = true; - } - - public override function init(level:MarbleWorld, onFinish:Void->Void) { - super.init(level, () -> { - ResourceLoader.load("sound/publastvoice.wav").entry.load(() -> { - this.pickupSound = ResourceLoader.getResource("data/sound/publastvoice.wav", ResourceLoader.getAudio, this.soundResources); - onFinish(); - }); - }); - } - - public function pickUp(marble:src.Marble):Bool { - return true; - } - - public function use(marble:src.Marble, timeState:TimeState) { - marble.blastAmount = 1.03; - marble.blastTicks = 36000 >> 5; // Fix me - } -} diff --git a/src/shapes/Checkpoint.hx b/src/shapes/Checkpoint.hx deleted file mode 100644 index 9617c562..00000000 --- a/src/shapes/Checkpoint.hx +++ /dev/null @@ -1,37 +0,0 @@ -package shapes; - -import collision.CollisionInfo; -import mis.MisParser; -import src.DtsObject; -import src.ResourceLoader; -import mis.MissionElement.MissionElementStaticShape; - -class Checkpoint extends DtsObject { - public var disableOOB = false; - - var element:MissionElementStaticShape; - - public function new(element:MissionElementStaticShape) { - super(); - this.dtsPath = "data/shapes/buttons/checkpoint.dts"; - this.isCollideable = true; - this.isTSStatic = false; - this.identifier = "Checkpoint"; - this.element = element; - - this.disableOOB = element.fields.exists('disableOob') ? MisParser.parseBoolean(element.fields['disableOob'][0]) : false; - } - - public override function init(level:src.MarbleWorld, onFinish:() -> Void) { - super.init(level, () -> { - ResourceLoader.load("sound/checkpoint.wav").entry.load(onFinish); - }); - } - - public override function onMarbleContact(marble:src.Marble, time:src.TimeState, ?contact:CollisionInfo) { - this.level.saveCheckpointState({ - obj: this, - elem: this.element - }, null); - } -} diff --git a/src/shapes/MegaMarble.hx b/src/shapes/MegaMarble.hx deleted file mode 100644 index cc3332d9..00000000 --- a/src/shapes/MegaMarble.hx +++ /dev/null @@ -1,47 +0,0 @@ -package shapes; - -import src.ResourceLoaderWorker; -import src.MarbleWorld; -import src.ResourceLoader; -import src.TimeState; -import mis.MissionElement.MissionElementItem; -import src.AudioManager; - -class MegaMarble extends PowerUp { - public function new(element:MissionElementItem) { - super(element); - this.dtsPath = "data/shapes/items/megamarble.dts"; - this.isCollideable = false; - this.isTSStatic = false; - this.showSequences = true; - this.identifier = "MegaMarble"; - this.pickUpName = "Mega Marble PowerUp"; - } - - public override function init(level:MarbleWorld, onFinish:Void->Void) { - super.init(level, () -> { - ResourceLoader.load("sound/pumegamarblevoice.wav").entry.load(() -> { - var worker = new ResourceLoaderWorker(onFinish); - worker.loadFile("sound/mega_bouncehard1.wav"); - worker.loadFile("sound/mega_bouncehard2.wav"); - worker.loadFile("sound/mega_bouncehard3.wav"); - worker.loadFile("sound/mega_bouncehard4.wav"); - worker.loadFile("sound/mega_roll.wav"); - worker.loadFile("sound/dosuperjump.wav"); - this.pickupSound = ResourceLoader.getResource("data/sound/pumegamarblevoice.wav", ResourceLoader.getAudio, this.soundResources); - worker.run(); - }); - }); - } - - public function pickUp(marble:src.Marble):Bool { - return this.level.pickUpPowerUp(marble, this); - } - - public function use(marble:src.Marble, timeState:TimeState) { - marble.enableMegaMarble(timeState); - this.level.deselectPowerUp(marble); - if (this.level.marble == marble && @:privateAccess !marble.isNetUpdate) - AudioManager.playSound(ResourceLoader.getResource('data/sound/dosuperjump.wav', ResourceLoader.getAudio, this.soundResources)); - } -} diff --git a/src/triggers/CheckpointTrigger.hx b/src/triggers/CheckpointTrigger.hx deleted file mode 100644 index 012d6aaf..00000000 --- a/src/triggers/CheckpointTrigger.hx +++ /dev/null @@ -1,33 +0,0 @@ -package triggers; - -import h3d.Vector; -import src.MarbleWorld; -import mis.MissionElement.MissionElementTrigger; -import src.ResourceLoader; -import mis.MisParser; - -class CheckpointTrigger extends Trigger { - public var disableOOB = false; - public var add:Vector = null; - - override public function new(element:MissionElementTrigger, level:MarbleWorld) { - super(element, level); - - this.disableOOB = element.fields.exists('disableOob') ? MisParser.parseBoolean(element.fields['disableOob'][0]) : false; - this.add = element.fields.exists('add') ? MisParser.parseVector3(element.fields['add'][0]) : null; - } - - public override function init(onFinish:() -> Void) { - super.init(() -> { - ResourceLoader.load("sound/checkpoint.wav").entry.load(onFinish); - }); - } - - public override function onMarbleEnter(marble:src.Marble, time:src.TimeState) { - super.onMarbleEnter(marble, time); - var shape = this.level.namedObjects.get(this.element.respawnpoint); - if (shape == null) - return; - this.level.saveCheckpointState(shape, this); - } -} diff --git a/src/triggers/DestinationTrigger.hx b/src/triggers/DestinationTrigger.hx deleted file mode 100644 index 1276e523..00000000 --- a/src/triggers/DestinationTrigger.hx +++ /dev/null @@ -1,5 +0,0 @@ -package triggers; - -class DestinationTrigger extends Trigger { - // Stub -} diff --git a/src/triggers/TeleportTrigger.hx b/src/triggers/TeleportTrigger.hx deleted file mode 100644 index 2d56c19f..00000000 --- a/src/triggers/TeleportTrigger.hx +++ /dev/null @@ -1,151 +0,0 @@ -package triggers; - -import src.Marble; -import h3d.Vector; -import src.ResourceLoader; -import src.AudioManager; -import mis.MisParser; -import src.MarbleWorld; -import mis.MissionElement.MissionElementTrigger; -import src.Console; - -@:publicFields -@:structInit -class TeleportationState { - var entryTime:Null; - var exitTime:Null; -} - -class TeleportTrigger extends Trigger { - var delay:Float = 2; - - var marbleStates:Map = []; - - public function new(element:MissionElementTrigger, level:MarbleWorld) { - super(element, level); - if (element.delay != null) - this.delay = MisParser.parseNumber(element.delay) / 1000; - } - - function getState(marble:Marble) { - if (marbleStates.exists(marble)) - return marbleStates.get(marble); - else { - marbleStates.set(marble, {entryTime: null, exitTime: null}); - return marbleStates.get(marble); - } - } - - override function onMarbleEnter(marble:src.Marble, time:src.TimeState) { - var state = getState(marble); - state.exitTime = null; - marble.setCloaking(true, time); - if (state.entryTime != null) - return; - state.entryTime = time.currentAttemptTime; - if (level.marble == marble && @:privateAccess !marble.isNetUpdate) { - this.level.displayAlert("Teleporter has been activated, please wait."); - AudioManager.playSound(ResourceLoader.getResource("data/sound/teleport.wav", ResourceLoader.getAudio, this.soundResources)); - } - } - - override function onMarbleLeave(marble:src.Marble, time:src.TimeState) { - var state = getState(marble); - state.exitTime = time.currentAttemptTime; - marble.setCloaking(false, time); - } - - public override function update(timeState:src.TimeState) { - for (marble => state in marbleStates) { - if (state.entryTime == null) - continue; - if (state.exitTime != null && timeState.currentAttemptTime - state.exitTime > 0.05) { - state.entryTime = null; - state.exitTime = null; - continue; - } - - if (timeState.currentAttemptTime - state.entryTime >= this.delay) { - state.entryTime = null; - this.executeTeleport(marble); - } - } - } - - override function init(onFinish:() -> Void) { - ResourceLoader.load("sound/teleport.wav").entry.load(onFinish); - } - - function executeTeleport(marble:Marble) { - function chooseNonNull(a:String, b:String) { - if (a != null) - return a; - if (b != null) - return b; - return null; - } - - // Find the destination trigger - if (this.element.destination == null) - return; - var destinationList = this.level.triggers.filter(x -> x is DestinationTrigger - && x.element._name.toLowerCase() == this.element.destination.toLowerCase()); - if (destinationList.length == 0) - return; // Who knows - - var destination = destinationList[0]; - - var pos = MisParser.parseVector3(destination.element.position); - pos.x = -pos.x; - - // Determine where to place the marble - var position:Vector; - if (MisParser.parseBoolean(chooseNonNull(this.element.centerdestpoint, destination.element.centerdestpoint))) { - position = destination.collider.boundingBox.getCenter().toVector(); // Put the marble in the middle of the thing - } else { - position = destination.vertices[0].add(new Vector(0, 0, 3)).add(pos); // destination.vertices[0].clone().add(new Vector(0, 0, 3)); - } - position.w = 1; - marble.prevPos.load(position); - marble.setPosition(position.x, position.y, position.z); - var ct = marble.collider.transform.clone(); - ct.setPosition(position); - marble.collider.setTransform(ct); - if (this.level.isRecording) { - this.level.replay.recordMarbleStateFlags(false, false, true, false); - } - - if (!MisParser.parseBoolean(chooseNonNull(this.element.keepvelocity, destination.element.keepvelocity))) - marble.velocity.set(0, 0, 0); - if (MisParser.parseBoolean(chooseNonNull(this.element.inversevelocity, destination.element.inversevelocity))) - marble.velocity.scale(-1); - if (!MisParser.parseBoolean(chooseNonNull(this.element.keepangular, destination.element.keepangular))) - marble.omega.set(0, 0, 0); - - Console.log('Teleport:'); - Console.log('Marble Position: ${position.x} ${position.y} ${position.z}'); - Console.log('Marble Velocity: ${marble.velocity.x} ${marble.velocity.y} ${marble.velocity.z}'); - Console.log('Marble Angular: ${marble.omega.x} ${marble.omega.y} ${marble.omega.z}'); - - // Determine camera orientation - if (marble == level.marble) { - if (!MisParser.parseBoolean(chooseNonNull(this.element.keepcamera, destination.element.keepcamera))) { - var yaw:Float; - if (this.element.camerayaw != null) - yaw = MisParser.parseNumber(this.element.camerayaw) * Math.PI / 180; - else if (destination.element.camerayaw != null) - yaw = MisParser.parseNumber(destination.element.camerayaw) * Math.PI / 180; - else - yaw = 0; - - yaw = -yaw; // Need to flip it for some reason - - marble.camera.CameraYaw = yaw + Math.PI / 2; - marble.camera.CameraPitch = 0.45; - marble.camera.nextCameraYaw = yaw + Math.PI / 2; - marble.camera.nextCameraPitch = 0.45; - } - AudioManager.playSound(ResourceLoader.getResource("data/sound/spawn.wav", ResourceLoader.getAudio, this.soundResources)); - } - } -}