From 15fb7c5cb9f19032500e5990063531205ea7f726 Mon Sep 17 00:00:00 2001 From: RandomityGuy <31925790+RandomityGuy@users.noreply.github.com> Date: Sun, 25 Feb 2024 14:19:11 +0530 Subject: [PATCH] get OOBs working sorta without sound --- src/Marble.hx | 20 ++- src/MarbleGame.hx | 2 +- src/MarbleWorld.hx | 211 +++++++++++++++-------------- src/modes/GameMode.hx | 3 +- src/modes/HuntMode.hx | 11 +- src/modes/NullMode.hx | 3 +- src/net/MoveManager.hx | 6 - src/net/NetPacket.hx | 3 + src/rewind/RewindManager.hx | 16 +-- src/shapes/AntiGravity.hx | 2 +- src/triggers/InBoundsTrigger.hx | 2 +- src/triggers/OutOfBoundsTrigger.hx | 2 +- 12 files changed, 149 insertions(+), 132 deletions(-) diff --git a/src/Marble.hx b/src/Marble.hx index ff1916f9..5730e63d 100644 --- a/src/Marble.hx +++ b/src/Marble.hx @@ -249,6 +249,10 @@ class Marble extends GameObject { public var lastContactPosition:Vector; public var currentUp = new Vector(0, 0, 1); + public var outOfBounds:Bool = false; + public var outOfBoundsTime:TimeState; + public var oobSchedule:Float; + var helicopter:HelicopterImage; var blastWave:BlastWave; var helicopterEnableTime:Float = -1e8; @@ -567,14 +571,15 @@ class Marble extends GameObject { A = A.multiply(0.25); } if (this.level != null) { + var mass = this.getMass(); for (obj in level.forceObjects) { var force = cast(obj, ForceObject).getForce(this.collider.transform.getPosition()); - A = A.add(force.multiply(1 / _mass)); + A = A.add(force.multiply(1 / mass)); } for (marble in level.marbles) { if (marble != this) { var force = marble.getForce(this.collider.transform.getPosition(), tick); - A = A.add(force.multiply(1 / _mass)); + A = A.add(force.multiply(1 / mass)); } } } @@ -603,7 +608,7 @@ class Marble extends GameObject { if (forceObjectCount != 0) { contactNormal.normalize(); - var a = contactForce / this._mass; + var a = contactForce / this.getMass(); var dot = this.velocity.dot(contactNormal); if (a > dot) { if (dot > 0) @@ -699,8 +704,8 @@ class Marble extends GameObject { } else if (contacts[i].collider != null) { var otherMarble:Marble = cast contacts[i].collider.go; - var ourMass = this._mass; - var theirMass = otherMarble._mass; + var ourMass = this.getMass(); + var theirMass = otherMarble.getMass(); var bounce = Math.max(this._bounceRestitution, otherMarble._bounceRestitution); @@ -1599,7 +1604,7 @@ class Marble extends GameObject { this.collisionWorld.updateTransform(this.collider); this.collider.velocity = this.velocity; - if (this.heldPowerup != null && m.powerup && !this.level.outOfBounds) { + if (this.heldPowerup != null && m.powerup && !this.outOfBounds) { var pTime = timeState.clone(); pTime.dt = timeStep; pTime.currentAttemptTime = passedTime; @@ -1664,6 +1669,7 @@ class Marble extends GameObject { marbleUpdate.blastTick = this.blastUseTick; marbleUpdate.heliTick = this.helicopterUseTick; marbleUpdate.megaTick = this.megaMarbleUseTick; + marbleUpdate.oob = this.outOfBounds; marbleUpdate.serialize(b); return b.getBytes(); } @@ -1686,6 +1692,8 @@ class Marble extends GameObject { this.blastUseTick = p.blastTick; this.helicopterUseTick = p.heliTick; this.megaMarbleUseTick = p.megaTick; + this.outOfBounds = p.oob; + this.camera.oob = p.oob; if (this.controllable && Net.isClient) { // We are client, need to do something about the queue var mm = Net.clientConnection.moveManager; diff --git a/src/MarbleGame.hx b/src/MarbleGame.hx index f3520b6d..0080f89b 100644 --- a/src/MarbleGame.hx +++ b/src/MarbleGame.hx @@ -251,7 +251,7 @@ class MarbleGame { @:privateAccess world.playGui.setGuiVisibility(true); canvas.popDialog(exitGameDlg); var w = getWorld(); - w.restart(true); + w.restart(w.marble, true); // world.setCursorLock(true); paused = !paused; }); diff --git a/src/MarbleWorld.hx b/src/MarbleWorld.hx index 94ef8afc..8dfeddcb 100644 --- a/src/MarbleWorld.hx +++ b/src/MarbleWorld.hx @@ -151,8 +151,6 @@ class MarbleWorld extends Scheduler { public var game:String; public var marble:Marble; - public var outOfBounds:Bool = false; - public var outOfBoundsTime:TimeState; public var finishTime:TimeState; public var finishPitch:Float; public var finishYaw:Float; @@ -230,7 +228,6 @@ class MarbleWorld extends Scheduler { var soundResources:Array> = []; var oobSchedule:Float; - var oobSchedule2:Float; var _cubemapNeedsUpdate:Bool = false; @@ -483,7 +480,7 @@ class MarbleWorld extends Scheduler { public function start() { Console.log("LEVEL START"); - restart(true); + restart(this.marble, true); for (interior in this.interiors) interior.onLevelStart(); for (shape in this.dtsObjects) @@ -492,7 +489,7 @@ class MarbleWorld extends Scheduler { NetCommands.clientIsReady(Net.clientId); } - public function restart(full:Bool = false) { + public function restart(marble:Marble, full:Bool = false) { Console.log("LEVEL RESTART"); if (!full && this.currentCheckpoint != null) { this.loadCheckpointState(); @@ -502,7 +499,7 @@ class MarbleWorld extends Scheduler { if (!full) { var respawnT = this.gameMode.getRespawnTransform(); if (respawnT != null) { - respawn(respawnT.position, respawnT.orientation, respawnT.up); + respawn(marble, respawnT.position, respawnT.orientation, respawnT.up); return 0; } } @@ -517,10 +514,10 @@ class MarbleWorld extends Scheduler { this.timeState.currentAttemptTime = 0; this.timeState.gameplayClock = this.gameMode.getStartTime(); this.bonusTime = 0; - this.outOfBounds = false; + this.marble.outOfBounds = false; this.marble.blastAmount = 0; this.renderBlastAmount = 0; - this.outOfBoundsTime = null; + this.marble.outOfBoundsTime = null; this.finishTime = null; this.skipStartBugPauseTime = 0.0; @@ -563,7 +560,7 @@ class MarbleWorld extends Scheduler { } this.cancel(this.oobSchedule); - this.cancel(this.oobSchedule2); + this.cancel(this.marble.oobSchedule); var startquat = this.gameMode.getSpawnTransform(); @@ -583,6 +580,7 @@ class MarbleWorld extends Scheduler { if (isMultiplayer) { for (client => marble in clientMarbles) { + this.cancel(marble.oobSchedule); var marbleStartQuat = this.gameMode.getSpawnTransform(); marble.setMarblePosition(marbleStartQuat.position.x, marbleStartQuat.position.y, marbleStartQuat.position.z); marble.reset(); @@ -600,7 +598,7 @@ class MarbleWorld extends Scheduler { for (interior in this.interiors) interior.reset(); - this.setUp(startquat.up, this.timeState, true); + this.setUp(this.marble, startquat.up, this.timeState, true); this.deselectPowerUp(this.marble); playGui.setCenterText(''); @@ -611,10 +609,9 @@ class MarbleWorld extends Scheduler { return 0; } - public function respawn(respawnPos:Vector, respawnQuat:Quat, respawnUp:Vector) { - var marble = this.marble; + public function respawn(marble:Marble, respawnPos:Vector, respawnQuat:Quat, respawnUp:Vector) { // Determine where to spawn the marble - this.marble.setMarblePosition(respawnPos.x, respawnPos.y, respawnPos.z); + marble.setMarblePosition(respawnPos.x, respawnPos.y, respawnPos.z); marble.velocity.set(0, 0, 0); marble.omega.set(0, 0, 0); Console.log('Respawn:'); @@ -623,15 +620,20 @@ class MarbleWorld extends Scheduler { Console.log('Marble Angular: ${marble.omega.x} ${marble.omega.y} ${marble.omega.z}'); // Set camera orientation var euler = respawnQuat.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.helicopterEnableTime = -1e8; - @:privateAccess this.marble.megaMarbleEnableTime = -1e8; + marble.camera.CameraYaw = euler.z + Math.PI / 2; + marble.camera.CameraPitch = 0.45; + marble.camera.nextCameraYaw = marble.camera.CameraYaw; + marble.camera.nextCameraPitch = marble.camera.CameraPitch; + marble.camera.oob = false; + if (isMultiplayer) { + marble.megaMarbleUseTick = 0; + marble.helicopterUseTick = 0; + } else { + @:privateAccess marble.helicopterEnableTime = -1e8; + @:privateAccess marble.megaMarbleEnableTime = -1e8; + } if (this.isRecording) { - this.replay.recordCameraState(this.marble.camera.CameraYaw, this.marble.camera.CameraPitch); + this.replay.recordCameraState(marble.camera.CameraYaw, marble.camera.CameraPitch); this.replay.recordMarbleInput(0, 0); this.replay.recordMarbleState(respawnPos, marble.velocity, marble.getRotationQuat(), marble.omega); this.replay.recordMarbleStateFlags(false, false, true, false); @@ -640,13 +642,16 @@ class MarbleWorld extends Scheduler { // 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(respawnQuat.toMatrix()); - this.setUp(up, this.timeState, true); + this.setUp(marble, up, this.timeState, true); - this.playGui.setCenterText(''); - this.clearSchedule(); - this.outOfBounds = false; - this.gameMode.onRespawn(); - AudioManager.playSound(ResourceLoader.getResource('data/sound/spawn_alternate.wav', ResourceLoader.getAudio, this.soundResources)); + if (marble == this.marble) + this.playGui.setCenterText(''); + if (!this.isMultiplayer) + this.clearSchedule(); + marble.outOfBounds = false; + this.gameMode.onRespawn(marble); + if (marble == this.marble) + AudioManager.playSound(ResourceLoader.getResource('data/sound/spawn_alternate.wav', ResourceLoader.getAudio, this.soundResources)); } public function allClientsReady() { @@ -654,7 +659,7 @@ class MarbleWorld extends Scheduler { } public function updateGameState() { - if (this.outOfBounds) + if (this.marble.outOfBounds) return; // We will update state manually if (!this.isMultiplayer) { if (this.timeState.currentAttemptTime < 0.5) { @@ -1023,7 +1028,7 @@ class MarbleWorld extends Scheduler { public function performRestart() { this.respawnPressedTime = timeState.timeSinceLoad; - this.restart(); + this.restart(this.marble); if (!this.isWatching) { Settings.playStatistics.respawns++; @@ -1142,9 +1147,6 @@ class MarbleWorld extends Scheduler { for (pw in marble.level.powerUps) { pw.lastPickUpTime = mvs.shift(); } - @:privateAccess marble.helicopterEnableTime = qm.helicopterState; - @:privateAccess marble.megaMarbleEnableTime = qm.megaState; - marble.blastAmount = qm.blastAmt; } } @@ -1170,7 +1172,7 @@ class MarbleWorld extends Scheduler { if (distFromUs < 5) m.calculationTicks = ourQueuedMoves.length; // ourQueuedMoves.length; else - m.calculationTicks = Std.int(Math.max(1, ourQueuedMoves.length - (distFromUs - 5) / 5)); + m.calculationTicks = Std.int(Math.max(1, ourQueuedMoves.length - (distFromUs - 5) / 3)); // - Std.int((@:privateAccess Net.clientConnection.moveManager.ackRTT - ourLastMove.moveQueueSize) / 2); marblesToTick.set(client, m); @@ -1377,7 +1379,7 @@ class MarbleWorld extends Scheduler { // Replay gravity if (this.isWatching) { if (this.replay.currentPlaybackFrame.gravityChange) { - this.setUp(this.replay.currentPlaybackFrame.gravity, timeState, this.replay.currentPlaybackFrame.gravityInstant); + this.setUp(this.marble, this.replay.currentPlaybackFrame.gravity, timeState, this.replay.currentPlaybackFrame.gravityInstant); } if (this.replay.currentPlaybackFrame.powerupPickup != null) { this.pickUpPowerUpReplay(this.replay.currentPlaybackFrame.powerupPickup); @@ -1473,11 +1475,11 @@ class MarbleWorld extends Scheduler { ProfilerUI.measure("updateAudio"); AudioManager.update(this.scene); - if (this.outOfBounds + if (this.marble.outOfBounds && this.finishTime == null && (Key.isDown(Settings.controlsSettings.jump) || Gamepad.isDown(Settings.gamepadSettings.jump)) && !this.isWatching) { - this.restart(); + this.restart(this.marble); return; } @@ -1816,7 +1818,7 @@ class MarbleWorld extends Scheduler { function touchFinish() { if (this.finishTime != null - || (this.outOfBounds && this.timeState.currentAttemptTime - this.outOfBoundsTime.currentAttemptTime >= 0.5)) + || (this.marble.outOfBounds && this.timeState.currentAttemptTime - this.marble.outOfBoundsTime.currentAttemptTime >= 0.5)) return; if (this.gemCount < this.totalGems) { @@ -1903,7 +1905,7 @@ class MarbleWorld extends Scheduler { var restartGameCode = () -> { MarbleGame.canvas.popDialog(egg); playGui.setGuiVisibility(true); - this.restart(true); + this.restart(this.marble, true); #if js pointercontainer.hidden = true; #end @@ -1992,64 +1994,66 @@ class MarbleWorld extends Scheduler { return q; } - public function setUp(vec:Vector, timeState:TimeState, instant:Bool = false) { - this.marble.currentUp = vec; - var currentQuat = this.getOrientationQuat(timeState.currentAttemptTime); - var oldUp = new Vector(0, 0, 1); - oldUp.transform(currentQuat.toMatrix()); + public function setUp(marble:Marble, vec:Vector, timeState:TimeState, instant:Bool = false) { + marble.currentUp = vec; + if (marble == this.marble) { + var currentQuat = this.getOrientationQuat(timeState.currentAttemptTime); + var oldUp = new Vector(0, 0, 1); + oldUp.transform(currentQuat.toMatrix()); - function getRotQuat(v1:Vector, v2:Vector) { - function orthogonal(v:Vector) { - var x = Math.abs(v.x); - var y = Math.abs(v.y); - var z = Math.abs(v.z); - var other = x < y ? (x < z ? new Vector(1, 0, 0) : new Vector(0, 0, 1)) : (y < z ? new Vector(0, 1, 0) : new Vector(0, 0, 1)); - return v.cross(other); - } + function getRotQuat(v1:Vector, v2:Vector) { + function orthogonal(v:Vector) { + var x = Math.abs(v.x); + var y = Math.abs(v.y); + var z = Math.abs(v.z); + var other = x < y ? (x < z ? new Vector(1, 0, 0) : new Vector(0, 0, 1)) : (y < z ? new Vector(0, 1, 0) : new Vector(0, 0, 1)); + return v.cross(other); + } - var u = v1.normalized(); - var v = v2.normalized(); - if (Math.abs(u.dot(v) + 1) < hxd.Math.EPSILON) { + var u = v1.normalized(); + var v = v2.normalized(); + if (Math.abs(u.dot(v) + 1) < hxd.Math.EPSILON) { + var q = new Quat(); + var o = orthogonal(u).normalized(); + q.x = o.x; + q.y = o.y; + q.z = o.z; + q.w = 0; + return q; + } + var half = u.add(v).normalized(); var q = new Quat(); - var o = orthogonal(u).normalized(); - q.x = o.x; - q.y = o.y; - q.z = o.z; - q.w = 0; + q.w = u.dot(half); + var vr = u.cross(half); + q.x = vr.x; + q.y = vr.y; + q.z = vr.z; return q; } - var half = u.add(v).normalized(); - var q = new Quat(); - q.w = u.dot(half); - var vr = u.cross(half); - q.x = vr.x; - q.y = vr.y; - q.z = vr.z; - return q; + + var quatChange = getRotQuat(oldUp, vec); + // Instead of calculating the new quat from nothing, calculate it from the last one to guarantee the shortest possible rotation. + // quatChange.initMoveTo(oldUp, vec); + quatChange.multiply(quatChange, currentQuat); + + if (this.isRecording) { + this.replay.recordGravity(vec, instant); + } + + this.newOrientationQuat = quatChange; + this.oldOrientationQuat = currentQuat; + this.orientationChangeTime = instant ? -1e8 : timeState.currentAttemptTime; } - - var quatChange = getRotQuat(oldUp, vec); - // Instead of calculating the new quat from nothing, calculate it from the last one to guarantee the shortest possible rotation. - // quatChange.initMoveTo(oldUp, vec); - quatChange.multiply(quatChange, currentQuat); - - if (this.isRecording) { - this.replay.recordGravity(vec, instant); - } - - this.newOrientationQuat = quatChange; - this.oldOrientationQuat = currentQuat; - this.orientationChangeTime = instant ? -1e8 : timeState.currentAttemptTime; } - public function goOutOfBounds() { - if (this.outOfBounds || this.finishTime != null) + public function goOutOfBounds(marble:Marble) { + if (marble.outOfBounds || this.finishTime != null) return; // this.updateCamera(this.timeState); // Update the camera at the point of OOB-ing - this.outOfBounds = true; - this.outOfBoundsTime = this.timeState.clone(); - this.marble.camera.oob = true; - if (!this.isWatching) { + marble.outOfBounds = true; + marble.outOfBoundsTime = this.timeState.clone(); + marble.camera.oob = true; + if (!this.isWatching && !this.isMultiplayer) { Settings.playStatistics.oobs++; if (!Settings.levelStatistics.exists(mission.path)) { Settings.levelStatistics.set(mission.path, { @@ -2060,19 +2064,24 @@ class MarbleWorld extends Scheduler { } else { Settings.levelStatistics[mission.path].oobs++; } + + // sky.follow = null; + // this.oobCameraPosition = camera.position.clone(); + } + if (marble == this.marble) { + playGui.setCenterText('Out of Bounds'); + // if (this.replay.mode != = 'playback') + this.oobSchedule = this.schedule(this.timeState.currentAttemptTime + 2, () -> { + playGui.setCenterText(''); + return null; + }); + } + if (Net.isHost) { + marble.oobSchedule = this.schedule(this.timeState.currentAttemptTime + 2.5, () -> { + this.restart(marble); + return null; + }); } - // sky.follow = null; - // this.oobCameraPosition = camera.position.clone(); - playGui.setCenterText('Out of Bounds'); - // if (this.replay.mode != = 'playback') - this.oobSchedule = this.schedule(this.timeState.currentAttemptTime + 2, () -> { - playGui.setCenterText(''); - return null; - }); - this.oobSchedule2 = this.schedule(this.timeState.currentAttemptTime + 2.5, () -> { - this.restart(); - return null; - }); } /** Sets a new active checkpoint. */ @@ -2086,7 +2095,7 @@ class MarbleWorld extends Scheduler { } checkpointSequence = trigger.seqNum; // (shape.srcElement as any) ?.disableOob || trigger?.element.disableOob; - if (disableOob && this.outOfBounds) + if (disableOob && this.marble.outOfBounds) return false; // The checkpoint is configured to not work when the player is already OOB this.currentCheckpoint = shape; this.currentCheckpointTrigger = trigger; @@ -2144,7 +2153,7 @@ class MarbleWorld extends Scheduler { // 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.getRotationQuat().toMatrix()); - this.setUp(up, this.timeState, true); + this.setUp(marble, up, this.timeState, true); // Restore gem states for (gem in this.gems) { @@ -2156,7 +2165,7 @@ class MarbleWorld extends Scheduler { this.playGui.formatGemCounter(this.gemCount, this.totalGems); this.playGui.setCenterText(''); this.clearSchedule(); - this.outOfBounds = false; + 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) { diff --git a/src/modes/GameMode.hx b/src/modes/GameMode.hx index a83a36e6..991d40d5 100644 --- a/src/modes/GameMode.hx +++ b/src/modes/GameMode.hx @@ -1,5 +1,6 @@ package modes; +import src.Marble; import rewind.RewindableState; import shapes.Gem; import h3d.Quat; @@ -24,7 +25,7 @@ interface GameMode { public function applyRewindState(state:RewindableState):Void; public function onTimeExpire():Void; public function onRestart():Void; - public function onRespawn():Void; + public function onRespawn(marble:Marble):Void; public function onGemPickup(gem:Gem):Void; public function getPreloadFiles():Array; diff --git a/src/modes/HuntMode.hx b/src/modes/HuntMode.hx index 32079b6b..399812ef 100644 --- a/src/modes/HuntMode.hx +++ b/src/modes/HuntMode.hx @@ -22,6 +22,7 @@ import mis.MissionElement.MissionElementSpawnSphere; import src.AudioManager; import src.ResourceLoader; import src.Settings; +import src.Marble; @:publicFields class GemSpawnSphere { @@ -240,7 +241,7 @@ class HuntMode extends NullMode { return null; } - override function onRespawn() { + override function onRespawn(marble:Marble) { if (activeGemSpawnGroup.length != 0) { var gemAvg = new Vector(); for (gi in activeGemSpawnGroup) { @@ -248,15 +249,15 @@ class HuntMode extends NullMode { gemAvg = gemAvg.add(g.position); } gemAvg.scale(1 / activeGemSpawnGroup.length); - var delta = gemAvg.sub(level.marble.getAbsPos().getPosition()); + var delta = gemAvg.sub(marble.getAbsPos().getPosition()); var gravFrame = level.getOrientationQuat(0).toMatrix(); var v1 = gravFrame.front(); var v2 = gravFrame.right(); var deltaRot = new Vector(delta.dot(v2), delta.dot(v1)); if (deltaRot.length() >= 0.001) { var ang = Math.atan2(deltaRot.x, deltaRot.y); - level.marble.camera.CameraYaw = ang; - level.marble.camera.nextCameraYaw = ang; + marble.camera.CameraYaw = ang; + marble.camera.nextCameraYaw = ang; } } } @@ -477,7 +478,7 @@ class HuntMode extends NullMode { level.finishPitch = level.marble.camera.CameraPitch; level.displayAlert("Congratulations! You've finished!"); level.cancel(@:privateAccess level.oobSchedule); - level.cancel(@:privateAccess level.oobSchedule2); + level.cancel(@:privateAccess level.marble.oobSchedule); if (!level.isWatching) { var myScore = { name: "Player", diff --git a/src/modes/NullMode.hx b/src/modes/NullMode.hx index 5d2d78e1..c406708b 100644 --- a/src/modes/NullMode.hx +++ b/src/modes/NullMode.hx @@ -1,5 +1,6 @@ package modes; +import src.Marble; import rewind.RewindableState; import modes.GameMode.ScoreType; import shapes.Gem; @@ -56,7 +57,7 @@ class NullMode implements GameMode { public function onRestart() {} - public function onRespawn() {} + public function onRespawn(marble:Marble) {} public function onGemPickup(gem:Gem) { this.level.gemCount++; diff --git a/src/net/MoveManager.hx b/src/net/MoveManager.hx index 8f6d1558..797be600 100644 --- a/src/net/MoveManager.hx +++ b/src/net/MoveManager.hx @@ -26,9 +26,6 @@ class NetMove { // For rewind purposes var powerup:PowerUp; var powerupStates:Array; - var helicopterState:Float; - var megaState:Float; - var blastAmt:Float; public function new(move:Move, motionDir:Vector, timeState:TimeState, id:Int) { this.move = move; @@ -101,9 +98,6 @@ class MoveManager { var netMove = new NetMove(move, motionDir, timeState.clone(), nextMoveId++); netMove.powerup = marble.heldPowerup; netMove.powerupStates = []; - netMove.helicopterState = @:privateAccess marble.helicopterEnableTime; - netMove.megaState = @:privateAccess marble.megaMarbleEnableTime; - netMove.blastAmt = marble.blastAmount; for (pw in marble.level.powerUps) { netMove.powerupStates.push(pw.lastPickUpTime); } diff --git a/src/net/NetPacket.hx b/src/net/NetPacket.hx index 82220138..e05112e3 100644 --- a/src/net/NetPacket.hx +++ b/src/net/NetPacket.hx @@ -42,6 +42,7 @@ class MarbleUpdatePacket implements NetPacket { var blastTick:Int; var megaTick:Int; var heliTick:Int; + var oob:Bool; var moveQueueSize:Int; public function new() {} @@ -64,6 +65,7 @@ class MarbleUpdatePacket implements NetPacket { b.writeUInt16(blastTick); b.writeUInt16(heliTick); b.writeUInt16(megaTick); + b.writeByte(oob ? 1 : 0); } public inline function deserialize(b:haxe.io.BytesInput) { @@ -78,5 +80,6 @@ class MarbleUpdatePacket implements NetPacket { blastTick = b.readUInt16(); heliTick = b.readUInt16(); megaTick = b.readUInt16(); + oob = b.readByte() != 0; } } diff --git a/src/rewind/RewindManager.hx b/src/rewind/RewindManager.hx index 50559653..b308cc40 100644 --- a/src/rewind/RewindManager.hx +++ b/src/rewind/RewindManager.hx @@ -93,8 +93,8 @@ class RewindManager { } rf.blastAmt = level.marble.blastAmount; rf.oobState = { - oob: level.outOfBounds, - timeState: level.outOfBoundsTime != null ? level.outOfBoundsTime.clone() : null + oob: level.marble.outOfBounds, + timeState: level.marble.outOfBoundsTime != null ? level.marble.outOfBoundsTime.clone() : null }; rf.checkpointState = { currentCheckpoint: @:privateAccess level.currentCheckpoint, @@ -150,7 +150,7 @@ class RewindManager { if (level.marble.currentUp.x != rf.currentUp.x || level.marble.currentUp.y != rf.currentUp.y || level.marble.currentUp.z != rf.currentUp.z) { - level.setUp(rf.currentUp, level.timeState); + level.setUp(level.marble, rf.currentUp, level.timeState); // Hacky things @:privateAccess level.orientationChangeTime = level.timeState.currentAttemptTime - 300; var oldorient = level.newOrientationQuat; @@ -205,18 +205,18 @@ class RewindManager { if (!rf.oobState.oob) { @:privateAccess level.cancel(level.oobSchedule); - @:privateAccess level.cancel(level.oobSchedule2); + @:privateAccess level.cancel(level.marble.oobSchedule); } else { - level.goOutOfBounds(); + level.goOutOfBounds(level.marble); } - level.outOfBounds = rf.oobState.oob; - if (level.outOfBounds) + level.marble.outOfBounds = rf.oobState.oob; + if (level.marble.outOfBounds) @:privateAccess level.playGui.setCenterText('Out of Bounds'); else @:privateAccess level.playGui.setCenterText(''); level.marble.camera.oob = rf.oobState.oob; - level.outOfBoundsTime = rf.oobState.timeState != null ? rf.oobState.timeState.clone() : null; + level.marble.outOfBoundsTime = rf.oobState.timeState != null ? rf.oobState.timeState.clone() : null; level.marble.blastAmount = rf.blastAmt; @:privateAccess level.checkpointCollectedGems = rf.checkpointState.checkpointCollectedGems; @:privateAccess level.cheeckpointBlast = rf.checkpointState.checkpointBlast; diff --git a/src/shapes/AntiGravity.hx b/src/shapes/AntiGravity.hx index 90b135a9..eebad1d9 100644 --- a/src/shapes/AntiGravity.hx +++ b/src/shapes/AntiGravity.hx @@ -38,7 +38,7 @@ class AntiGravity extends PowerUp { var direction = new Vector(0, 0, -1); direction.transform(this.getRotationQuat().toMatrix()); if (marble == level.marble) - this.level.setUp(direction, timeState); + this.level.setUp(marble, direction, timeState); else marble.currentUp.load(direction); } diff --git a/src/triggers/InBoundsTrigger.hx b/src/triggers/InBoundsTrigger.hx index 9ef3c84c..7a62e762 100644 --- a/src/triggers/InBoundsTrigger.hx +++ b/src/triggers/InBoundsTrigger.hx @@ -6,7 +6,7 @@ import src.Marble; class InBoundsTrigger extends Trigger { override function onMarbleLeave(marble:Marble, timeState:TimeState) { - this.level.goOutOfBounds(); + this.level.goOutOfBounds(marble); // this.level.replay.recordMarbleLeave(this); } diff --git a/src/triggers/OutOfBoundsTrigger.hx b/src/triggers/OutOfBoundsTrigger.hx index c005a396..7e71f4c1 100644 --- a/src/triggers/OutOfBoundsTrigger.hx +++ b/src/triggers/OutOfBoundsTrigger.hx @@ -6,7 +6,7 @@ import src.Marble; class OutOfBoundsTrigger extends Trigger { override function onMarbleInside(marble:Marble, time:TimeState) { - this.level.goOutOfBounds(); + this.level.goOutOfBounds(marble); // this.level.replay.recordMarbleInside(this); }