コード例 #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;
 }