private IEvent _Undo(bool countNonActionable = true) // TODO { IEvent e = allEvents.Pop(); // Make method for this if (e is IActionableEvent) { IBaseCommand undoCommand = (e as IActionableEvent).NewUndoCommand(); if (undoCommand is IEntityModifier) { IEntityModifier m = (undoCommand as IEntityModifier); Assert.IsTrue(m is IEventProducing); (m as IEventProducing).DontRecordEvent = true; EM.ApplyMod(m); } else if (undoCommand is IIndependentModifier) { IIndependentModifier m = (undoCommand as IIndependentModifier); Assert.IsTrue(m is IEventProducing); (m as IEventProducing).DontRecordEvent = true; EM.ApplyMod(m); } else if (undoCommand is Command) { throw new NotImplementedException(); } else { throw new Exception("Cannot apply undo command: " + undoCommand.GetType().Name); } } return(e); }
private void _Do(IEvent e) { if (e is IActionableEvent) { IBaseCommand doCommand = (e as IActionableEvent).NewDoCommand(); if (doCommand is IEntityModifier) { IEntityModifier m = (doCommand as IEntityModifier); Assert.IsTrue(m is IEventProducing); EM.ApplyMod(m); } else if (doCommand is IIndependentModifier) { IIndependentModifier m = (doCommand as IIndependentModifier); Assert.IsTrue(m is IEventProducing); EM.ApplyMod(m); } else if (doCommand is Command) { throw new NotImplementedException(); } else { throw new Exception(); } } }
private void DoIndependentMod(byte[] binary) { IIndependentModifier m = Serialisation.To <IIndependentModifier>(binary); PingSimulator.Delay(() => { EM.ApplyMod(m, DistributeBetweenPlayersAsyncFilter); }); }
public void SendIndependentModAndConfirm(IIndependentModifier m, Action finished) { int requestID = NetworkInteractionTracker.RecordMassPingRequestStarted(); Action <int, bool> ret = null; ReturnModSentByRequestID[requestID] = ret; long targetStep = IntervalTimer.NextPossibleStepToTarget(NetworkInteractionTracker.MaxPing); PhotonHelper.RequestFromPlayers( IndependentRequest, r => ReturnModSentByRequestID.Add(requestID, r), _ => { ReturnModSentByRequestID.Remove(requestID); if (finished != null) { finished.Invoke(); } }, PhotonNetwork.player.ID, m, requestID, targetStep ); }
public void SendIndependentMod(IIndependentModifier m) { View.RPC("DoIndependentMod", PhotonTargets.All, Serialisation.ToBinary(m)); }