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);
        }
Exemplo n.º 2
0
 private void ServerOnObservationEnded(RangeRelationship cancelled)
 {
     // stop observing item storage
     this.GetComponent <DynamicItemStorage>().ServerRemoveObserverPlayer(cancelled.obj1.gameObject);
     // send message to disable examination window
     PlayerExaminationMessage.Send(cancelled.obj1.gameObject, this, false);
 }
Exemplo n.º 3
0
 private void ServerOnObservationEndedd(RangeRelationship cancelled)
 {
     // stop observing item storage
     interactableStorage.ItemStorage.ServerRemoveObserverPlayer(cancelled.obj1.gameObject);
     // send message to disable examination window
     PlayerExaminationMessage.Send(cancelled.obj1.gameObject, this, false);
 }
Exemplo n.º 4
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);
        }
Exemplo n.º 5
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);
            }
        }
Exemplo n.º 6
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));
         }
     }
 }
Exemplo n.º 7
0
 private void ServerOnRelationshipEnded(RangeRelationship cancelled)
 {
     //they can't observe anymore
     itemStorage.ServerRemoveObserverPlayer(cancelled.obj1.gameObject);
     ObserveInteractableStorageMessage.Send(cancelled.obj1.gameObject, this, false);
 }