Esempio n. 1
0
 public void NotifyPlayer(NetworkConnection recipient, bool clothItems = false)
 {
     if (!clothItems)
     {
         PlayerCustomisationMessage.SendTo(gameObject, recipient, ThisCharacter);
     }
     else
     {
         for (int i = 0; i < characterSprites.Length; i++)
         {
             var clothItem = characterSprites[i];
             PlayerAppearanceMessage.SendTo(gameObject, i, recipient, clothItem.GameObjectReference, true, true);
         }
     }
 }
Esempio n. 2
0
        public void ServerPerformInteraction(HandActivate interaction)
        {
            ItemSlot hiddenHand = DetermineHiddenHand(interaction);

            if (hiddenHand != null)
            {
                HiddenHandValue hiddenHandSelection = HiddenHandValue.bothHands;

                if (hiddenHand.NamedSlot.GetValueOrDefault(NamedSlot.none) == NamedSlot.leftHand)
                {
                    hiddenHandSelection = HiddenHandValue.leftHand;
                }
                else if (hiddenHand.NamedSlot.GetValueOrDefault(NamedSlot.none) == NamedSlot.rightHand)
                {
                    hiddenHandSelection = HiddenHandValue.rightHand;
                }

                Inventory.ServerDrop(hiddenHand);

                SyncState(isWielded, !isWielded);


                if (isWielded)
                {
                    itemAttributes.ServerHitDamage = damageWielded;
                    itemAttributes.SetSprites(Wielded);
                    Chat.AddExamineMsgFromServer(interaction.Performer, $"You wield {gameObject.ExpensiveName()} grabbing it with both of your hands.");
                    HideHand(hiddenHandSelection, interaction.PerformerPlayerScript);
                }
                else
                {
                    itemAttributes.ServerHitDamage = damageUnwielded;
                    itemAttributes.SetSprites(Unwielded);
                    Chat.AddExamineMsgFromServer(interaction.Performer, $"You unwield {gameObject.ExpensiveName()}.");
                    HideHand(HiddenHandValue.none, interaction.PerformerPlayerScript);
                }

                PlayerAppearanceMessage.SendToAll(interaction.Performer, (int)interaction.HandSlot.NamedSlot.GetValueOrDefault(NamedSlot.none), gameObject);
            }
        }
Esempio n. 3
0
    public virtual void OnInventoryMoveServer(InventoryMove info)
    {
        /*
         * TODO: There is a security issue here which existed even prior to inventory refactor.
         * The issue is that every time a player's top level inventory changes, a message is sent to all other players
         * telling them what object was added / removed from that player's slot. So with a hacked client,
         * it would be easy to see every item change that happens on the server in top level inventory, such as being able
         * to see who is using antag items.
         *
         * Bubbling should help prevent this
         */


        //update appearance depending on the slot that was changed
        if (info.FromPlayer != null &&
            HasClothingItem(info.FromPlayer, info.FromSlot))
        {
            //clear previous slot appearance
            PlayerAppearanceMessage.SendToAll(info.FromPlayer.gameObject,
                                              (int)info.FromSlot.NamedSlot.GetValueOrDefault(NamedSlot.none), null);

            //ask target playerscript to update shown name.
            info.FromPlayer.GetComponent <PlayerScript>().RefreshVisibleName();
        }

        if (info.ToPlayer != null &&
            HasClothingItem(info.ToPlayer, info.ToSlot))
        {
            //change appearance based on new item
            PlayerAppearanceMessage.SendToAll(info.ToPlayer.gameObject,
                                              (int)info.ToSlot.NamedSlot.GetValueOrDefault(NamedSlot.none), info.MovedObject.gameObject);

            //ask target playerscript to update shown name.
            info.ToPlayer.GetComponent <PlayerScript>().RefreshVisibleName();
        }
    }
Esempio n. 4
0
 public void SetReference(int index, GameObject _Item)
 {
     PlayerAppearanceMessage.SendToAll(gameObject, index, _Item);
 }
Esempio n. 5
0
 public void ServerPerformInteraction(HandActivate interaction)
 {
     ToggleState(interaction.Performer.WorldPosServer());
     PlayerAppearanceMessage.SendToAll(interaction.Performer, (int)interaction.HandSlot.NamedSlot.GetValueOrDefault(NamedSlot.none), gameObject);
 }
Esempio n. 6
0
    // Cheap hack until networked character sprites.
    private IEnumerator DelayCharacterSprite(HandActivate interaction)
    {
        yield return(WaitFor.Seconds(1));

        PlayerAppearanceMessage.SendToAll(interaction.Performer, (int)interaction.HandSlot.NamedSlot.GetValueOrDefault(NamedSlot.none), gameObject);
    }