예제 #1
0
 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);
 }
예제 #2
0
 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)
     });
 }
예제 #3
0
    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);
            }
        }
    }
예제 #4
0
    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);
    }
예제 #5
0
 public ClaimToken(ClaimKeeper keeper, string resourceId)
 {
     this.keeper     = keeper;
     this.resourceId = resourceId;
 }