Пример #1
0
    public 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);
        }

        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);
        }
    }
Пример #2
0
    public void ServerPerformInteraction(HandActivate interaction)
    {
        isActivated = !isActivated;         // This runs SyncState, which sets itemAttributes on clients
        var lightColor = GetLightSourceColor(color);

        lightControl.SetColor(lightColor);
        lightControl.Toggle(isActivated);

        if (isActivated)
        {
            SetActivatedAttributes();
            spriteHandler.ChangeSprite((int)color);
            itemAttributes.SetSprites(GetItemSprites(color));
        }
        else
        {
            SetDeactivatedAttributes();
            spriteHandler.ChangeSprite(0);
            itemAttributes.SetSprites(Sprites.Off);
        }

        SoundManager.PlayNetworkedAtPos(
            isActivated ? saberon : saberoff, gameObject.AssumedWorldPosServer());

        PlayerAppearanceMessage.SendToAll(interaction.Performer, (int)interaction.HandSlot.NamedSlot.GetValueOrDefault(NamedSlot.none), gameObject);
    }
Пример #3
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);
            }
        }
Пример #4
0
 public void SetReference(int index, GameObject _Item)
 {
     PlayerAppearanceMessage.SendToAll(gameObject, index, _Item);
 }
Пример #5
0
 public void ServerPerformInteraction(HandActivate interaction)
 {
     ToggleState(interaction.Performer.WorldPosServer());
     PlayerAppearanceMessage.SendToAll(interaction.Performer, (int)interaction.HandSlot.NamedSlot.GetValueOrDefault(NamedSlot.none), gameObject);
 }
Пример #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);
    }