/// <summary>
 /// Coordinator will perform client side validation of the interaction using its validators. If any
 /// validator fails, validation will fail and NOTHING_HAPPENED will be returned.
 /// If validation succeeds, it will send RequestInteractMessage to the server to request the server
 /// to perform the interaction.
 /// </summary>
 /// <param name="interaction">interaction being performed.</param>
 /// <param name="specificComponent">Name of specific component on the object to be targeted by the interaction.</param>
 /// <returns>if validation succeeded</returns>
 public bool ClientValidateAndRequest(T interaction, string specificComponent = null)
 {
     if (willInteract != null && !willInteract.Invoke(interaction, NetworkSide.Client))
     {
         return(false);
     }
     InteractionMessageUtils.SendRequest(interaction, processor, specificComponent);
     return(true);
 }
Пример #2
0
    public bool Interact(HandApply interaction)
    {
        if (!DefaultWillInteract.HandApply(interaction, NetworkSide.Client))
        {
            return(false);
        }

        InteractionMessageUtils.SendRequest(interaction, this);
        return(true);
    }
    private void ProcessHandApply(GameObject handObject, GameObject targetObj, GameObject processorObj, GameObject performerObj, HandSlot usedSlot)
    {
        //try to look up the components on the processor that can handle this interaction
        var processorComponents = InteractionMessageUtils.TryGetProcessors <HandApply>(processorObj);
        //invoke each component that can handle this interaction
        var handApply = HandApply.ByClient(performerObj, handObject, targetObj, TargetBodyPart, usedSlot);

        foreach (var processorComponent in processorComponents)
        {
            if (processorComponent.ServerProcessInteraction(handApply))
            {
                //something happened, don't check further components
                return;
            }
        }
    }
    private void ProcessActivate(GameObject activatedObject, GameObject processorObj, GameObject performerObj, HandSlot handSlot)
    {
        //try to look up the components on the processor that can handle this interaction
        var processorComponents = InteractionMessageUtils.TryGetProcessors <HandActivate>(processorObj);
        //invoke each component that can handle this interaction
        var activate = HandActivate.ByClient(performerObj, activatedObject, handSlot);

        foreach (var processorComponent in processorComponents)
        {
            if (processorComponent.ServerProcessInteraction(activate))
            {
                //something happened, don't check further components
                return;
            }
        }
    }
Пример #5
0
    private void ProcessMouseDrop(GameObject handObject, GameObject targetObj, GameObject processorObj, GameObject performerObj)
    {
        //try to look up the components on the processor that can handle this interaction
        var processorComponents = InteractionMessageUtils.TryGetProcessors <MouseDrop>(processorObj);
        //invoke each component that can handle this interaction
        var mouseDrop = MouseDrop.ByClient(performerObj, handObject, targetObj);

        foreach (var processorComponent in processorComponents)
        {
            if (processorComponent.ServerProcessInteraction(mouseDrop))
            {
                //something happened, don't check further components
                return;
            }
        }
    }
    private void ProcessCombine(HandSlot usedSlot, GameObject handObject, InventorySlot targetSlot, GameObject processorObj, GameObject performerObj)
    {
        //try to look up the components on the processor that can handle this interaction
        var processorComponents = InteractionMessageUtils.TryGetProcessors <InventoryApply>(processorObj);
        //invoke each component that can handle this interaction
        var combine = InventoryApply.ByClient(performerObj, targetSlot, handObject, usedSlot);

        foreach (var processorComponent in processorComponents)
        {
            if (processorComponent.ServerProcessInteraction(combine))
            {
                //something happened, don't check further components
                return;
            }
        }
    }
    private void ProcessAimApply(GameObject handObject, Vector2 targetVector, GameObject processorObj,
                                 GameObject performerObj, HandSlot usedSlot, MouseButtonState buttonState)
    {
        //try to look up the components on the processor that can handle this interaction
        var processorComponents = InteractionMessageUtils.TryGetProcessors <AimApply>(processorObj);
        //invoke each component that can handle this interaction
        var aimApply = AimApply.ByClient(performerObj, targetVector, handObject, usedSlot, buttonState);

        foreach (var processorComponent in processorComponents)
        {
            if (processorComponent.ServerProcessInteraction(aimApply))
            {
                //something happened, don't check further components
                return;
            }
        }
    }