private void DestroyAction(TimeInversibleAction action) { int storageIndex = actionsStorage.FindIndex(t => t.Item1 == action); if (storageIndex >= 0) { LogDebug("Destroying action: " + action.ToString()); GameObject actionObject = actionsStorage[storageIndex].Item2; actionsStorage.RemoveAt(storageIndex); Destroy(actionObject); } else { LogError($"The following action was not destroyed since it's not one of this object's actions: {action}"); } }
/// <summary> /// Actions call this method when then completed backwards. It is generally a propert time to discard them /// as they will not be played again. /// </summary> internal void SignalActionCompletedBackwards(TimeInversibleAction action) { DestroyAction(action); }
/// <summary> /// Signals that an action could not start. This may be due to the player creating time paradoxes. /// These failed actions should probably be discarded in such case. /// </summary> internal void SignalActionStartFailed(TimeInversibleAction action) { Log($"The following action could not start and will be discarded: {action}"); DestroyAction(action); }