void ReleaseCommands() { IBaseCommand[] clone = new IBaseCommand[_retained.Count]; _retained.CopyTo(clone); for (int i = 0, cloneLength = clone.Length; i < cloneLength; i++) { IBaseCommand command = clone[i]; command.Release(); command.onFinish -= OnFinish; } }
void ExecuteCommand(Type type, Action <IBaseCommand> executeCommand) { IBaseCommand command = GetCommand(type); executeCommand(command); if (command.isRetained) { _retained.Add(command); } else { command.Release(); } }