diff --git a/src/gui/VersionGui.hx b/src/gui/VersionGui.hx index fade0dff..454b5071 100644 --- a/src/gui/VersionGui.hx +++ b/src/gui/VersionGui.hx @@ -13,10 +13,6 @@ class VersionGui extends GuiImage { public function new() { var res = ResourceLoader.getImage("data/ui/xbox/BG_fadeOutSoftEdge.png").resource.toTile(); super(res); - var domcasual32fontdata = ResourceLoader.getFileEntry("data/font/DomCasualD.fnt"); - var domcasual32b = new BitmapFont(domcasual32fontdata.entry); - @:privateAccess domcasual32b.loader = ResourceLoader.loader; - var domcasual32 = domcasual32b.toSdfFont(cast 42 * Settings.uiScale, MultiChannel); this.horizSizing = Width; this.vertSizing = Height; diff --git a/src/modes/GameMode.hx b/src/modes/GameMode.hx index c32b41e6..606be47a 100644 --- a/src/modes/GameMode.hx +++ b/src/modes/GameMode.hx @@ -1,5 +1,6 @@ package modes; +import rewind.RewindableState; import shapes.Gem; import h3d.Quat; import h3d.Vector; @@ -19,6 +20,8 @@ interface GameMode { public function timeMultiplier():Float; public function getScoreType():ScoreType; public function getFinishScore():Float; + public function getRewindState():RewindableState; + public function applyRewindState(state:RewindableState):Void; public function onTimeExpire():Void; public function onRestart():Void; public function onGemPickup(gem:Gem):Void; diff --git a/src/modes/HuntMode.hx b/src/modes/HuntMode.hx index cdd1b576..07eb242c 100644 --- a/src/modes/HuntMode.hx +++ b/src/modes/HuntMode.hx @@ -1,5 +1,6 @@ package modes; +import rewind.RewindableState; import gui.AchievementsGui; import modes.GameMode.ScoreType; import shapes.GemBeam; @@ -75,6 +76,28 @@ class GemOctreeElem implements IOctreeObject { } } +@:publicFields +class HuntState implements RewindableState { + var activeGemSpawnGroup:Array; + var activeGems:Array; + var points:Int; + + public function new() {} + + public function apply(level:src.MarbleWorld) { + var mode:HuntMode = cast level.gameMode; + mode.applyRewindState(this); + } + + public function clone():RewindableState { + var c = new HuntState(); + c.activeGemSpawnGroup = activeGemSpawnGroup.copy(); + c.points = points; + c.activeGems = activeGems.copy(); + return c; + } +} + class HuntMode extends NullMode { var gemSpawnPoints:Array = []; var playerSpawnPoints:Array = []; @@ -357,4 +380,32 @@ class HuntMode extends NullMode { override function getFinishScore():Float { return points; } + + override function getRewindState():RewindableState { + var s = new HuntState(); + s.points = points; + s.activeGemSpawnGroup = activeGemSpawnGroup; + s.activeGems = activeGems.copy(); + return s; + } + + override function applyRewindState(state:RewindableState) { + var s:HuntState = cast state; + points = s.points; + @:privateAccess level.playGui.formatGemHuntCounter(points); + for (gem in activeGems) { + gem.pickedUp = true; + gem.setHide(true); + var gemBeam = gemToBeamMap.get(gem); + gemBeam.setHide(true); + } + activeGemSpawnGroup = s.activeGemSpawnGroup; + activeGems = s.activeGems; + for (gem in activeGems) { + gem.pickedUp = false; + gem.setHide(false); + var gemBeam = gemToBeamMap.get(gem); + gemBeam.setHide(false); + } + } } diff --git a/src/modes/NullMode.hx b/src/modes/NullMode.hx index d93b827a..902c840e 100644 --- a/src/modes/NullMode.hx +++ b/src/modes/NullMode.hx @@ -1,5 +1,6 @@ package modes; +import rewind.RewindableState; import modes.GameMode.ScoreType; import shapes.Gem; import h3d.Quat; @@ -94,4 +95,10 @@ class NullMode implements GameMode { public function getFinishScore():Float { return level.finishTime.gameplayClock; } + + public function getRewindState():RewindableState { + return null; + } + + public function applyRewindState(state:RewindableState) {} } diff --git a/src/rewind/RewindFrame.hx b/src/rewind/RewindFrame.hx index 2e2a088e..2d28f7c2 100644 --- a/src/rewind/RewindFrame.hx +++ b/src/rewind/RewindFrame.hx @@ -45,6 +45,7 @@ class RewindFrame { checkpointHeldPowerup:PowerUp, checkpointBlast:Float }; + var modeState:RewindableState; public function new() {} @@ -96,6 +97,7 @@ class RewindFrame { checkpointHeldPowerup: checkpointState.checkpointHeldPowerup, checkpointBlast: checkpointState.checkpointBlast, }; + c.modeState = modeState != null ? modeState.clone() : null; return c; } } diff --git a/src/rewind/RewindManager.hx b/src/rewind/RewindManager.hx index 2d7fbe4f..31754393 100644 --- a/src/rewind/RewindManager.hx +++ b/src/rewind/RewindManager.hx @@ -74,6 +74,7 @@ class RewindManager { checkpointCollectedGems: @:privateAccess level.checkpointCollectedGems.copy(), checkpointHeldPowerup: @:privateAccess level.checkpointHeldPowerup, }; + rf.modeState = level.gameMode.getRewindState(); frames.push(rf); } @@ -171,6 +172,8 @@ class RewindManager { @:privateAccess level.checkpointHeldPowerup = rf.checkpointState.checkpointHeldPowerup; @:privateAccess level.currentCheckpoint = rf.checkpointState.currentCheckpoint; @:privateAccess level.currentCheckpointTrigger = rf.checkpointState.currentCheckpointTrigger; + if (rf.modeState != null) + rf.modeState.apply(level); } public function getNextRewindFrame(absTime:Float):RewindFrame { diff --git a/src/rewind/RewindableState.hx b/src/rewind/RewindableState.hx new file mode 100644 index 00000000..a919db70 --- /dev/null +++ b/src/rewind/RewindableState.hx @@ -0,0 +1,8 @@ +package rewind; + +import src.MarbleWorld; + +interface RewindableState { + function apply(level:MarbleWorld):Void; + function clone():RewindableState; +}