public void ForceRestoreSnapshot(TimeDict.TimeSlice snapshotDictionary) { Activated.ForceLoadSnapshot(snapshotDictionary); Occupied.ForceLoadSnapshot(snapshotDictionary); ActivatedTimeStep.ForceLoadSnapshot(snapshotDictionary); Countdown.ForceLoadSnapshot(snapshotDictionary); playerID.ForceLoadSnapshot(snapshotDictionary); FlagDestroy = snapshotDictionary.Get <bool>(GameController.FLAG_DESTROY); ItemForm = snapshotDictionary.Get <bool>(nameof(ItemForm)); Position.ForceLoadSnapshot(snapshotDictionary); Position.Current = Position.History; IsAnimatingOpenClose = snapshotDictionary.Get <bool>(nameof(IsAnimatingOpenClose)); animator.SetBool(AnimateOpen, IsAnimatingOpenClose); IsAnimatingFold = snapshotDictionary.Get <bool>(nameof(IsAnimatingFold)); animator.SetBool(AnimateFolding, IsAnimatingFold); IsAnimatingUnfold = snapshotDictionary.Get <bool>(nameof(IsAnimatingUnfold)); animator.SetBool(AnimateUnfolding, IsAnimatingUnfold); doneTimeTravelPlayerID = snapshotDictionary.Get <int>(nameof(doneTimeTravelPlayerID)); isFoldable = snapshotDictionary.Get <bool>(nameof(isFoldable)); animator.SetBool(AnimIsFoldable, isFoldable); animator.SetBool(AnimIsItem, ItemForm); gameObject.SetActive((!ItemForm && !FlagDestroy) || IsAnimatingFold); }
public virtual void PreUpdateLoadSnapshot(TimeDict.TimeSlice snapshotDictionary) { //FlagDestroy = snapshotDictionary.Get<bool>(GameController.FLAG_DESTROY); prevFlagDestroy = gameController.GetSnapshotValue <bool>(this, gameController.TimeStep - 1, GameController.FLAG_DESTROY); UpdateShow(); }
// TODO: add fixed frame # associated with snapshot? and Lerp in update loop?! public void PreUpdateLoadSnapshot(TimeDict.TimeSlice snapshotDictionary) { prevItemID = ItemID; ItemID = snapshotDictionary.Get <int>(nameof(ItemID)); if (prevItemID != -1 && ItemID == -1) { ItemID = prevItemID; // keep previous item id locally if it was dropped this frame prevItemID = -2; //-2 to indicate it was removed this frame, so we don't re-save the value } Position.LoadSnapshot(snapshotDictionary); Velocity.LoadSnapshot(snapshotDictionary); if (gameController.CurrentPlayerID != ID) // we don't want the current player to revert to their history positions/velocity { Position.Current = Position.History; Velocity.Current = Velocity.History; } Rigidbody.rotation = snapshotDictionary.Get <float>(nameof(Rigidbody.rotation)); historyActivating = snapshotDictionary.Get <bool>(nameof(isActivating)); DidTimeTravel = snapshotDictionary.Get <bool>(nameof(DidTimeTravel)); facingRight = snapshotDictionary.Get <bool>(nameof(facingRight)); isSpriteOrderForced = snapshotDictionary.Get <bool>(nameof(isSpriteOrderForced)); FlagDestroy = snapshotDictionary.Get <bool>(GameController.FLAG_DESTROY); }
public virtual void SaveSnapshot(TimeDict.TimeSlice snapshotDictionary, bool force = false) { // NOTE: behavior for how current/history are stored is ill-defined for templated type T snapshotDictionary.Set(CurrentName, Current, force); snapshotDictionary.Set(HistoryName, History, force); }
public override void SaveSnapshot(TimeDict.TimeSlice snapshotDictionary, bool force = false) { base.SaveSnapshot(snapshotDictionary, force); snapshotDictionary.Set(nameof(movingRight), movingRight); snapshotDictionary.Set(nameof(toFire), toFire); snapshotDictionary.Set(nameof(_alertState), _alertState); }
public void PreUpdateLoadSnapshot(TimeDict.TimeSlice snapshotDictionary) { Activated.LoadSnapshot(snapshotDictionary); Occupied.LoadSnapshot(snapshotDictionary); ActivatedTimeStep.LoadSnapshot(snapshotDictionary); Countdown.LoadSnapshot(snapshotDictionary); playerID.LoadSnapshot(snapshotDictionary); FlagDestroy = snapshotDictionary.Get <bool>(GameController.FLAG_DESTROY); gameObject.SetActive((!ItemForm && !FlagDestroy) || IsAnimatingFold); IsAnimatingOpenClose = snapshotDictionary.Get <bool>(nameof(IsAnimatingOpenClose)); animator.SetBool(AnimateOpen, IsAnimatingOpenClose); IsAnimatingFold = snapshotDictionary.Get <bool>(nameof(IsAnimatingFold)); animator.SetBool(AnimateFolding, IsAnimatingFold); IsAnimatingUnfold = snapshotDictionary.Get <bool>(nameof(IsAnimatingUnfold)); animator.SetBool(AnimateUnfolding, IsAnimatingUnfold); int prevDoneTimeTravelPlayerID = doneTimeTravelPlayerID; doneTimeTravelPlayerID = snapshotDictionary.Get <int>(nameof(doneTimeTravelPlayerID)); if (prevDoneTimeTravelPlayerID != -1 && doneTimeTravelPlayerID == -1) { // persist this value one frame locally so that player sprite order etc are updated in GameUpdate() doneTimeTravelPlayerID = prevDoneTimeTravelPlayerID; } Occupied.Current &= Activated.History; }
public override void SaveSnapshot(TimeDict.TimeSlice snapshotDictionary, bool force = false) { base.SaveSnapshot(snapshotDictionary, force); snapshotDictionary.Set(nameof(requiredActivatableIDs), string.Join(",", requiredActivatableIDs), force: force); snapshotDictionary.Set(nameof(distance), distance, force: force); snapshotDictionary.Set(nameof(spritePath), spritePath, force: force); }
public override void ForceRestoreSnapshot(TimeDict.TimeSlice snapshotDictionary) { base.ForceRestoreSnapshot(snapshotDictionary); movingRight = snapshotDictionary.Get <bool>(nameof(movingRight)); toFire = snapshotDictionary.Get <float>(nameof(toFire)); _alertState = snapshotDictionary.Get <bool>(nameof(_alertState)); }
public override void ForceRestoreSnapshot(TimeDict.TimeSlice snapshotDictionary) { base.ForceRestoreSnapshot(snapshotDictionary); LoadActivatables(snapshotDictionary); distance = snapshotDictionary.Get <float>(nameof(distance)); spritePath = snapshotDictionary.Get <string>(nameof(spritePath)); }
public virtual void SaveSnapshot(TimeDict.TimeSlice snapshotDictionary, bool force = false) { prevFlagDestroy = FlagDestroy; snapshotDictionary.Set(GameController.FLAG_DESTROY, FlagDestroy, force, clearFuture: true); snapshotDictionary.Set(nameof(ItemForm), ItemForm, force, clearFuture: true); UpdateShow(); Position.SaveSnapshot(snapshotDictionary, force); }
public virtual void ForceRestoreSnapshot(TimeDict.TimeSlice snapshotDictionary) { FlagDestroy = snapshotDictionary.Get <bool>(GameController.FLAG_DESTROY); prevFlagDestroy = gameController.GetSnapshotValue <bool>(this, gameController.TimeStep - 1, GameController.FLAG_DESTROY); ItemForm = snapshotDictionary.Get <bool>(nameof(ItemForm)); Position.ForceLoadSnapshot(snapshotDictionary); Position.Current = Position.History; UpdateShow(); }
public void SaveSnapshot(TimeDict.TimeSlice snapshotDictionary, bool force = false) { Position.SaveSnapshot(snapshotDictionary, force); Velocity.SaveSnapshot(snapshotDictionary, force); snapshotDictionary.Set(nameof(ItemID), prevItemID == -2 ? -1 : ItemID, force, clearFuture: true); snapshotDictionary.Set(nameof(Rigidbody.rotation), Rigidbody.rotation, force); snapshotDictionary.Set(nameof(isActivating), isActivating, force); snapshotDictionary.Set(nameof(DidTimeTravel), DidTimeTravel, force); snapshotDictionary.Set(nameof(facingRight), facingRight, force); snapshotDictionary.Set(nameof(isSpriteOrderForced), isSpriteOrderForced, force); //snapshotDictionary[nameof(GetCollisionStateString)] = GetCollisionStateString(); snapshotDictionary.Set(GameController.FLAG_DESTROY, FlagDestroy, force); //NOTE: players should never be in item form, so don't save/load that info here }
public override void SaveSnapshot(TimeDict.TimeSlice snapshotDictionary, bool force = false) { bool clearPositionFuture = false; if (_canClearFuturePosition) { clearPositionFuture = Vector2.Distance(Current, History) > GameController.POSITION_CLEAR_FUTURE_THRESHOLD; } Vector2 temp = Current; snapshotDictionary.Set(CurrentName, temp, force, clearPositionFuture); snapshotDictionary.Set(HistoryName, temp == Vector2.negativeInfinity ? History : temp, force, clearPositionFuture); }
public void SaveSnapshot(TimeDict.TimeSlice snapshotDictionary, bool force = false) { Activated.SaveSnapshot(snapshotDictionary, force); Occupied.SaveSnapshot(snapshotDictionary, force); ActivatedTimeStep.SaveSnapshot(snapshotDictionary, force); Countdown.SaveSnapshot(snapshotDictionary, force); playerID.SaveSnapshot(snapshotDictionary, force); snapshotDictionary.Set(GameController.FLAG_DESTROY, FlagDestroy, force); snapshotDictionary.Set(nameof(ItemForm), ItemForm, force, clearFuture: true); snapshotDictionary.Set(nameof(IsAnimatingOpenClose), IsAnimatingOpenClose); // don't force animations?! snapshotDictionary.Set(nameof(IsAnimatingFold), IsAnimatingFold); snapshotDictionary.Set(nameof(IsAnimatingUnfold), IsAnimatingUnfold); snapshotDictionary.Set(nameof(doneTimeTravelPlayerID), doneTimeTravelPlayerID, force); snapshotDictionary.Set(nameof(isFoldable), isFoldable, force); Position.SaveSnapshot(snapshotDictionary, force); }
private void LoadActivatables(TimeDict.TimeSlice snapshotDictionary) { string newActivatableString = snapshotDictionary.Get <string>(nameof(requiredActivatableIDs)); if (prevActivatableString != newActivatableString) { prevActivatableString = newActivatableString; requiredActivatables.Clear(); requiredActivatableIDs.Clear(); string[] activatableStringIDs = newActivatableString.Split(','); foreach (var stringID in activatableStringIDs) { if (int.TryParse(stringID, out int id)) { var activatableBehaviour = gameController.GetObjectByID(id) as ActivatableBehaviour; Assert.IsNotNull(activatableBehaviour); requiredActivatables.Add(activatableBehaviour); requiredActivatableIDs.Add(id); } } } }
public override void ForceRestoreSnapshot(TimeDict.TimeSlice snapshotDictionary) { timer = snapshotDictionary.Get <float>(nameof(timer)); }
public override void SaveSnapshot(TimeDict.TimeSlice snapshotDictionary, bool force = false) { snapshotDictionary.Set(nameof(timer), timer, force: force, clearFuture: true); }
public override void PreUpdateLoadSnapshot(TimeDict.TimeSlice snapshotDictionary) { timer = snapshotDictionary.Get <float>(nameof(timer)); }
public virtual void ForceLoadSnapshot(TimeDict.TimeSlice snapshotDictionary) { Current = snapshotDictionary.Get <T>(CurrentName); History = snapshotDictionary.Get <T>(HistoryName); }
public virtual void LoadSnapshot(TimeDict.TimeSlice snapshotDictionary) { History = snapshotDictionary.Get <T>(HistoryName); }
public override void SaveSnapshot(TimeDict.TimeSlice snapshotDictionary, bool force = false) { snapshotDictionary.Set(CurrentName, Current, force); snapshotDictionary.Set(HistoryName, Current == -1 ? History : Current, force); }
public override void PreUpdateLoadSnapshot(TimeDict.TimeSlice snapshotDictionary) { base.PreUpdateLoadSnapshot(snapshotDictionary); }
public override void SaveSnapshot(TimeDict.TimeSlice snapshotDictionary, bool force = false) { base.SaveSnapshot(snapshotDictionary, force); snapshotDictionary.Set(nameof(destroyStep), destroyStep, force); }
public override void ForceRestoreSnapshot(TimeDict.TimeSlice snapshotDictionary) { base.ForceRestoreSnapshot(snapshotDictionary); destroyStep = snapshotDictionary.Get <int>(nameof(destroyStep)); }
public override void PreUpdateLoadSnapshot(TimeDict.TimeSlice snapshotDictionary) { base.PreUpdateLoadSnapshot(snapshotDictionary); destroyStep = snapshotDictionary.Get <int>(nameof(destroyStep)); }