Ejemplo n.º 1
0
    public override CheckResult Check(Verb verb, GameObject target)
    {
        PhysicalAttachmentPoint inventory = null;
        Physical physicalSelf             = null;

        try {
            inventory    = (PhysicalAttachmentPoint)verb.blackboard["inventory"];
            physicalSelf = (Physical)verb.blackboard["physicalSelf"];
        } catch (SystemException e) {
            WaywardManager.instance.Log($@"<red>GrabVerb of GameObject '{verb.self.GetName()}' failed in CheckResult:</red> {e}");
            return(CheckResult.INVALID);
        }

        if (target.container == null || inventory == null)
        {
            return(CheckResult.INVALID);
        }

        Physical physical = target as Physical;

        if (physical == null || physical.attachedTo != null)
        {
            return(CheckResult.INVALID);
        }

        if (physical.Contains(physicalSelf))
        {
            return(CheckResult.INVALID);
        }

        if (inventory.Contains(target))
        {
            CheckResult check = verb.self.container.CanAttach(target);
            if (check >= CheckResult.RESTRICTED)
            {
                return(check);
            }
        }
        else
        {
            Physical parent = PhysicalUtilities.FindParentPhysical(physicalSelf);
            if (parent.container.Contains(target))
            {
                CheckResult check = inventory.CanAttach(target);
                if (check >= CheckResult.RESTRICTED)
                {
                    return(check);
                }
            }
        }

        return(CheckResult.INVALID);
    }
Ejemplo n.º 2
0
    bool ParseGrap(Verb verb, InputEventArgs inputEventArgs)
    {
        Physical physicalSelf = null;

        try {
            physicalSelf = (Physical)verb.blackboard["physicalSelf"];
        } catch (SystemException e) {
            WaywardManager.instance.Log($@"<red>GrabVerb of GameObject '{verb.self.GetName()}' failed in ParseGrab:</red> {e}");
            return(true);
        }

        if (inputEventArgs.parameters.Length <= 0)
        {
            WaywardManager.instance.DisplayMessage($"Grab what?");
            return(true);
        }

        GameObject foundObject = GetInputTarget(verb, inputEventArgs);

        if (foundObject == null)
        {
            return(true);
        }
        if (foundObject == verb.self)
        {
            WaywardManager.instance.DisplayMessage($"You get a hold of yourself.");
            return(true);
        }

        if (verb.Check(foundObject) == CheckResult.VALID)
        {
            Physical physical = foundObject as Physical;
            if (physical != null && physicalSelf.Contains(physical))
            {
                WaywardManager.instance.DisplayMessage($"You are already holding {foundObject.GetData("name").text}.");
                return(true);
            }
            else
            {
                verb.Register(new Dictionary <string, object>()
                {
                    { "target", foundObject }
                }, true);
                return(true);
            }
        }
        else
        {
            WaywardManager.instance.DisplayMessage($"Could not grab {foundObject.GetData("name").text}.");
            return(true);
        }
    }
Ejemplo n.º 3
0
    public override CheckResult Check(Verb verb, GameObject target)
    {
        CheckResult check = CheckResult.INVALID;

        if (verb.self.container.GetParent() == target &&
            target.container != null &&
            target.container != verb.self.container)
        {
            check = target.container.CanAttach(verb.self);
            if (check >= CheckResult.RESTRICTED)
            {
                return(check);
            }
        }

        Physical physical = target as Physical;

        if (physical != null)
        {
            Physical physicalSelf = verb.self as Physical;
            if (physicalSelf != null &&
                physicalSelf.Contains(physical))
            {
                return(CheckResult.INVALID);
            }

            foreach (AttachmentPoint point in physical.GetAttachmentPoints())
            {
                if (point == verb.self.container)
                {
                    continue;
                }

                CheckResult pointCheck = point.CanAttach(verb.self);
                check = pointCheck > check ? pointCheck : check;
                if (check >= CheckResult.RESTRICTED)
                {
                    return(check);
                }
            }
        }

        return(check);
    }
Ejemplo n.º 4
0
        public static bool IsPhysical(this GameObject tar)
        {
            var gameObject = tar as Character;

            return(gameObject != null && Physical.Contains(gameObject.CurrentJob));
        }