예제 #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);
            }
        }
    }
        public void Examine(GameObject sentByPlayer)
        {
            // if distance is too big or is self-examination, send normal examine message
            if (Vector3.Distance(sentByPlayer.WorldPosServer(), gameObject.WorldPosServer()) >= maxInteractionDistance ||
                sentByPlayer == gameObject)
            {
                Chat.AddExamineMsg(sentByPlayer,
                                   $"This is <b>{VisibleName}</b>.\n" +
                                   $"{Equipment.Examine()}" +
                                   $"<color={LILAC_COLOR}>{Health.GetExamineText()}</color>");
                return;
            }

            // start itemslot observation
            interactableStorage.ItemStorage.ServerAddObserverPlayer(sentByPlayer);
            // send message to enable examination window
            PlayerExaminationMessage.Send(sentByPlayer, this, true);

            //stop observing when target player is too far away
            var relationship = RangeRelationship.Between(
                sentByPlayer,
                gameObject,
                maxInteractionDistance,
                ServerOnObservationEnded
                );

            SpatialRelationship.ServerActivate(relationship);
        }
예제 #3
0
        public void Examine(GameObject sentByPlayer)
        {
            if (sentByPlayer.TryGetComponent <PlayerScript>(out var sentByPlayerScript) == false)
            {
                return;
            }

            if (sentByPlayerScript.PlayerState != PlayerScript.PlayerStates.Ghost)
            {
                // if distance is too big or is self-examination, send normal examine message
                if (Vector3.Distance(sentByPlayer.WorldPosServer(), gameObject.WorldPosServer()) >= maxInteractionDistance || sentByPlayer == gameObject)
                {
                    BasicExamine(sentByPlayer);
                    return;
                }
            }

            //If youre not normal or ghost then only allow basic examination
            //TODO maybe in future have this be a separate setting for each player type?
            if (sentByPlayerScript.PlayerState != PlayerScript.PlayerStates.Normal &&
                sentByPlayerScript.PlayerState != PlayerScript.PlayerStates.Ghost)
            {
                BasicExamine(sentByPlayer);
                return;
            }

            // start itemslot observation
            this.GetComponent <DynamicItemStorage>().ServerAddObserverPlayer(sentByPlayer);
            // send message to enable examination window
            PlayerExaminationMessage.Send(sentByPlayer, this, true);

            //Allow ghosts to keep the screen open even if player moves away
            if (sentByPlayerScript.PlayerState == PlayerScript.PlayerStates.Ghost)
            {
                return;
            }

            //stop observing when target player is too far away
            var relationship = RangeRelationship.Between(
                sentByPlayer,
                gameObject,
                maxInteractionDistance,
                ServerOnObservationEnded
                );

            SpatialRelationship.ServerActivate(relationship);
        }
예제 #4
0
        public void Examine(GameObject SentByPlayer)
        {
            // if player is not inspecting self and distance is not too big
            if (SentByPlayer != gameObject && Vector3.Distance(SentByPlayer.WorldPosServer(), gameObject.WorldPosServer()) <= maxInteractionDistance)
            {
                // start itemslot observation
                interactableStorage.ItemStorage.ServerAddObserverPlayer(SentByPlayer);
                // send message to enable examination window
                PlayerExaminationMessage.Send(SentByPlayer, this, true);

                //stop observing when target player is too far away
                var relationship = RangeRelationship.Between(
                    SentByPlayer,
                    gameObject,
                    maxInteractionDistance,
                    ServerOnObservationEndedd
                    );
                SpatialRelationship.ServerActivate(relationship);
            }
        }
예제 #5
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));
         }
     }
 }