Exemplo n.º 1
0
        IEnumerator <float> DoInventoryRegeneration(Player player)
        {
            for (;;)
            {
                yield return(Timing.WaitForSeconds(Plugin.Singleton.Config.ItemConfigs.Scp127Cfg.RegenDelay));

                bool hasItem = false;

                for (int i = 0; i < player.Inventory.items.Count; i++)
                {
                    if (CheckItem(player.Inventory.items[i]))
                    {
                        hasItem = true;

                        if (player.Inventory.items[i].durability < ClipSize)
                        {
                            Inventory.SyncItemInfo newInfo = player.Inventory.items[i];
                            newInfo.durability       += Plugin.Singleton.Config.ItemConfigs.Scp127Cfg.RegenAmount;
                            player.Inventory.items[i] = newInfo;
                        }
                    }
                }

                if (!hasItem)
                {
                    yield break;
                }
            }
        }
Exemplo n.º 2
0
        private IEnumerator <float> SpawnPlayer(Player player)
        {
            yield return(Timing.WaitForSeconds(0.1F));

            Timing.WaitUntilDone(_teamHandler.SpawnPlayer(player));

            yield return(Timing.WaitForSeconds(0.1f));

            foreach (var item in _spawnItems)
            {
                player.AddItem(item);
            }
            player.Ammo[(int)AmmoType.Nato9]   = 3000;
            player.Ammo[(int)AmmoType.Nato556] = 3000;
            player.Ammo[(int)AmmoType.Nato762] = 3000;

            //TODO: Attachments blacklist
            var sif = new Inventory.SyncItemInfo
            {
                id         = _roundWeapon,
                durability = _roundWeapon == ItemType.GunLogicer ? 100f : 30f,
                modBarrel  = _attachments[0],
                modOther   = _attachments[1],
                modSight   = _attachments[2]
            };

            player.AddItem(sif);
            player.IsGodModeEnabled = true;
            yield return(Timing.WaitForSeconds(5));

            player.IsGodModeEnabled = false;
        }
Exemplo n.º 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ChangingAttachmentsEventArgs"/> class.
 /// </summary>
 /// <param name="item"><inheritdoc cref="ChangingAttributesEventArgs.OldItem"/></param>
 /// <param name="newSight"><inheritdoc cref="ChangingAttributesEventArgs.NewSight"/></param>
 /// <param name="newBarrel"><inheritdoc cref="ChangingAttributesEventArgs.NewBarrel"/></param>
 /// <param name="newOther"><inheritdoc cref="ChangingAttributesEventArgs.NewOther"/></param>
 /// <param name="isAllowed"><inheritdoc cref="ChangingAttributesEventArgs.IsAllowed"/></param>
 public ChangingAttachmentsEventArgs(Inventory.SyncItemInfo item, SightType newSight, BarrelType newBarrel, OtherType newOther, bool isAllowed = true)
     : base(item, item, isAllowed)
 {
     NewSight  = newSight;
     NewBarrel = newBarrel;
     NewOther  = newOther;
 }
Exemplo n.º 4
0
 public static bool HasLightSource(this ReferenceHub rh)
 {
     if (rh.inventory != null && rh.inventory.curItem == ItemType.Flashlight)
     {
         return(true);
     }
     if (rh.inventory == null || rh.weaponManager == null || !rh.weaponManager.NetworksyncFlash ||
         rh.weaponManager.curWeapon < 0 ||
         rh.weaponManager.curWeapon >= rh.weaponManager.weapons.Length)
     {
         return(false);
     }
     WeaponManager.Weapon   weapon     = rh.weaponManager.weapons[rh.weaponManager.curWeapon];
     Inventory.SyncItemInfo itemInHand = rh.inventory.GetItemInHand();
     if (weapon == null || itemInHand.modOther < 0 || itemInHand.modOther >= weapon.mod_others.Length)
     {
         return(false);
     }
     WeaponManager.Weapon.WeaponMod modOther = weapon.mod_others[itemInHand.modOther];
     if (modOther != null && !string.IsNullOrEmpty(modOther.name) && (modOther.name.ToLower().Contains("flashlight") || modOther.name.Contains("night")))
     {
         return(true);
     }
     return(false);
 }
        private static bool Prefix(Generator079 __instance, GameObject person, PlayerInteract.Generator079Operations command)
        {
            try
            {
                var player    = person.GetPlayer();
                var generator = __instance.GetGenerator();

                switch (command)
                {
                case PlayerInteract.Generator079Operations.Tablet:

                    if (generator.IsTabletConnected || !generator.Open || __instance._localTime <= 0f || Generator079.mainGenerator.forcedOvercharge || !SynapseExtensions.CanHarmScp(player))
                    {
                        return(false);
                    }

                    Inventory component = person.GetComponent <Inventory>();

                    using (SyncList <Inventory.SyncItemInfo> .SyncListEnumerator enumerator = component.items.GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            Inventory.SyncItemInfo syncItemInfo = enumerator.Current;
                            if (syncItemInfo.id == ItemType.WeaponManagerTablet)
                            {
                                bool allow2 = true;
                                var  item   = syncItemInfo.GetSynapseItem();
                                Server.Get.Events.Player.InvokePlayerGeneratorInteractEvent(player, generator, GeneratorInteraction.TabletInjected, ref allow2);
                                Server.Get.Events.Player.InvokePlayerItemUseEvent(player, item, Api.Events.SynapseEventArguments.ItemInteractState.Finalizing, ref allow2);
                                if (!allow2)
                                {
                                    break;
                                }

                                generator.ConnectedTablet = item;
                                break;
                            }
                        }
                    }
                    return(false);

                case PlayerInteract.Generator079Operations.Cancel:
                    if (!generator.IsTabletConnected)
                    {
                        return(false);
                    }

                    bool allow = true;
                    Server.Get.Events.Player.InvokePlayerGeneratorInteractEvent(player, generator, GeneratorInteraction.TabledEjected, ref allow);
                    return(allow);
                }
                return(true);
            }
            catch (Exception e)
            {
                Logger.Get.Error($"Synapse-Event: PlayerGenerator failed!!\n{e}\nStackTrace:\n{e.StackTrace}");
                return(true);
            }
        }
Exemplo n.º 6
0
 public static Inventory.SyncItemInfo GetTranquilizerItem()
 {
     Inventory.SyncItemInfo _tempGun = new Inventory.SyncItemInfo {
         modBarrel  = Plugin.Instance.Config.silencerRequired ? 1 : 0,
         durability = Plugin.Instance.Config.uspIsTranquilizer ? 18 : 12,
         id         = Plugin.Instance.Config.uspIsTranquilizer ? ItemType.GunUSP : ItemType.GunCOM15
     };
     // This is still todo
     return(_tempGun);
 }
Exemplo n.º 7
0
        public static bool Prefix(Generator079 __instance, GameObject person, PlayerInteract.Generator079Operations command)
        {
            try
            {
                switch (command)
                {
                case PlayerInteract.Generator079Operations.Tablet:

                    if (__instance.isTabletConnected || !__instance.isDoorOpen || __instance._localTime <= 0f || Generator079.mainGenerator.forcedOvercharge)
                    {
                        return(false);
                    }
                    Inventory component = person.GetComponent <Inventory>();
                    using (SyncList <Inventory.SyncItemInfo> .SyncListEnumerator enumerator = component.items.GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            Inventory.SyncItemInfo syncItemInfo = enumerator.Current;
                            if (syncItemInfo.id == ItemType.WeaponManagerTablet)
                            {
                                var allow2 = true;
                                Events.InvokeGeneratorInserted(person.GetPlayer(), __instance, ref allow2);
                                if (!allow2)
                                {
                                    break;
                                }

                                component.items.Remove(syncItemInfo);
                                __instance.NetworkisTabletConnected = true;
                                break;
                            }
                        }
                    }
                    return(false);

                case PlayerInteract.Generator079Operations.Cancel:
                    if (!__instance.isTabletConnected)
                    {
                        return(false);
                    }

                    var allow = true;
                    Events.InvokeGeneratorEjected(person.GetPlayer(), __instance, ref allow);
                    return(allow);
                }
                return(true);
            }
            catch (Exception e)
            {
                Log.Error($"GeneratorTablet Event Error: {e}");
                return(true);
            }
        }
Exemplo n.º 8
0
 public LabItem(GameObject pickup)
 {
     go    = pickup;
     _item = new Inventory.SyncItemInfo()
     {
         id         = pickup.GetComponent <Pickup>().info.itemId,
         durability = pickup.GetComponent <Pickup>().info.durability,
         modSight   = pickup.GetComponent <Pickup>().info.weaponMods[0],
         modBarrel  = pickup.GetComponent <Pickup>().info.weaponMods[1],
         modOther   = pickup.GetComponent <Pickup>().info.weaponMods[2]
     };
 }
Exemplo n.º 9
0
        private static void Prefix(Inventory __instance, int i)
        {
            try
            {
                if (__instance.itemUniq == i)
                {
                    return;
                }

                int oldItemIndex = __instance.GetItemIndex();

                if (oldItemIndex == -1 && i == -1)
                {
                    return;
                }

                Inventory.SyncItemInfo oldItem = oldItemIndex == -1
                    ? new Inventory.SyncItemInfo()
                {
                    id = ItemType.None
                }
                    : __instance.GetItemInHand();
                Inventory.SyncItemInfo newItem = new Inventory.SyncItemInfo()
                {
                    id = ItemType.None
                };

                foreach (Inventory.SyncItemInfo item in __instance.items)
                {
                    if (item.uniq == i)
                    {
                        newItem = item;
                    }
                }

                var ev = new ChangingItemEventArgs(API.Features.Player.Get(__instance.gameObject), oldItem, newItem);

                Player.OnChangingItem(ev);

                oldItemIndex = __instance.GetItemIndex();

                if (oldItemIndex != -1)
                {
                    __instance.items[oldItemIndex] = ev.OldItem;
                }
            }
            catch (Exception e)
            {
                Exiled.API.Features.Log.Error($"Exiled.Events.Patches.Events.Player.ChangingItem: {e}\n{e.StackTrace}");
            }
        }
Exemplo n.º 10
0
        public static void Prefix(Inventory __instance, int i)
        {
            try
            {
                if (__instance.itemUniq == i)
                {
                    return;
                }

                int oldItemIndex = __instance.GetItemIndex();

                if (oldItemIndex == -1 && i == -1)
                {
                    return;
                }

                Inventory.SyncItemInfo oldItem = oldItemIndex == -1 ? new Inventory.SyncItemInfo()
                {
                    id = ItemType.None
                } : __instance.GetItemInHand();
                Inventory.SyncItemInfo newItem = new Inventory.SyncItemInfo()
                {
                    id = ItemType.None
                };

                foreach (Inventory.SyncItemInfo item in __instance.items)
                {
                    if (item.uniq == i)
                    {
                        newItem = item;
                    }
                }

                Events.InvokeItemChanged(__instance.gameObject, ref oldItem, newItem);

                oldItemIndex = __instance.GetItemIndex();

                if (oldItemIndex != -1)
                {
                    __instance.items[oldItemIndex] = oldItem;
                }

                return;
            }
            catch (Exception exception)
            {
                Log.Error($"ItemChangedEvent error {exception}");
                return;
            }
        }
Exemplo n.º 11
0
        public static void InvokeItemDropped(GameObject player, Pickup pickup, Inventory.SyncItemInfo syncItemInfo)
        {
            if (ItemDroppedEvent == null)
            {
                return;
            }

            ItemDroppedEvent ev = new ItemDroppedEvent
            {
                Player       = player.GetPlayer(),
                Item         = pickup,
                SyncItemInfo = syncItemInfo
            };

            ItemDroppedEvent.InvokeSafely(ev);
        }
Exemplo n.º 12
0
        public static bool Prefix(Inventory __instance, int itemInventoryIndex)
        {
            if (EventPlugin.DropItemEventPatchDisable)
            {
                return(true);
            }

            try
            {
                if (!__instance._iawRateLimit.CanExecute(true) || itemInventoryIndex < 0 || itemInventoryIndex >= __instance.items.Count)
                {
                    return(false);
                }

                Inventory.SyncItemInfo syncItemInfo = __instance.items[itemInventoryIndex];

                if (__instance.items[itemInventoryIndex].id != syncItemInfo.id)
                {
                    return(false);
                }

                bool allow = true;

                Events.InvokeDropItem(__instance.gameObject, ref syncItemInfo, ref allow);

                if (!allow)
                {
                    return(false);
                }

                Pickup dropped = __instance.SetPickup(syncItemInfo.id, syncItemInfo.durability, __instance.transform.position,
                                                      __instance.camera.transform.rotation, syncItemInfo.modSight, syncItemInfo.modBarrel,
                                                      syncItemInfo.modOther);

                __instance.items.RemoveAt(itemInventoryIndex);

                Events.InvokeItemDropped(__instance.gameObject, dropped, syncItemInfo);

                return(false);
            }
            catch (Exception exception)
            {
                Log.Error($"DropItemEvent error: {exception}");
                return(true);
            }
        }
Exemplo n.º 13
0
        private static bool Prefix(Inventory __instance, int itemInventoryIndex)
        {
            try
            {
                if (!__instance._iawRateLimit.CanExecute(true) || itemInventoryIndex < 0 ||
                    itemInventoryIndex >= __instance.items.Count)
                {
                    return(false);
                }

                Inventory.SyncItemInfo syncItemInfo = __instance.items[itemInventoryIndex];

                if (__instance.items[itemInventoryIndex].id != syncItemInfo.id)
                {
                    return(false);
                }

                var droppingItemEventArgs =
                    new DroppingItemEventArgs(API.Features.Player.Get(__instance.gameObject), syncItemInfo);

                Player.OnDroppingItem(droppingItemEventArgs);

                syncItemInfo = droppingItemEventArgs.Item;

                if (!droppingItemEventArgs.IsAllowed)
                {
                    return(false);
                }

                Pickup droppedPickup = __instance.SetPickup(syncItemInfo.id, syncItemInfo.durability, __instance.transform.position, __instance.camera.transform.rotation, syncItemInfo.modSight, syncItemInfo.modBarrel, syncItemInfo.modOther);

                __instance.items.RemoveAt(itemInventoryIndex);

                var itemDroppedEventArgs = new ItemDroppedEventArgs(API.Features.Player.Get(__instance.gameObject), droppedPickup);

                Player.OnItemDropped(itemDroppedEventArgs);

                return(false);
            }
            catch (Exception e)
            {
                API.Features.Log.Error($"Exiled.Events.Patches.Events.Player.ItemDrop: {e}\n{e.StackTrace}");

                return(true);
            }
        }
Exemplo n.º 14
0
        internal static void InvokePlayerReloadEvent(Player player, ref bool allow, Inventory.SyncItemInfo syncItem)
        {
            if (PlayerReloadEvent == null)
            {
                return;
            }

            var ev = new PlayerReloadEvent
            {
                Player        = player,
                Allow         = allow,
                InventorySlot = syncItem
            };

            PlayerReloadEvent.Invoke(ev);

            allow = ev.Allow;
        }
Exemplo n.º 15
0
        public static void InvokeItemChanged(GameObject player, ref Inventory.SyncItemInfo oldItem, Inventory.SyncItemInfo newItem)
        {
            if (ItemChangedEvent == null)
            {
                return;
            }

            ItemChangedEvent ev = new ItemChangedEvent()
            {
                Player  = player.GetPlayer(),
                OldItem = oldItem,
                NewItem = newItem
            };

            ItemChangedEvent.InvokeSafely(ev);

            oldItem = ev.OldItem;
        }
Exemplo n.º 16
0
        private static void Prefix(Inventory __instance, int i)
        {
            if (__instance.itemUniq == i)
            {
                return;
            }

            int oldItemIndex = __instance.GetItemIndex();

            if (oldItemIndex == -1 && i == -1)
            {
                return;
            }

            Inventory.SyncItemInfo oldItem = oldItemIndex == -1 ? new Inventory.SyncItemInfo()
            {
                id = ItemType.None
            } : __instance.GetItemInHand();
            Inventory.SyncItemInfo newItem = new Inventory.SyncItemInfo()
            {
                id = ItemType.None
            };

            foreach (Inventory.SyncItemInfo item in __instance.items)
            {
                if (item.uniq == i)
                {
                    newItem = item;
                }
            }

            var ev = new ChangingItemEventArgs(API.Features.Player.Get(__instance.gameObject), oldItem, newItem);

            Player.OnChangingItem(ev);

            oldItemIndex = __instance.GetItemIndex();

            if (oldItemIndex != -1)
            {
                __instance.items[oldItemIndex] = ev.OldItem;
            }

            return;
        }
Exemplo n.º 17
0
        public static void InvokeDropItem(GameObject player, ref Inventory.SyncItemInfo item, ref bool allow)
        {
            if (DropItemEvent == null)
            {
                return;
            }

            DropItemEvent ev = new DropItemEvent()
            {
                Player = player.GetPlayer(),
                Item   = item,
                Allow  = allow
            };

            DropItemEvent.InvokeSafely(ev);

            allow = ev.Allow;
            item  = ev.Item;
        }
Exemplo n.º 18
0
        public static void InvokeDropItem(GameObject player, ref Inventory.SyncItemInfo item, ref bool allow)
        {
            DropItem dropItem = DropItemEvent;

            if (dropItem == null)
            {
                return;
            }
            DropItemEvent ev = new DropItemEvent()
            {
                Player = Player.GetPlayer(player),
                Item   = item,
                Allow  = allow
            };

            dropItem.Invoke(ref ev);
            allow = ev.Allow;
            item  = ev.Item;
        }
Exemplo n.º 19
0
        internal static void InvokeDropItem(Player player, ref Inventory.SyncItemInfo item, ref bool allow)
        {
            if (DropItemEvent == null)
            {
                return;
            }

            var ev = new DropItemEvent
            {
                Player = player,
                Item   = item,
                Allow  = allow
            };

            DropItemEvent.Invoke(ev);

            allow = ev.Allow;
            item  = ev.Item;
        }
Exemplo n.º 20
0
        private IEnumerator <float> DeletePlayerWeaponsLate(ReferenceHub player)
        {
            yield return(Timing.WaitForSeconds(1f));

            List <Inventory.SyncItemInfo> delete = new List <Inventory.SyncItemInfo>();

            for (int i = 0; i < player.inventory.items.Count; i++)
            {
                Inventory.SyncItemInfo item = player.inventory.items[i];
                if (plugin.allowedRngWeapons.Contains(item.id))
                //if (item.id == ItemType.GunCOM15 || item.id == ItemType.GunE11SR || item.id == ItemType.GunLogicer || item.id == ItemType.GunMP7 || item.id == ItemType.GunProject90 || item.id == ItemType.GunUSP || item.id == ItemType.GrenadeFlash || item.id == ItemType.GrenadeFrag || item.id == ItemType.MicroHID || item.id == ItemType.GunCOM15)
                {
                    delete.Add(item);
                }
            }
            foreach (Inventory.SyncItemInfo item in delete)
            {
                player.inventory.items.Remove(item);
            }
        }
Exemplo n.º 21
0
        private IEnumerator <float> DoInventoryRegeneration(Player player)
        {
            while (true)
            {
                yield return(Timing.WaitForSeconds(RegenerationDelay));

                bool hasItem = false;

                for (int i = 0; i < player.Inventory.items.Count; i++)
                {
                    if (!Check(player.Inventory.items[i]))
                    {
                        continue;
                    }

                    hasItem = true;

                    if (!(player.Inventory.items[i].durability < ClipSize))
                    {
                        continue;
                    }

                    Inventory.SyncItemInfo newInfo = player.Inventory.items[i];

                    if ((newInfo.durability + RegenerationAmount) > ClipSize)
                    {
                        newInfo.durability = ClipSize;
                    }
                    else
                    {
                        newInfo.durability += RegenerationAmount;
                    }
                    player.Inventory.items[i] = newInfo;
                }

                if (!hasItem)
                {
                    yield break;
                }
            }
        }
Exemplo n.º 22
0
 public static bool HasSmallScope(this ReferenceHub rh)
 {
     if (rh.inventory == null || rh.weaponManager == null || !rh.weaponManager.NetworksyncFlash ||
         rh.weaponManager.curWeapon < 0 ||
         rh.weaponManager.curWeapon >= rh.weaponManager.weapons.Length)
     {
         return(false);
     }
     WeaponManager.Weapon   weapon     = rh.weaponManager.weapons[rh.weaponManager.curWeapon];
     Inventory.SyncItemInfo itemInHand = rh.inventory.GetItemInHand();
     if (weapon == null || itemInHand.modSight < 0 || itemInHand.modSight >= weapon.mod_sights.Length)
     {
         return(false);
     }
     WeaponManager.Weapon.WeaponMod modScope = weapon.mod_sights[itemInHand.modSight];
     if (modScope != null && !string.IsNullOrEmpty(modScope.name) && (modScope.name.ToLower().Contains("dot") || modScope.name.Contains("holo")))
     {
         return(true);
     }
     return(false);
 }
Exemplo n.º 23
0
        /// <summary>
        /// Sets other modification of the weapon.
        /// </summary>
        /// <param name="player">The player instance.</param>
        /// <param name="weapon">The weapon with attachment.</param>
        /// <param name="type">Type of the other.</param>
        public static void SetOther(this Player player, Inventory.SyncItemInfo weapon, OtherType type)
        {
            WeaponManager wmanager = player.ReferenceHub.weaponManager;

            if (weapon.id.IsWeapon())
            {
                WeaponManager.Weapon wep = wmanager.weapons.FirstOrDefault(wp => wp.inventoryID == weapon.id);
                if (wep != null)
                {
                    string name = type.ToString("g").SplitCamelCase();

                    int weaponMod = wep.mod_others.Select((s, i) => new { s, i }).Where(e => e.s.name == name).Select(e => e.i).FirstOrDefault();
                    int weaponId  = player.Inventory.items.FindIndex(s => s == weapon);
                    weapon.modOther = weaponMod;
                    if (weaponId > -1)
                    {
                        player.Inventory.items[weaponId] = weapon;
                    }
                }
            }
        }
Exemplo n.º 24
0
        /// <summary>
        /// Gets other modification of the weapon.
        /// </summary>
        /// <param name="player">The player instance.</param>
        /// <param name="weapon">The weapon with attachment.</param>
        /// <returns>Returns <see cref="OtherType"/>.</returns>
        public static OtherType GetOther(this Player player, Inventory.SyncItemInfo weapon)
        {
            WeaponManager wmanager = player.ReferenceHub.weaponManager;

            if (weapon.id.IsWeapon())
            {
                WeaponManager.Weapon wep = wmanager.weapons.FirstOrDefault(wp => wp.inventoryID == weapon.id);
                if (wep != null)
                {
                    try
                    {
                        string name = wep.mod_others[weapon.modOther].name.RemoveSpaces();
                        return((OtherType)Enum.Parse(typeof(OtherType), name));
                    }
                    catch (Exception)
                    {
                    }
                }
            }

            return(OtherType.None);
        }
Exemplo n.º 25
0
        void PlayerPickup(PickingUpItemEventArgs ev)
        {
            ev.IsAllowed = false;
            if (ev.Pickup.itemId.IsKeycard())
            {
                Inventory.SyncItemInfo curCard = CurrentKeycard(ev.Player);
                if (ev.Pickup.ItemId <= curCard.id)
                {
                    ev.Player.ShowHint("Your keycard is already a higher grade!");
                    return;
                }

                if (ev.Pickup.ItemId - 1 > curCard.id)
                {
                    ev.Player.ShowHint("You need to find a lower tier card first!");
                    return;
                }

                curCard.id++;
                ev.Player.ShowHint($"Upgraded! Next one is: {curCard.id+1.ToString()}");
            }
            else if (ev.Pickup.ItemId == ItemType.SCP207)
            {
                if (ev.Player.GetEffectActive <Scp207>())
                {
                    ev.Player.ShowHint("Speedboost already enabled!");
                    return;
                }

                ev.Player.ShowHint("Speedboost enabled!");
                ev.Player.EnableEffect <Scp207>();
                ev.Player.ChangeEffectIntensity <Scp207>(1);
            }
            else
            {
                ev.Player.ShowHint("Sorry, picking up that item is not allowed.");
            }
        }
Exemplo n.º 26
0
        public bool LoadInventory(Player plr)
        {
            if (!PluginMain.items.ContainsKey(plr.UserId))
            {
                return(false);
            }
            List <Inventory.SyncItemInfo> items = PluginMain.items[plr.UserId];

            if (items.Count == 0)
            {
                return(false);
            }
            foreach (var item in items)
            {
                var newitem = new Inventory.SyncItemInfo();
                newitem.id         = item.id;
                newitem.modSight   = item.modSight;
                newitem.modBarrel  = item.modBarrel;
                newitem.modOther   = item.modOther;
                newitem.durability = Pickup.Inv.GetItemByID(item.id).durability;
                plr.AddItem(newitem);
            }
            return(true);
        }
Exemplo n.º 27
0
 /// <summary>
 /// Initializes a new instance of the <see cref="OwnerEscapingEventArgs"/> class.
 /// </summary>
 /// <param name="item"><inheritdoc cref="Item"/></param>
 /// <param name="player"><inheritdoc cref="EscapingEventArgs.Player"/></param>
 /// <param name="newRole"><inheritdoc cref="EscapingEventArgs.NewRole"/></param>
 /// <param name="isAllowed"><inheritdoc cref="EscapingEventArgs.IsAllowed"/></param>
 public OwnerEscapingEventArgs(Inventory.SyncItemInfo item, Player player, RoleType newRole, bool isAllowed = true)
     : base(player, newRole, isAllowed)
 {
     Item = item;
 }
Exemplo n.º 28
0
 /// <summary>
 /// Initializes a new instance of the <see cref="OwnerEscapingEventArgs"/> class.
 /// </summary>
 /// <param name="item"><inheritdoc cref="Item"/></param>
 /// <param name="ev">The <see cref="EscapingEventArgs"/> instance.</param>
 public OwnerEscapingEventArgs(Inventory.SyncItemInfo item, EscapingEventArgs ev)
     : this(item, ev.Player, ev.NewRole, ev.IsAllowed)
 {
 }
Exemplo n.º 29
0
 /// <summary>
 /// Add an item with the specified info to a player's inventory.
 /// </summary>
 /// <param name="player"></param>
 /// <param name="item"></param>
 public static void AddItem(this ReferenceHub player, Inventory.SyncItemInfo item) => player.inventory.AddNewItem(item.id, item.durability, item.modSight, item.modBarrel, item.modOther);
Exemplo n.º 30
0
 /// <summary>
 /// Remove an item from the player's inventory.
 /// </summary>
 /// <param name="player"></param>
 /// <param name="item"></param>
 public static void RemoveItem(this ReferenceHub player, Inventory.SyncItemInfo item) => player.inventory.items.Remove(item);