public Error Cancel(uint id) { ActiveAction activeAction; if (ActiveActions.TryGetValue(id, out activeAction) && !activeAction.IsDone) { var actionRequirements = Ioc.Kernel.Get <ActionRequirementFactory>().GetActionRequirementRecord(activeAction.WorkerType); var actionRequirement = actionRequirements.List.FirstOrDefault(x => x.Index == activeAction.WorkerIndex); if (actionRequirement == null || (actionRequirement.Option & ActionOption.Uncancelable) == ActionOption.Uncancelable) { return(Error.ActionUncancelable); } ThreadPool.QueueUserWorkItem(ActiveCancelCallback, activeAction); return(Error.Ok); } PassiveAction passiveAction; if (PassiveActions.TryGetValue(id, out passiveAction) && !passiveAction.IsDone) { if (!passiveAction.IsCancellable) { return(Error.ActionUncancelable); } ThreadPool.QueueUserWorkItem(PassiveCancelCallback, passiveAction); return(Error.Ok); } return(Error.ActionNotFound); }
public bool Contains(GameAction action) { if (action is ActiveAction) { return(ActiveActions.ContainsKey(action.ActionId)); } if (action is PassiveAction) { return(PassiveActions.ContainsKey(action.ActionId)); } return(false); }