public static bool TryAddLocalCommand(ChangeBehaviourCommand command, World world) { if (CommandUtils.CommandIsValid(command, world)) { if (volatileChangeBehaviourCommands.ContainsKey(command.Target)) { //el commando es igual al que ya esta almacenado if (volatileChangeBehaviourCommands[command.Target].Equals(command)) { return(false); } else { volatileChangeBehaviourCommands[command.Target] = command; return(true); } } else { volatileChangeBehaviourCommands.Add(command.Target, command); return(true); } } else { return(false); } }
protected override void OnUpdate() { //Move Commands if (CommandStorageSystem.QueuedMoveCommands.TryGetValue(MainSimulationLoopSystem.CurrentLockstepTurn, out var MoveCommands)) { if (loggExecutionTurn) { Debug.Log($"Executing a move comand in the turn: {MainSimulationLoopSystem.CurrentLockstepTurn}"); } foreach (MoveCommand command in MoveCommands) { if (CommandUtils.CommandIsValid(command, World)) { ExecuteCommand(command); } } } if (CommandStorageSystem.QueuedChangeBehaviourCommands.TryGetValue(MainSimulationLoopSystem.CurrentLockstepTurn, out var changeBehaviourCommands)) { if (loggExecutionTurn) { Debug.Log($"Executing a change behaviour comand in the turn: {MainSimulationLoopSystem.CurrentLockstepTurn}"); } foreach (ChangeBehaviourCommand command in changeBehaviourCommands) { if (CommandUtils.CommandIsValid(command, World)) { ExecuteCommand(command); } } } if (CommandStorageSystem.QueuedGatherCommands.TryGetValue(MainSimulationLoopSystem.CurrentLockstepTurn, out var gatherCommands)) { if (loggExecutionTurn) { Debug.Log($"Executing a gather comand in the turn: {MainSimulationLoopSystem.CurrentLockstepTurn}"); } foreach (GatherCommand command in gatherCommands) { ExecuteCommand(command); } } //Other Commands }