public static bool TryClaimAndDo(ClaimKeeper keeper, string resourceId, System.Action doAction) { // Since this is a synchronous action and we already checked the claim status, // do the operation without requesting another claim token. doAction(); return(true); }
public static void PushUndoForResource(this UndoStack stack, ClaimKeeper keeper, ClaimableUndoItem undoItem) { stack.Push(new UndoStack.Item { actionLabel = undoItem.label, getUnableToDoReason = () => GetUnableToEditResourceReason(keeper, undoItem.resourceId, undoItem.resourceName, undoItem.cannotDoReason), getUnableToUndoReason = () => GetUnableToEditResourceReason(keeper, undoItem.resourceId, undoItem.resourceName, undoItem.cannotUndoReason), doIt = () => TryClaimAndDo(keeper, undoItem.resourceId, undoItem.doIt), undo = () => TryClaimAndDo(keeper, undoItem.resourceId, undoItem.undo) }); }
public static void CommandCkList(CommandTerminal.CommandArg[] args) { ClaimKeeper keeper = GameObject.FindObjectOfType <ClaimKeeper>(); foreach (KeyValuePair <int, HashSet <string> > pair in keeper.claimsByPlayerId) { foreach (string resourceId in pair.Value) { CommandTerminal.HeadlessTerminal.Log(pair.Key + " claims " + resourceId); } } }
public static string GetUnableToEditResourceReason(ClaimKeeper keeper, string resourceId, string resourceName, GetInvalidResourceReason reason) { string ownerNickname = keeper.GetEffectiveOwnerNickname(resourceId); if (ownerNickname != null && !keeper.IsMine(resourceId)) { return($"{ownerNickname} is editing '{resourceName}'."); } if (reason != null) { return(reason()); } return(null); }
public ClaimToken(ClaimKeeper keeper, string resourceId) { this.keeper = keeper; this.resourceId = resourceId; }