示例#1
0
        public async void ApplyTransferedItems(UnityEngine.GameObject gameObject, bool clear = false)
        {
            await Task.Delay(250);

            Smod2.API.Player player = new ServerMod2.API.SmodPlayer(gameObject);
            if (clear)
            {
                foreach (Smod2.API.Item item in player.GetInventory())
                {
                    item.Remove();
                }
            }

            StackEventHandler.CheckSteamIDItemNum[player.SteamId].ResetToZero();

            if (Escape)
            {
                player.SetAmmo(AmmoType.DROPPED_9, StackEventHandler.CheckSteamIDItemNum[player.SteamId].ammo9 + player.GetAmmo(AmmoType.DROPPED_9));
                player.SetAmmo(AmmoType.DROPPED_7, StackEventHandler.CheckSteamIDItemNum[player.SteamId].ammo7 + player.GetAmmo(AmmoType.DROPPED_7));
                player.SetAmmo(AmmoType.DROPPED_5, StackEventHandler.CheckSteamIDItemNum[player.SteamId].ammo5 + player.GetAmmo(AmmoType.DROPPED_5));
            }

            foreach (Smod2.API.ItemType item in (Smod2.API.ItemType[])Enum.GetValues(typeof(Smod2.API.ItemType)))
            {
                if (StackEventHandler.CheckSteamIDItemNum[player.SteamId].TempItemList.TryGetValue((int)item, out int value))
                {
                    for (int i = 0; i < value; i++)
                    {
                        player.GiveItem(item);
                    }
                }
            }
            StackEventHandler.CheckSteamIDItemNum[player.SteamId].TempItemList.Clear();
        }
示例#2
0
        public void OnSCP914Activate(SCP914ActivateEvent ev)
        {
            if (!SI_Config.si_914enable)
            {
                return;
            }
            Scp914 scp914 = GameObject.FindObjectOfType <Scp914>();

            if (scp914 == null)
            {
                plugin.Error("914 cannot be found.");
                return;
            }
            foreach (UnityEngine.Collider collider in ev.Inputs)
            {
                if (collider.GetComponent <Inventory>() != null)
                {
                    Smod2.API.Player play = new ServerMod2.API.SmodPlayer(collider.gameObject);

                    if (SI_Config.si_914handorinv == 1)                     // Don't know if passing the collider will work the way I want it to work so I'm just gonna pray to the unity gods for a bug free experience.
                    {
                        _914Manager.DoHand914(collider, ev.OutputPos, ev.KnobSetting, scp914);
                    }
                    else if (SI_Config.si_914handorinv == 2)
                    {
                        _914Manager.DoInventory914(collider, ev.OutputPos, ev.KnobSetting, scp914);
                    }
                    else if (SI_Config.si_914handorinv == 0)
                    {
                        CheckSteamIDItemNum[play.SteamId].TransferItems(collider.gameObject);
                        CheckSteamIDItemNum[play.SteamId].ApplyTransferedItems(collider.gameObject, true);
                    }
                }
            }
        }
示例#3
0
        public void OnSCP914Activate(SCP914ActivateEvent ev)
        {
            if (!enabled)
            {
                return;
            }
            object[] inputs       = ev.Inputs;
            Scp914   objectOfType = UnityEngine.Object.FindObjectOfType <Scp914>();

            if ((UnityEngine.Object)objectOfType == (UnityEngine.Object)null)
            {
                this.plugin.Error("Couldnt find SCP-914");
                return;
            }
            //            string[] strArray = new string[5] { "Very Rough", "Rough", "1 to 1", "Fine", "Very Fine" };
            //            for (byte index1 = 0; index1 < objectOfType.recipes.Length; ++index1) //item id
            //            {
            //                this.plugin.Debug("==== Recipe for: " + component.availableItems[index1].label + " ====");
            //                for (byte index2 = 0; index2 < objectOfType.recipes[index1].outputs.Count; ++index2) //knob setting id
            //                {
            //                    foreach(sbyte itm in objectOfType.recipes[index1].outputs[index2].outputs) //output item id
            //                    {
            //                        this.plugin.Debug(strArray[index2] + ": " + (itm == -1 ? "NULL" : component.availableItems[itm].label));
            //                    }
            //                }
            //            }
            foreach (UnityEngine.Collider collider in inputs)
            {
                Pickup component1 = collider.GetComponent <Pickup>();
                if ((UnityEngine.Object)component1 == (UnityEngine.Object)null)
                {
                    NicknameSync          component2 = collider.GetComponent <NicknameSync>();
                    CharacterClassManager component3 = collider.GetComponent <CharacterClassManager>();
                    PlyMovementSync       component4 = collider.GetComponent <PlyMovementSync>();
                    PlayerStats           component5 = collider.GetComponent <PlayerStats>();
                    if ((UnityEngine.Object)component2 != (UnityEngine.Object)null && (UnityEngine.Object)component3 != (UnityEngine.Object)null && ((UnityEngine.Object)component4 != (UnityEngine.Object)null && (UnityEngine.Object)component5 != (UnityEngine.Object)null) && (UnityEngine.Object)collider.gameObject != (UnityEngine.Object)null)
                    {
                        UnityEngine.GameObject    gameObject = collider.gameObject;
                        ServerMod2.API.SmodPlayer player     = new ServerMod2.API.SmodPlayer(gameObject);
                        if (player.TeamRole.Team != Smod2.API.Team.SCP && player.TeamRole.Team != Smod2.API.Team.NONE && player.TeamRole.Team != Smod2.API.Team.SPECTATOR)
                        {
                            if (currentonly)
                            {
                                Smod2.API.Item item = player.GetCurrentItem();
                                doRecipe(item, objectOfType, player, ev.KnobSetting);
                            }
                            else
                            {
                                foreach (Smod2.API.Item item in player.GetInventory())
                                {
                                    doRecipe(item, objectOfType, player, ev.KnobSetting);
                                }
                            }
                        }
                    }
                }
            }
        }
示例#4
0
        static bool Prefix(ServerMod2.API.SmodPlayer __instance)
        {
            NetworkConnection conn = DisableBroadcastOutput.conn.GetValue(__instance) as NetworkConnection;

            if (conn != null)
            {
                PlayerManager.localPlayer.GetComponent <Broadcast>().CallTargetClearElements(conn);
                DisableBroadcastOutput.Debuglog.Invoke(null, new object[] { "Broadcast", "Cleared broadcasts for: " + __instance.Name });
            }
            return(false);
        }
示例#5
0
        static bool Prefix(ServerMod2.API.SmodPlayer __instance, ref uint duration, ref string message, ref bool isMonoSpaced)
        {
            NetworkConnection conn = DisableBroadcastOutput.conn.GetValue(__instance) as NetworkConnection;

            if (conn != null)
            {
                PlayerManager.localPlayer.GetComponent <Broadcast>().CallTargetAddElement(conn, message, duration, isMonoSpaced);
                DisableBroadcastOutput.Debuglog.Invoke(null, new object[] { "Broadcast", "Broadcasted: " + message + " to: " + __instance.Name });
            }
            return(false);
        }
示例#6
0
        public void TransferItems(UnityEngine.GameObject gameObject)
        {
            Smod2.API.Player player = new ServerMod2.API.SmodPlayer(gameObject);

            TempItemList.Clear();

            foreach (KeyValuePair <int, int> keyValuePair in checkItemTypeForNumOfItems)
            {
                TempItemList[keyValuePair.Key] = keyValuePair.Value;
            }

            ammo9 = player.GetAmmo(AmmoType.DROPPED_9);
            ammo7 = player.GetAmmo(AmmoType.DROPPED_7);
            ammo5 = player.GetAmmo(AmmoType.DROPPED_5);

            checkItemTypeForNumOfItems.Clear();
        }
示例#7
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);
        }
示例#8
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);
        }