Exemplo n.º 1
0
    public virtual string GetInvalidActorReason(VoosActor actor)
    {
        if (actor == null)
        {
            return("Actor does not exist anymore!");
        }

        // True, this doesn't prevent the race condition if two players try to
        // request-lock the same actor. Basically one will win, and the other will
        // forever *think* they have it, but not really. And with copy-groups, this
        // problem becomes more likely. We'll ignore it for now, but in the future
        // possible solutions are: 1) make all tools poll for lock (and self-close
        // if they didn't actually get it), 2) have a centralized lock arbiter and
        // hopefully hide any edit latency, if possible.
        if (actor.IsLockedByAnother())
        {
            if (actor.IsCloneParentLockedByAnother())
            {
                VoosActor parent = actor.GetCloneParentActor();
                return($"LOCKED\nThis is a copy, and {parent.GetOwnerNickName()} is editing the original");
            }
            else
            {
                return($"LOCKED\n{actor.GetOwnerNickName()} is editing this");
            }
        }
        return(null);
    }
    private bool ShouldLockActor(out string message)
    {
        if (!disableLockedActors)
        {
            message = null;
            return(false);
        }

        // True, this doesn't prevent the race condition if two players try to
        // request-lock the same actor. Basically one will win, and the other will
        // forever *think* they have it, but not really. And with copy-groups, this
        // problem becomes more likely. We'll ignore it for now, but in the future
        // possible solutions are: 1) make all tools poll for lock (and self-close
        // if they didn't actually get it), 2) have a centralized lock arbiter and
        // hopefully hide any edit latency, if possible.
        if (actor != null && actor.IsLockedByAnother())
        {
            if (actor.IsCloneParentLockedByAnother())
            {
                VoosActor parent = actor.GetCloneParentActor();
                message = $"LOCKED\nThis is a copy, and {parent.GetOwnerNickName()} is editing the original";
                return(true);
            }
            else
            {
                message = $"LOCKED\n{actor.GetOwnerNickName()} is editing this";
                return(true);
            }
        }
        message = null;
        return(false);
    }