gem hunt rewind

This commit is contained in:
RandomityGuy 2023-07-04 19:49:38 +05:30
parent c1164b4c11
commit 0f1be7359b
7 changed files with 74 additions and 4 deletions

View file

@ -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;

View file

@ -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;

View file

@ -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<GemSpawnSphere>;
var activeGems:Array<Gem>;
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<GemSpawnSphere> = [];
var playerSpawnPoints:Array<MissionElementSpawnSphere> = [];
@ -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);
}
}
}

View file

@ -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) {}
}

View file

@ -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;
}
}

View file

@ -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 {

View file

@ -0,0 +1,8 @@
package rewind;
import src.MarbleWorld;
interface RewindableState {
function apply(level:MarbleWorld):Void;
function clone():RewindableState;
}