示例#1
0
 public SCP914ActivateEvent(Player user, KnobSetting knobSetting, object[] inputs, Vector intakePos, Vector outputPos)
 {
     this.User        = user;
     this.KnobSetting = knobSetting;
     this.Inputs      = inputs;
     this.IntakePos   = intakePos;
     this.OutputPos   = outputPos;
 }
示例#2
0
 public SCP914ActivateEvent(Player user, KnobSetting knobSetting, List <Player> playerList, List <Item> itemList, Vector intakePos, Vector outputPos)
 {
     this.User         = user;
     this.KnobSetting  = knobSetting;
     this.PlayerInputs = playerList;
     this.ItemInputs   = itemList;
     this.IntakePos    = intakePos;
     this.OutputPos    = outputPos;
 }
示例#3
0
 public PlayerSCP914ChangeKnobEvent(Player player, KnobSetting knobSetting) : base(player)
 {
     this.KnobSetting = knobSetting;
 }
示例#4
0
        /// <summary>
        /// Does a full 914 pass on the user's held item.
        /// </summary>
        /// <param name="collider">Player</param>
        /// <param name="OutputPos">Smod2 Vector on the output of 914</param>
        /// <param name="knobSetting">Current 914 knob setting</param>
        /// <param name="scp914">914</param>
        public void DoHand914(UnityEngine.Collider collider, Vector OutputPos, KnobSetting knobSetting, Scp914 scp914)
        {
            Smod2.API.Player play = new ServerMod2.API.SmodPlayer(collider.gameObject);

            if (play.GetCurrentItem() == null || play.GetCurrentItemIndex() == -1 || play.GetCurrentItem().ItemType == ItemType.USP || stackManager.ContainsWeapon((int)play.GetCurrentItem().ItemType) && knobSetting == KnobSetting.ONE_TO_ONE)
            {
                StackEventHandler.CheckSteamIDItemNum[play.SteamId].TransferItems(collider.gameObject);
                StackEventHandler.CheckSteamIDItemNum[play.SteamId].ApplyTransferedItems(collider.gameObject, true);
                return;
            }
            Smod2.API.ItemType currentItem = play.GetCurrentItem().ItemType;
            int itemIndex = -1;

            Dictionary <int, List <Inventory.SyncItemInfo> > TempGetItemsByItemType = new Dictionary <int, List <Inventory.SyncItemInfo> >();       //This is for seeing a item's index in inventory

            foreach (var item in collider.gameObject.GetComponent <Inventory>().items)
            {
                if (TempGetItemsByItemType.ContainsKey(item.id))
                {
                    TempGetItemsByItemType[item.id].Add(item);
                    if (item.uniq == collider.gameObject.GetComponent <Inventory>().GetItemInHand().uniq)
                    {
                        itemIndex = TempGetItemsByItemType[item.id].IndexOf(item) + 1;
                    }
                }
                else
                {
                    TempGetItemsByItemType.Add(item.id, new List <Inventory.SyncItemInfo> {
                        item
                    });
                    if (item.uniq == collider.gameObject.GetComponent <Inventory>().GetItemInHand().uniq)
                    {
                        itemIndex = TempGetItemsByItemType[item.id].IndexOf(item) + 1;
                    }
                }
            }
            play.GetCurrentItem().Remove();
            int AmountOfItems = -1;

            if (TempGetItemsByItemType[(int)currentItem].Count == itemIndex)
            {
                AmountOfItems = (int)Math.Ceiling(StackEventHandler.CheckSteamIDItemNum[play.SteamId].GetItemAmount((int)currentItem) % (float)stackManager.GetStackSize((int)currentItem));
                if (AmountOfItems == 0)
                {
                    AmountOfItems = stackManager.GetStackSize((int)currentItem);
                }
            }
            else
            {
                AmountOfItems = stackManager.GetStackSize((int)currentItem);
            }

            if (stackManager.GetStackSize((int)currentItem) == 1)
            {
                AmountOfItems = 1;
            }

            StackEventHandler.CheckSteamIDItemNum[play.SteamId].AddItemAmount((int)currentItem, AmountOfItems * -1);

            for (int i = 0; i < AmountOfItems; i++)
            {
                int newitem = GetRandom914ItemByKnob(scp914, (int)currentItem, (int)knobSetting);
                if (newitem != -1 || ConfigOptions.si_914itemstosave.Contains(newitem))
                {
                    if (play.GetInventory().Count == 8)
                    {
                        Smod2.PluginManager.Manager.Server.Map.SpawnItem((ItemType)newitem, OutputPos, new Vector(0, 0, 0));
                    }
                    else
                    {
                        StackEventHandler.CheckSteamIDItemNum[play.SteamId].AddItemAmount(newitem, 1);
                    }
                }
            }

            StackEventHandler.CheckSteamIDItemNum[play.SteamId].TransferItems(collider.gameObject);
            StackEventHandler.CheckSteamIDItemNum[play.SteamId].ApplyTransferedItems(collider.gameObject, true);
        }
示例#5
0
        /// <summary>
        /// Does a pass on every item in the user's inventory
        /// </summary>
        /// <param name="collider">player collider</param>
        /// <param name="OutputPos">smod2 vector of output pos of 914</param>
        /// <param name="knobSetting">current knobsetting of 914</param>
        /// <param name="scp914">scp914</param>
        public void DoInventory914(UnityEngine.Collider collider, Vector OutputPos, KnobSetting knobSetting, Scp914 scp914)
        {
            Smod2.API.Player play = new ServerMod2.API.SmodPlayer(collider.gameObject);
            List <Inventory.SyncItemInfo> TempItems = new List <Inventory.SyncItemInfo>();

            TempItems.AddRange(collider.GetComponent <Inventory>().items);

            Dictionary <int, int> TempListOfItems = new Dictionary <int, int>();

            foreach (KeyValuePair <int, int> TypeAndAmount in StackEventHandler.CheckSteamIDItemNum[play.SteamId].checkItemTypeForNumOfItems)
            {
                TempListOfItems[TypeAndAmount.Key] = TypeAndAmount.Value;
            }
            StackEventHandler.CheckSteamIDItemNum[play.SteamId].ResetToZero();

            foreach (Inventory.SyncItemInfo item in TempItems)
            {
                if (!ConfigOptions.si_914itemstosave.Contains(item.id) && item.id != 30)
                {
                    double ItemAmount;

                    if (TempListOfItems.ContainsKey(item.id) && !stackManager.ContainsWeapon(item.id))
                    {
                        int TempItemAmount = (int)(TempListOfItems[item.id] - Math.Ceiling(TempListOfItems[item.id] / (float)stackManager.GetStackSize(item.id)));
                        if (TempItemAmount >= stackManager.GetStackSize(item.id))
                        {
                            ItemAmount = stackManager.GetStackSize(item.id);
                            TempListOfItems[item.id] -= stackManager.GetStackSize(item.id);
                        }
                        else
                        {
                            ItemAmount = TempListOfItems[item.id];
                            TempListOfItems[item.id] = 0;
                        }
                    }
                    else
                    {
                        ItemAmount = 1;
                    }
                    collider.GetComponent <Inventory>().items.Remove(item);
                    for (int i = 0; i < (int)ItemAmount; i++)
                    {
                        int newitem = GetRandom914ItemByKnob(scp914, item.id, (int)knobSetting);
                        if (newitem != -1)
                        {
                            if (play.GetInventory().Count == 8)
                            {
                                Smod2.PluginManager.Manager.Server.Map.SpawnItem((ItemType)newitem, OutputPos, new Vector(0, 0, 0));
                            }
                            else
                            {
                                StackEventHandler.CheckSteamIDItemNum[play.SteamId].AddItemAmount(newitem, 1);
                            }
                        }
                    }
                }
            }

            StackEventHandler.CheckSteamIDItemNum[play.SteamId].TransferItems(collider.gameObject);
            StackEventHandler.CheckSteamIDItemNum[play.SteamId].ApplyTransferedItems(collider.gameObject);
        }