Esempio n. 1
0
 public void ServerPerformInteraction(MouseDrop interaction)
 {
     if (interaction.TargetObject.TryGetComponent <StationBouncedRadio>(out var radio))
     {
         radio.AddEncryptionKey(this);
     }
 }
Esempio n. 2
0
    private void OnDragEnd()
    {
        UIManager.IsMouseInteractionDisabled = false;
        Destroy(shadowObject);
        shadowObject = null;
        if (lightingSystem.enabled && !lightingSystem.IsScreenPointVisible(CommonInput.mousePosition))
        {
            //do nothing, the point is not visible.
            return;
        }
        //check what we dropped on, which may or may not have mousedrop interaction components
        //can only drop on things that have a RegisterTile
        var dropTargets =
            MouseUtils.GetOrderedObjectsUnderMouse();

        //go through the stack of objects and call any drop components we find
        foreach (GameObject dropTarget in dropTargets)
        {
            MouseDrop info = MouseDrop.ByLocalPlayer(gameObject, dropTarget.gameObject);
            //call this object's mousedrop interaction methods if it has any, for each object we are dropping on
            if (InteractionUtils.ClientCheckAndTrigger(mouseDrops, info) != null)
            {
                return;
            }
            var targetComps = dropTarget.GetComponents <IBaseInteractable <MouseDrop> >()
                              .Where(mb => mb != null && (mb as MonoBehaviour).enabled);
            if (InteractionUtils.ClientCheckAndTrigger(targetComps, info) != null)
            {
                return;
            }
        }
    }
Esempio n. 3
0
    public bool Interact(MouseDrop interaction)
    {
        Logger.Log("Interaction detected on InteractableTiles.");

        LayerTile tile = LayerTileAt(interaction.ShadowWorldLocation, true);

        if (tile is BasicTile basicTile)
        {
            var tileApply     = new TileApply(interaction.Performer, interaction.UsedObject, interaction.Intent, (Vector2Int)WorldToCell(interaction.ShadowWorldLocation), this, basicTile, null, -((Vector2)interaction.Performer.transform.position - interaction.ShadowWorldLocation), TileApply.ApplyType.MouseDrop);
            var tileMouseDrop = new TileMouseDrop(interaction.Performer, interaction.UsedObject, interaction.Intent, (Vector2Int)WorldToCell(interaction.ShadowWorldLocation), this, basicTile, -((Vector2)interaction.Performer.transform.position - interaction.ShadowWorldLocation));
            foreach (var tileInteraction in basicTile.TileInteractions)
            {
                if (tileInteraction == null)
                {
                    continue;
                }
                if (tileInteraction.WillInteract(tileApply, NetworkSide.Client) &&
                    Cooldowns.TryStartClient(interaction, CommonCooldowns.Instance.Interaction))
                {
                    //request the tile interaction because we think one will happen
                    RequestInteractMessage.SendTileMouseDrop(tileMouseDrop, this);
                    return(true);
                }
            }
        }

        return(false);
    }
Esempio n. 4
0
    public void ServerPerformInteraction(MouseDrop interaction)
    {
        if (allowedToInteract == false)
        {
            return;
        }
        if (interaction.IsFromInventory && interaction.TargetObject == gameObject)
        {
            // try to add item to this storage
            Inventory.ServerTransfer(interaction.FromSlot,
                                     itemStorage.GetBestSlotFor(interaction.UsedObject));
        }
        else
        {
            // player can observe this storage
            itemStorage.ServerAddObserverPlayer(interaction.Performer);
            ObserveInteractableStorageMessage.Send(interaction.Performer, this, true);

            // if we are observing a storage not in our inventory (such as another player's top
            // level inventory or a storage within their inventory, or a box/backpack sitting on the ground), we must stop observing when it
            // becomes unobservable for whatever reason (such as the owner becoming unobservable)
            var rootStorage = itemStorage.GetRootStorage();
            if (interaction.Performer != rootStorage.gameObject)
            {
                // stop observing when it becomes unobservable for whatever reason
                var relationship = ObserveStorageRelationship.Observe(this,
                                                                      interaction.Performer.GetComponent <RegisterPlayer>(),
                                                                      PlayerScript.interactionDistance, ServerOnObservationEnded);
                SpatialRelationship.ServerActivate(relationship);
            }
        }
    }
Esempio n. 5
0
    protected override void ServerPerformInteraction(MouseDrop drop)
    {
        var objectBehaviour = drop.DroppedObject.GetComponent <ObjectBehaviour>();

        if (objectBehaviour)
        {
            IsClosed = true;
            StorePlayer(objectBehaviour);
            ChangeSprite();
        }
    }
Esempio n. 6
0
 private static RequestInteractMessage CreateMouseDropMessage(MouseDrop mouseDrop, GameObject processorObject,
                                                              short typeId)
 {
     return(new RequestInteractMessage()
     {
         UsedObject = mouseDrop.UsedObject.GetComponent <NetworkIdentity>().netId,
         TargetObject = mouseDrop.TargetObject.GetComponent <NetworkIdentity>().netId,
         ProcessorObject = processorObject.GetComponent <NetworkIdentity>().netId,
         InteractionTypeID = typeId
     });
 }
Esempio n. 7
0
    /// <summary>
    /// For most cases you should use InteractionMessageUtils.SendRequest() instead of this.
    ///
    /// Sends a request to the server to validate + perform the interaction.
    /// </summary>
    /// <param name="mouseDrop">info on the interaction being performed. Each object involved in the interaction
    /// must have a networkidentity.</param>
    /// <param name="processorObject">object who has a component implementing IInteractionProcessor<MouseDrop> which
    /// will process the interaction on the server-side. This object must have a NetworkIdentity and there must only be one instance
    /// of this component on the object. For organization, we suggest that the component which is sending this message
    /// should be on the processorObject, as such this parameter should almost always be passed using "this.gameObject", and
    /// should almost always be either a component on the target object or a component on the used object</param>
    public static void Send(MouseDrop mouseDrop, GameObject processorObject)
    {
        var msg = new RequestMouseDropMessage
        {
            TargetObject    = mouseDrop.TargetObject.GetComponent <NetworkIdentity>().netId,
            ProcessorObject = processorObject.GetComponent <NetworkIdentity>().netId,
            UsedObject      = mouseDrop.UsedObject.GetComponent <NetworkIdentity>().netId
        };

        msg.Send();
    }
Esempio n. 8
0
 public bool WillInteract(MouseDrop interaction, NetworkSide side)
 {
     if (DefaultWillInteract.Default(interaction, side) == false)
     {
         return(false);
     }
     if (interaction.TargetObject.TryGetComponent <StationBouncedRadio>(out var _))
     {
         return(true);
     }
     return(false);
 }
Esempio n. 9
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;
            }
        }
    }
Esempio n. 10
0
    private void OnDragEnd()
    {
        UIManager.IsMouseInteractionDisabled = false;
        Destroy(shadowObject);
        shadowObject = null;
        if (lightingSystem.enabled && !lightingSystem.IsScreenPointVisible(CommonInput.mousePosition))
        {
            //do nothing, the point is not visible.
            return;
        }
        //check what we dropped on, which may or may not have mousedrop interaction components
        //can only drop on things that have a RegisterTile
        var dropTargets =
            MouseUtils.GetOrderedObjectsUnderMouse(dropLayers, go => go.GetComponent <RegisterTile>() != null)
            //get the root gameobject of the dropped-on sprite renderer
            .Select(sr => sr.GetComponentInParent <RegisterTile>().gameObject)
            //only want distinct game objects even if we hit multiple renderers on one object.
            .Distinct();

        //go through the stack of objects and call any drop components we find
        foreach (GameObject dropTarget in dropTargets)
        {
            MouseDrop info = new MouseDrop(PlayerManager.LocalPlayer, gameObject, dropTarget.gameObject);
            //call this object's mousedrop interaction methods if it has any, for each object we are dropping on
            foreach (IInteractable <MouseDrop> mouseDrop in mouseDrops)
            {
                var result = mouseDrop.Interact(info);
                if (result.SomethingHappened)
                {
                    //we're done checking, something happened
                    return;
                }
            }

            //call the mousedrop interaction methods on the dropped-on object if it has any
            foreach (IInteractable <MouseDrop> mouseDropTarget in dropTarget.GetComponents <IInteractable <MouseDrop> >())
            {
                var result = mouseDropTarget.Interact(info);
                if (result.SomethingHappened)
                {
                    //something happened, done checking
                    return;
                }
            }
        }
    }
Esempio n. 11
0
    private void OnDragEnd()
    {
        UIManager.IsMouseInteractionDisabled = false;
        Destroy(shadowObject);
        shadowObject = null;
        if (lightingSystem.enabled && !lightingSystem.IsScreenPointVisible(CommonInput.mousePosition))
        {
            //do nothing, the point is not visible.
            return;
        }
        //check what we dropped on, which may or may not have mousedrop interaction components
        //can only drop on things that have a RegisterTile
        var dropTargets =
            MouseUtils.GetOrderedObjectsUnderMouse(dropLayers);

        //go through the stack of objects and call any drop components we find
        foreach (GameObject dropTarget in dropTargets)
        {
            MouseDrop info = MouseDrop.ByLocalPlayer(gameObject, dropTarget.gameObject);
            //call this object's mousedrop interaction methods if it has any, for each object we are dropping on
            foreach (IInteractable <MouseDrop> mouseDrop in mouseDrops)
            {
                var interacted = mouseDrop.Interact(info);
                if (interacted)
                {
                    //we're done checking, something happened
                    return;
                }
            }

            //call the mousedrop interaction methods on the dropped-on object if it has any
            foreach (IInteractable <MouseDrop> mouseDropTarget in dropTarget.GetComponents <IInteractable <MouseDrop> >()
                     .Where(mb => mb != null && (mb as MonoBehaviour).enabled))
            {
                var interacted = mouseDropTarget.Interact(info);
                if (interacted)
                {
                    //something happened, done checking
                    return;
                }
            }
        }
    }
Esempio n. 12
0
        public void StopDrag()
        {
            if (!DropInteracted && DraggedItem != null)
            {
                var mouseDrops = DraggedItem.GetComponents <IBaseInteractable <MouseDrop> >();
                // check for MouseDrop interactions in the world if we didn't drop on a UI slot
                // check what we dropped on, which may or may not have mousedrop interaction components
                var dropTargets =
                    MouseUtils.GetOrderedObjectsUnderMouse();

                // go through the stack of objects and call any drop components we find
                foreach (GameObject dropTarget in dropTargets)
                {
                    MouseDrop info = MouseDrop.ByLocalPlayer(DraggedItem, dropTarget.gameObject);
                    // call this object's mousedrop interaction methods if it has any, for each object we are dropping on
                    if (InteractionUtils.ClientCheckAndTrigger(mouseDrops, info) != null)
                    {
                        break;
                    }
                    var targetComps = dropTarget.GetComponents <IBaseInteractable <MouseDrop> >()
                                      .Where(mb => mb != null && (mb as MonoBehaviour).enabled);
                    if (InteractionUtils.ClientCheckAndTrigger(targetComps, info) != null)
                    {
                        break;
                    }
                }
            }
            DropInteracted    = false;
            isDragging        = false;
            dragDummy.enabled = false;
            if (FromSlotCache != null)
            {
                if (FromSlotCache.Item != null)
                {
                    FromSlotCache.RefreshImage();
                }
            }


            FromSlotCache = null;
            DraggedItem   = null;
            ResetInteractable();
        }
Esempio n. 13
0
 public void ServerPerformInteraction(MouseDrop interaction)
 {
     if (interaction.IsFromInventory && interaction.TargetObject == gameObject)
     {
         //try to add item to this storage
         Inventory.ServerTransfer(interaction.FromSlot,
                                  itemStorage.GetBestSlotFor(interaction.UsedObject));
     }
     else
     {
         //player can observe this storage
         itemStorage.ServerAddObserverPlayer(interaction.Performer);
         ObserveInteractableStorageMessage.Send(interaction.Performer, this, true);
         if (!interaction.IsFromInventory)
         {
             SpatialRelationship.ServerActivate(RangeRelationship.Between(interaction.Performer, interaction.UsedObject,
                                                                          PlayerScript.interactionDistance, ServerOnRelationshipEnded));
         }
     }
 }
Esempio n. 14
0
 public bool WillInteract(MouseDrop interaction, NetworkSide side)
 {
     if (!DefaultWillInteract.Default(interaction, side))
     {
         return(false);
     }
     //can only drag and drop the object to ourselves,
     //or from our inventory to this object
     if (interaction.IsFromInventory && interaction.TargetObject == gameObject)
     {
         //trying to add an item from inventory slot to this storage sitting in the world
         return(Validations.CanPutItemToStorage(interaction.Performer.GetComponent <PlayerScript>(),
                                                itemStorage, interaction.DroppedObject.GetComponent <Pickupable>(), side, examineRecipient: interaction.Performer));
     }
     else
     {
         //trying to view this storage, can only drop on ourselves to view it
         return(interaction.Performer == interaction.TargetObject);
     }
 }
Esempio n. 15
0
    public bool WillInteract(MouseDrop interaction, NetworkSide side)
    {
        if (allowedToInteract == false)
        {
            return(false);
        }
        if (DefaultWillInteract.Default(interaction, side) == false)
        {
            return(false);
        }
        // can't drag / view ourselves
        if (interaction.Performer == interaction.DroppedObject)
        {
            return(false);
        }
        // can only drag and drop the object to ourselves,
        // or from our inventory to this object
        if (interaction.IsFromInventory && interaction.TargetObject == gameObject)
        {
            // trying to add an item from inventory slot to this storage sitting in the world
            return(Validations.CanPutItemToStorage(interaction.Performer.GetComponent <PlayerScript>(),
                                                   itemStorage, interaction.DroppedObject.GetComponent <Pickupable>(), side,
                                                   examineRecipient: interaction.Performer));
        }
        else
        {
            // trying to view this storage, can only drop on ourselves to view it
            if (interaction.Performer != interaction.TargetObject)
            {
                return(false);
            }
            // if we're dragging another player to us, it's only allowed if the other player is downed
            if (Validations.HasComponent <PlayerScript>(interaction.DroppedObject))
            {
                // dragging a player, can only do this if they are down / dead
                return(Validations.IsStrippable(interaction.DroppedObject, side));
            }

            return(true);
        }
    }
Esempio n. 16
0
 protected override bool WillInteract(MouseDrop interaction, NetworkSide side)
 {
     if (side == NetworkSide.Server && IsClosed)
     {
         return(false);
     }
     if (!Validations.CanInteract(interaction.Performer, side))
     {
         return(false);
     }
     if (!Validations.IsAdjacent(interaction.Performer, interaction.DroppedObject))
     {
         return(false);
     }
     if (!Validations.IsAdjacent(interaction.Performer, gameObject))
     {
         return(false);
     }
     if (interaction.Performer == interaction.DroppedObject)
     {
         return(false);
     }
     return(true);
 }
Esempio n. 17
0
 public bool WillInteract(MouseDrop interaction, NetworkSide side)
 {
     if (closet.IsOpen == false)
     {
         return(false);
     }
     if (!Validations.CanInteract(interaction.PerformerPlayerScript, side))
     {
         return(false);
     }
     if (!Validations.IsAdjacent(interaction.Performer, interaction.DroppedObject))
     {
         return(false);
     }
     if (!Validations.IsAdjacent(interaction.Performer, gameObject))
     {
         return(false);
     }
     if (interaction.Performer == interaction.DroppedObject)
     {
         return(false);
     }
     return(true);
 }
Esempio n. 18
0
 public ValidationResult Validate(MouseDrop toValidate, NetworkSide side)
 {
     return(toValidate.UsedObject.GetComponent <T>() != null ?
            ValidationResult.SUCCESS :
            ValidationResult.FAIL);
 }
Esempio n. 19
0
 /// <summary>
 /// Server:
 /// Allows player to open / close bags in reach using alt-click
 /// </summary>
 public void ServerPerformInteraction(HandApply interaction)
 {
     // Reusing mouse drop logic for efficiency
     ServerPerformInteraction(MouseDrop.ByClient(interaction.Performer, interaction.TargetObject, interaction.Performer, interaction.Intent));
 }
    public override IEnumerator Process()
    {
        var performer = SentByPlayer.GameObject;

        if (InteractionType == typeof(PositionalHandApply))
        {
            //look up item in active hand slot
            var clientPNA  = SentByPlayer.Script.playerNetworkActions;
            var usedSlot   = HandSlot.ForName(clientPNA.activeHand);
            var usedObject = clientPNA.Inventory[usedSlot.equipSlot].Item;
            yield return(WaitFor(TargetObject, ProcessorObject));

            var targetObj    = NetworkObjects[0];
            var processorObj = NetworkObjects[1];
            var interaction  = PositionalHandApply.ByClient(performer, usedObject, targetObj, TargetVector, usedSlot);
            ProcessInteraction(interaction, processorObj);
        }
        else if (InteractionType == typeof(HandApply))
        {
            var clientPNA  = SentByPlayer.Script.playerNetworkActions;
            var usedSlot   = HandSlot.ForName(clientPNA.activeHand);
            var usedObject = clientPNA.Inventory[usedSlot.equipSlot].Item;
            yield return(WaitFor(TargetObject, ProcessorObject));

            var targetObj    = NetworkObjects[0];
            var processorObj = NetworkObjects[1];
            var performerObj = SentByPlayer.GameObject;
            var interaction  = HandApply.ByClient(performer, usedObject, targetObj, TargetBodyPart, usedSlot);
            ProcessInteraction(interaction, processorObj);
        }
        else if (InteractionType == typeof(AimApply))
        {
            var clientPNA  = SentByPlayer.Script.playerNetworkActions;
            var usedSlot   = HandSlot.ForName(clientPNA.activeHand);
            var usedObject = clientPNA.Inventory[usedSlot.equipSlot].Item;
            yield return(WaitFor(ProcessorObject));

            var processorObj = NetworkObject;
            var performerObj = SentByPlayer.GameObject;
            var interaction  = AimApply.ByClient(performer, TargetVector, usedObject, usedSlot, MouseButtonState);
            ProcessInteraction(interaction, processorObj);
        }
        else if (InteractionType == typeof(MouseDrop))
        {
            yield return(WaitFor(UsedObject, TargetObject, ProcessorObject));

            var usedObj      = NetworkObjects[0];
            var targetObj    = NetworkObjects[1];
            var processorObj = NetworkObjects[2];
            var performerObj = SentByPlayer.GameObject;
            var interaction  = MouseDrop.ByClient(performer, usedObj, targetObj);
            ProcessInteraction(interaction, processorObj);
        }
        else if (InteractionType == typeof(HandActivate))
        {
            yield return(WaitFor(ProcessorObject));

            var processorObj = NetworkObject;
            var performerObj = SentByPlayer.GameObject;
            //look up item in active hand slot
            var clientPNA       = SentByPlayer.Script.playerNetworkActions;
            var handSlot        = HandSlot.ForName(clientPNA.activeHand);
            var activatedObject = clientPNA.Inventory[handSlot.equipSlot].Item;
            var interaction     = HandActivate.ByClient(performer, activatedObject, handSlot);
            ProcessInteraction(interaction, processorObj);
        }
        else if (InteractionType == typeof(InventoryApply))
        {
            yield return(WaitFor(ProcessorObject));

            var processorObj = NetworkObject;
            var performerObj = SentByPlayer.GameObject;
            var pna          = SentByPlayer.Script.playerNetworkActions;
            var handSlot     = HandSlot.ForName(pna.activeHand);
            var handObject   = pna.Inventory[handSlot.equipSlot].Item;
            var interaction  = InventoryApply.ByClient(performer, pna.GetInventorySlot(processorObj), handObject, handSlot);
            ProcessInteraction(interaction, processorObj);
        }
    }
    public override void Process()
    {
        var performer = SentByPlayer.GameObject;

        if (SentByPlayer == null || SentByPlayer.Script == null || SentByPlayer.Script.ItemStorage == null)
        {
            return;
        }



        if (InteractionType == typeof(PositionalHandApply))
        {
            //look up item in active hand slot
            var clientStorage = SentByPlayer.Script.ItemStorage;
            var usedSlot      = clientStorage.GetActiveHandSlot();
            var usedObject    = clientStorage.GetActiveHandSlot().ItemObject;
            LoadMultipleObjects(new uint[] {
                TargetObject, ProcessorObject
            });
            var targetObj    = NetworkObjects[0];
            var processorObj = NetworkObjects[1];
            var interaction  = PositionalHandApply.ByClient(performer, usedObject, targetObj, TargetVector, usedSlot, Intent, TargetBodyPart);
            ProcessInteraction(interaction, processorObj);
        }
        else if (InteractionType == typeof(HandApply))
        {
            var clientStorage = SentByPlayer.Script.ItemStorage;
            var usedSlot      = clientStorage.GetActiveHandSlot();
            var usedObject    = clientStorage.GetActiveHandSlot().ItemObject;
            LoadMultipleObjects(new uint[] {
                TargetObject, ProcessorObject
            });
            var targetObj    = NetworkObjects[0];
            var processorObj = NetworkObjects[1];
            var interaction  = HandApply.ByClient(performer, usedObject, targetObj, TargetBodyPart, usedSlot, Intent, IsAltUsed);
            ProcessInteraction(interaction, processorObj);
        }
        else if (InteractionType == typeof(AimApply))
        {
            var clientStorage = SentByPlayer.Script.ItemStorage;
            var usedSlot      = clientStorage.GetActiveHandSlot();
            var usedObject    = clientStorage.GetActiveHandSlot().ItemObject;
            LoadNetworkObject(ProcessorObject);
            var processorObj = NetworkObject;
            var interaction  = AimApply.ByClient(performer, TargetVector, usedObject, usedSlot, MouseButtonState, Intent);
            ProcessInteraction(interaction, processorObj);
        }
        else if (InteractionType == typeof(MouseDrop))
        {
            LoadMultipleObjects(new uint[] { UsedObject,
                                             TargetObject, ProcessorObject });
            var usedObj      = NetworkObjects[0];
            var targetObj    = NetworkObjects[1];
            var processorObj = NetworkObjects[2];
            var interaction  = MouseDrop.ByClient(performer, usedObj, targetObj, Intent);
            ProcessInteraction(interaction, processorObj);
        }
        else if (InteractionType == typeof(HandActivate))
        {
            LoadNetworkObject(ProcessorObject);

            var processorObj = NetworkObject;
            var performerObj = SentByPlayer.GameObject;
            //look up item in active hand slot
            var clientStorage = SentByPlayer.Script.ItemStorage;
            var usedSlot      = clientStorage.GetActiveHandSlot();
            var usedObject    = clientStorage.GetActiveHandSlot().ItemObject;
            var interaction   = HandActivate.ByClient(performer, usedObject, usedSlot, Intent);
            ProcessInteraction(interaction, processorObj);
        }
        else if (InteractionType == typeof(InventoryApply))
        {
            LoadMultipleObjects(new uint[] { ProcessorObject, UsedObject,
                                             Storage });
            var processorObj = NetworkObjects[0];
            var usedObj      = NetworkObjects[1];
            var storageObj   = NetworkObjects[2];

            ItemSlot targetSlot = null;
            if (SlotIndex == -1)
            {
                targetSlot = ItemSlot.GetNamed(storageObj.GetComponent <ItemStorage>(), NamedSlot);
            }
            else
            {
                targetSlot = ItemSlot.GetIndexed(storageObj.GetComponent <ItemStorage>(), SlotIndex);
            }

            //if used object is null, then empty hand was used
            ItemSlot fromSlot = null;
            if (usedObj == null)
            {
                fromSlot = SentByPlayer.Script.ItemStorage.GetActiveHandSlot();
            }
            else
            {
                fromSlot = usedObj.GetComponent <Pickupable>().ItemSlot;
            }
            var interaction = InventoryApply.ByClient(performer, targetSlot, fromSlot, Intent, IsAltUsed);
            ProcessInteraction(interaction, processorObj);
        }
        else if (InteractionType == typeof(TileApply))
        {
            var clientStorage = SentByPlayer.Script.ItemStorage;
            var usedSlot      = clientStorage.GetActiveHandSlot();
            var usedObject    = clientStorage.GetActiveHandSlot().ItemObject;
            LoadNetworkObject(ProcessorObject);
            var processorObj = NetworkObject;
            processorObj.GetComponent <InteractableTiles>().ServerProcessInteraction(TileInteractionIndex,
                                                                                     SentByPlayer.GameObject, TargetVector, processorObj, usedSlot, usedObject, Intent, TileApply.ApplyType.HandApply);
        }
        else if (InteractionType == typeof(TileMouseDrop))
        {
            LoadMultipleObjects(new uint[] { UsedObject,
                                             ProcessorObject });

            var usedObj      = NetworkObjects[0];
            var processorObj = NetworkObjects[1];
            processorObj.GetComponent <InteractableTiles>().ServerProcessInteraction(TileInteractionIndex,
                                                                                     SentByPlayer.GameObject, TargetVector, processorObj, null, usedObj, Intent, TileApply.ApplyType.MouseDrop);
        }
    }
    public override IEnumerator Process()
    {
        var performer = SentByPlayer.GameObject;

        if (InteractionType == typeof(PositionalHandApply))
        {
            //look up item in active hand slot
            var clientStorage = SentByPlayer.Script.ItemStorage;
            var usedSlot      = clientStorage.GetActiveHandSlot();
            var usedObject    = clientStorage.GetActiveHandSlot().ItemObject;
            yield return(WaitFor(TargetObject, ProcessorObject));

            var targetObj    = NetworkObjects[0];
            var processorObj = NetworkObjects[1];
            var interaction  = PositionalHandApply.ByClient(performer, usedObject, targetObj, TargetVector, usedSlot);
            ProcessInteraction(interaction, processorObj);
        }
        else if (InteractionType == typeof(HandApply))
        {
            var clientStorage = SentByPlayer.Script.ItemStorage;
            var usedSlot      = clientStorage.GetActiveHandSlot();
            var usedObject    = clientStorage.GetActiveHandSlot().ItemObject;
            yield return(WaitFor(TargetObject, ProcessorObject));

            var targetObj    = NetworkObjects[0];
            var processorObj = NetworkObjects[1];
            var interaction  = HandApply.ByClient(performer, usedObject, targetObj, TargetBodyPart, usedSlot);
            ProcessInteraction(interaction, processorObj);
        }
        else if (InteractionType == typeof(AimApply))
        {
            var clientStorage = SentByPlayer.Script.ItemStorage;
            var usedSlot      = clientStorage.GetActiveHandSlot();
            var usedObject    = clientStorage.GetActiveHandSlot().ItemObject;
            yield return(WaitFor(ProcessorObject));

            var processorObj = NetworkObject;
            var interaction  = AimApply.ByClient(performer, TargetVector, usedObject, usedSlot, MouseButtonState);
            ProcessInteraction(interaction, processorObj);
        }
        else if (InteractionType == typeof(MouseDrop))
        {
            yield return(WaitFor(UsedObject, TargetObject, ProcessorObject));

            var usedObj      = NetworkObjects[0];
            var targetObj    = NetworkObjects[1];
            var processorObj = NetworkObjects[2];
            var interaction  = MouseDrop.ByClient(performer, usedObj, targetObj);
            ProcessInteraction(interaction, processorObj);
        }
        else if (InteractionType == typeof(HandActivate))
        {
            yield return(WaitFor(ProcessorObject));

            var processorObj = NetworkObject;
            var performerObj = SentByPlayer.GameObject;
            //look up item in active hand slot
            var clientStorage = SentByPlayer.Script.ItemStorage;
            var usedSlot      = clientStorage.GetActiveHandSlot();
            var usedObject    = clientStorage.GetActiveHandSlot().ItemObject;
            var interaction   = HandActivate.ByClient(performer, usedObject, usedSlot);
            ProcessInteraction(interaction, processorObj);
        }
        else if (InteractionType == typeof(InventoryApply))
        {
            yield return(WaitFor(ProcessorObject, UsedObject, Storage));

            var processorObj = NetworkObjects[0];
            var usedObj      = NetworkObjects[1];
            var storageObj   = NetworkObjects[2];

            ItemSlot targetSlot = null;
            if (SlotIndex == -1)
            {
                targetSlot = ItemSlot.GetNamed(storageObj.GetComponent <ItemStorage>(), NamedSlot);
            }
            else
            {
                targetSlot = ItemSlot.GetIndexed(storageObj.GetComponent <ItemStorage>(), SlotIndex);
            }

            //if used object is null, then empty hand was used
            ItemSlot fromSlot = null;
            if (usedObj == null)
            {
                fromSlot = SentByPlayer.Script.ItemStorage.GetActiveHandSlot();
            }
            else
            {
                fromSlot = usedObj.GetComponent <Pickupable>().ItemSlot;
            }
            var interaction = InventoryApply.ByClient(performer, targetSlot, fromSlot);
            ProcessInteraction(interaction, processorObj);
        }
    }
Esempio n. 23
0
 /// <summary>
 /// Default WillInteract logic for MouseDrop
 /// </summary>
 public static bool MouseDrop(MouseDrop interaction, NetworkSide side)
 {
     return(Validations.CanApply(interaction, side));
 }
Esempio n. 24
0
 protected override void ServerPerformInteraction(MouseDrop interaction)
 {
 }
Esempio n. 25
0
 /// <summary>
 /// Validates if the performer is in range and not in crit for a MouseDrop interaction.
 /// </summary>
 /// <param name="toValidate">interaction to validate</param>
 /// <param name="side">side of the network this is being checked on</param>
 /// <param name="allowSoftCrit">whether to allow interaction while in soft crit</param>
 /// <param name="reachRange">range to allow</param>
 /// <returns></returns>
 public static bool CanApply(MouseDrop toValidate, NetworkSide side, bool allowSoftCrit = false, ReachRange reachRange = ReachRange.Standard, bool isPlayerClick = false) =>
 CanApply(toValidate.Performer, toValidate.TargetObject, side, allowSoftCrit, reachRange, isPlayerClick: isPlayerClick);
Esempio n. 26
0
 public void ServerPerformInteraction(MouseDrop drop)
 {
     container.StoreObject(drop.DroppedObject);
     UpdateState();
 }
Esempio n. 27
0
 public ValidationResult Validate(MouseDrop toValidate, NetworkSide side)
 {
     return(ValidateAll(toValidate, side));
 }
Esempio n. 28
0
        public override void Process(NetMessage msg)
        {
            var ComponentType    = msg.ComponentType;
            var InteractionType  = msg.InteractionType;
            var ProcessorObject  = msg.ProcessorObject;
            var Intent           = msg.Intent;
            var TargetObject     = msg.TargetObject;
            var UsedObject       = msg.UsedObject;
            var TargetBodyPart   = msg.TargetBodyPart;
            var TargetVector     = msg.TargetVector;
            var MouseButtonState = msg.MouseButtonState;
            var IsAltUsed        = msg.IsAltUsed;
            var Storage          = msg.Storage;
            var SlotIndex        = msg.SlotIndex;
            var NamedSlot        = msg.NamedSlot;
            var connectionPointA = msg.connectionPointA;
            var connectionPointB = msg.connectionPointB;
            var RequestedOption  = msg.RequestedOption;

            var performer = SentByPlayer.GameObject;

            if (SentByPlayer == null || SentByPlayer.Script == null)
            {
                return;
            }

            if (SentByPlayer.Script.DynamicItemStorage == null)
            {
                if (InteractionType == typeof(AiActivate))
                {
                    LoadMultipleObjects(new uint[] { TargetObject, ProcessorObject });
                    var targetObj    = NetworkObjects[0];
                    var processorObj = NetworkObjects[1];

                    var interaction = new AiActivate(performer, null, targetObj, Intent, msg.ClickTypes);
                    ProcessInteraction(interaction, processorObj, ComponentType);
                }

                return;
            }

            if (InteractionType == typeof(PositionalHandApply))
            {
                //look up item in active hand slot
                var clientStorage = SentByPlayer.Script.DynamicItemStorage;
                var usedSlot      = clientStorage.GetActiveHandSlot();
                var usedObject    = clientStorage.GetActiveHandSlot().ItemObject;
                LoadMultipleObjects(new uint[] {
                    TargetObject, ProcessorObject
                });
                var targetObj    = NetworkObjects[0];
                var processorObj = NetworkObjects[1];
                CheckMatrixSync(ref targetObj);
                CheckMatrixSync(ref processorObj);

                var interaction = PositionalHandApply.ByClient(performer, usedObject, targetObj, TargetVector, usedSlot, Intent, TargetBodyPart);
                ProcessInteraction(interaction, processorObj, ComponentType);
            }
            else if (InteractionType == typeof(HandApply))
            {
                var clientStorage = SentByPlayer.Script.DynamicItemStorage;
                var usedSlot      = clientStorage.GetActiveHandSlot();
                var usedObject    = clientStorage.GetActiveHandSlot()?.ItemObject;
                LoadMultipleObjects(new uint[] {
                    TargetObject, ProcessorObject
                });
                var targetObj    = NetworkObjects[0];
                var processorObj = NetworkObjects[1];
                CheckMatrixSync(ref targetObj);
                CheckMatrixSync(ref processorObj);

                var interaction = HandApply.ByClient(performer, usedObject, targetObj, TargetBodyPart, usedSlot, Intent, IsAltUsed);
                ProcessInteraction(interaction, processorObj, ComponentType);
            }
            else if (InteractionType == typeof(AimApply))
            {
                var clientStorage = SentByPlayer.Script.DynamicItemStorage;
                var usedSlot      = clientStorage.GetActiveHandSlot();
                var usedObject    = clientStorage.GetActiveHandSlot().ItemObject;
                LoadNetworkObject(ProcessorObject);
                var processorObj = NetworkObject;
                CheckMatrixSync(ref processorObj);

                var interaction = AimApply.ByClient(performer, TargetVector, usedObject, usedSlot, MouseButtonState, Intent);
                ProcessInteraction(interaction, processorObj, ComponentType);
            }
            else if (InteractionType == typeof(MouseDrop))
            {
                LoadMultipleObjects(new uint[] { UsedObject,
                                                 TargetObject, ProcessorObject });

                var usedObj      = NetworkObjects[0];
                var targetObj    = NetworkObjects[1];
                var processorObj = NetworkObjects[2];
                CheckMatrixSync(ref targetObj);
                CheckMatrixSync(ref processorObj);

                var interaction = MouseDrop.ByClient(performer, usedObj, targetObj, Intent);
                ProcessInteraction(interaction, processorObj, ComponentType);
            }
            else if (InteractionType == typeof(HandActivate))
            {
                LoadNetworkObject(ProcessorObject);

                var processorObj = NetworkObject;
                CheckMatrixSync(ref processorObj);

                var performerObj = SentByPlayer.GameObject;
                //look up item in active hand slot
                var clientStorage = SentByPlayer.Script.DynamicItemStorage;
                var usedSlot      = clientStorage.GetActiveHandSlot();
                var usedObject    = clientStorage.GetActiveHandSlot().ItemObject;
                var interaction   = HandActivate.ByClient(performer, usedObject, usedSlot, Intent);
                ProcessInteraction(interaction, processorObj, ComponentType);
            }
            else if (InteractionType == typeof(InventoryApply))
            {
                LoadMultipleObjects(new uint[] { ProcessorObject, UsedObject,
                                                 Storage });
                var processorObj = NetworkObjects[0];
                var usedObj      = NetworkObjects[1];
                var storageObj   = NetworkObjects[2];
                CheckMatrixSync(ref processorObj);

                ItemSlot targetSlot = null;
                if (SlotIndex == -1)
                {
                    targetSlot = ItemSlot.GetNamed(storageObj.GetComponents <ItemStorage>()[msg.StorageIndexOnGameObject], NamedSlot);
                }
                else
                {
                    targetSlot = ItemSlot.GetIndexed(storageObj.GetComponents <ItemStorage>()[msg.StorageIndexOnGameObject], SlotIndex);
                }

                //if used object is null, then empty hand was used
                ItemSlot fromSlot = null;
                if (usedObj == null)
                {
                    fromSlot = SentByPlayer.Script.DynamicItemStorage.GetActiveHandSlot();
                }
                else
                {
                    fromSlot = usedObj.GetComponent <Pickupable>().ItemSlot;
                }
                var interaction = InventoryApply.ByClient(performer, targetSlot, fromSlot, Intent, IsAltUsed);
                ProcessInteraction(interaction, processorObj, ComponentType);
            }
            else if (InteractionType == typeof(TileApply))
            {
                var clientStorage = SentByPlayer.Script.DynamicItemStorage;
                var usedSlot      = clientStorage.GetActiveHandSlot();
                var usedObject    = clientStorage.GetActiveHandSlot().ItemObject;
                LoadNetworkObject(ProcessorObject);
                var processorObj = NetworkObject;
                CheckMatrixSync(ref processorObj);

                processorObj.GetComponent <InteractableTiles>().ServerProcessInteraction(SentByPlayer.GameObject,
                                                                                         TargetVector, processorObj, usedSlot, usedObject, Intent,
                                                                                         TileApply.ApplyType.HandApply);
            }
            else if (InteractionType == typeof(TileMouseDrop))
            {
                LoadMultipleObjects(new uint[] { UsedObject,
                                                 ProcessorObject });

                var usedObj      = NetworkObjects[0];
                var processorObj = NetworkObjects[1];
                CheckMatrixSync(ref processorObj);

                processorObj.GetComponent <InteractableTiles>().ServerProcessInteraction(SentByPlayer.GameObject,
                                                                                         TargetVector, processorObj, null, usedObj, Intent,
                                                                                         TileApply.ApplyType.MouseDrop);
            }
            else if (InteractionType == typeof(ConnectionApply))
            {
                //look up item in active hand slot
                var clientStorage = SentByPlayer.Script.DynamicItemStorage;
                var usedSlot      = clientStorage.GetActiveHandSlot();
                var usedObject    = clientStorage.GetActiveHandSlot().ItemObject;
                LoadMultipleObjects(new uint[] {
                    TargetObject, ProcessorObject
                });
                var targetObj    = NetworkObjects[0];
                var processorObj = NetworkObjects[1];
                CheckMatrixSync(ref targetObj);
                CheckMatrixSync(ref processorObj);

                var interaction = ConnectionApply.ByClient(performer, usedObject, targetObj, connectionPointA, connectionPointB, TargetVector, usedSlot, Intent);
                ProcessInteraction(interaction, processorObj, ComponentType);
            }
            else if (InteractionType == typeof(ContextMenuApply))
            {
                LoadMultipleObjects(new uint[] { TargetObject, ProcessorObject });
                var clientStorage = SentByPlayer.Script.DynamicItemStorage;
                var usedObj       = clientStorage.GetActiveHandSlot().ItemObject;
                var targetObj     = NetworkObjects[0];
                var processorObj  = NetworkObjects[1];
                CheckMatrixSync(ref targetObj);
                CheckMatrixSync(ref processorObj);

                var interaction = ContextMenuApply.ByClient(performer, usedObj, targetObj, RequestedOption, Intent);
                ProcessInteraction(interaction, processorObj, ComponentType);
            }
        }