Exemplo n.º 1
0
    public bool Action(Verb verb, AttachmentPoint target)
    {
        Physical physicalSelf = verb.self as Physical;

        if (physicalSelf != null)
        {
            Physical parent = PhysicalUtilities.FindParentPhysical(physicalSelf);
            target.Attach(parent);
        }
        else
        {
            target.Attach(verb.self);
        }

        // Create data dictionary to be passed to observers
        Dictionary <string, object> data = new Dictionary <string, object>();

        // Message for Verbose pages
        data["message"] = new ObservableText($"[0] {verb.displayLabel.ToLower()} into [1].",
                                             new Tuple <GameObject, string>(verb.self, "name top"),
                                             new Tuple <GameObject, string>(target.GetParent(), "name")
                                             );
        data["turnPage"]     = true;
        data["displayAfter"] = true;

        TimelineManager.instance.OnAction(data);

        return(true);
    }
Exemplo n.º 2
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);
    }
Exemplo n.º 3
0
    bool EnterConnection(Verb verb, Connection connection, Dictionary <string, object> data = null)
    {
        Physical physicalSelf = null;

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

        Physical parent = PhysicalUtilities.FindParentPhysical(physicalSelf);

        bool success = connection.secondContainer.Attach(parent);

        if (success)
        {
            SendMessage(verb, connection.secondContainer.GetParent(), data);
        }

        return(success);
    }