Esempio n. 1
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. 2
0
 /// <summary>
 /// Gets the top-level ItemStorage containing this slot. I.e. if this
 /// is inside a crate in a backpack, will return the backpack ItemStorage.
 /// </summary>
 /// <returns></returns>
 public ItemStorage GetRootStorage()
 {
     return(itemStorage.GetRootStorage());
 }