private void Events_OnWearGlasses(Player nativePlayer, ushort id, byte quality, byte[] state, ref bool cancel) { var player = GetUnturnedPlayer(nativePlayer) !; ICancellableEvent @event; if (id == 0) { PlayerClothing c = nativePlayer.clothing; var item = new Item(c.glasses, 1, c.glassesQuality, c.glassesState); @event = new UnturnedPlayerClothingUnequippingEvent(player !, new UnturnedClothingItem(item, player, ClothingType.Glasses)); } else { var item = new Item(id, 1, quality, state); @event = new UnturnedPlayerClothingEquippingEvent(player !, new UnturnedClothingItem(item, player, ClothingType.Glasses)); } @event.IsCancelled = cancel; Emit(@event); cancel = @event.IsCancelled; }
public static void Copy(UnturnedPlayer fromPlayer, UnturnedPlayer toPlayer, bool clothes) { PlayerClothing clothing = fromPlayer.Player.clothing; Hat hat = new Hat(clothing.hat, clothing.hatQuality, clothing.hatState); Mask mask = new Mask(clothing.mask, clothing.maskQuality, clothing.maskState); Shirt shirt = new Shirt(clothing.shirt, clothing.shirtQuality, clothing.shirtState); Vest vest = new Vest(clothing.vest, clothing.vestQuality, clothing.vestState); Backpack backpack = new Backpack(clothing.backpack, clothing.backpackQuality, clothing.backpackState); Pants pants = new Pants(clothing.pants, clothing.pantsQuality, clothing.pantsState); Clothing clothesList = new Clothing(hat, mask, shirt, vest, backpack, pants); List <Item> itemList = ListItems(fromPlayer); int inventoryCount = itemList.Count; Clear(toPlayer, clothes); if (clothes == true) { AddClothing(toPlayer, backpack, clothesList); } else { AddClothing(toPlayer, backpack); } for (int i = 0; i < itemList.Count; i++) { AddItem(toPlayer, itemList[i]); } }
private void Events_OnWearGlasses(Player nativePlayer, ushort id, byte quality, byte[] state, out bool cancel) { UnturnedPlayer player = GetUnturnedPlayer(nativePlayer); ICancellableEvent @event; if (id == 0) { PlayerClothing c = nativePlayer.clothing; Item item = new Item(c.glasses, 1, c.glassesQuality, c.glassesState); @event = new UnturnedPlayerClothingUnequippingEvent(player, new UnturnedItem(item), ClothingType.Glasses); } else { Item item = new Item(id, 1, quality, state); @event = new UnturnedPlayerClothingEquippingEvent(player, new UnturnedItem(item), ClothingType.Glasses); } Emit(@event); cancel = @event.IsCancelled; }
public static IEnumerable <SerializableItem> GetClothing(this PlayerClothing source) { ICollection <SerializableItem> result = new List <SerializableItem>(); if (source.backpack != default) { result.Add(SerializableItem.CreateSerializableItem(new Item(source.backpack, 1, source.backpackQuality, source.backpackState))); } if (source.backpack != default) { result.Add(SerializableItem.CreateSerializableItem(new Item(source.glasses, 1, source.glassesQuality, source.glassesState))); } if (source.hat != default) { result.Add(SerializableItem.CreateSerializableItem(new Item(source.hat, 1, source.hatQuality, source.hatState))); } if (source.mask != default) { result.Add(SerializableItem.CreateSerializableItem(new Item(source.mask, 1, source.maskQuality, source.maskState))); } if (source.pants != default) { result.Add(SerializableItem.CreateSerializableItem(new Item(source.pants, 1, source.pantsQuality, source.pantsState))); } if (source.shirt != default) { result.Add(SerializableItem.CreateSerializableItem(new Item(source.shirt, 1, source.shirtQuality, source.shirtState))); } if (source.vest != default) { result.Add(SerializableItem.CreateSerializableItem(new Item(source.vest, 1, source.vestQuality, source.vestState))); } return(result); }
private static bool AskWearVest(PlayerClothing __instance, ushort id, byte quality, byte[] state) { bool cancel = false; OnWearVest?.Invoke(__instance.player, id, quality, state, out cancel); return !cancel; }
public static bool AskWearVest(PlayerClothing __instance, ushort id, byte quality, byte[] state) { var cancel = false; OnWearVest?.Invoke(__instance.player, id, quality, state, ref cancel); return(!cancel); }
void takeOffBackpack(PlayerClothing clothing) { if (clothing.backpack > 0) { clothing.askWearBackpack(0, 0, new byte[0], true); UnturnedChat.Say(clothing.player.channel.owner.playerID.steamID, Plugin.Instance.Translate("DisableBackpackCustomField_takeOffBackpack"), true); } }
private IEnumerator PlayerJoin(Player player, PlayerClothing clothing) { yield return(new WaitForSeconds(2f)); SendEffectClothing(clothing.backpack, player); SendEffectClothing(clothing.glasses, player); SendEffectClothing(clothing.hat, player); SendEffectClothing(clothing.mask, player); SendEffectClothing(clothing.pants, player); SendEffectClothing(clothing.shirt, player); SendEffectClothing(clothing.vest, player); yield break; }
public static List <ItemWrapper> GetClothing(this UnturnedPlayer player) { var list = new List <ItemWrapper>(); PlayerClothing clothing = player.Player.clothing; if (clothing.backpack != 0) { ItemWrapper item = new ItemWrapper(new Item(clothing.backpack, 1, clothing.backpackQuality, clothing.backpackState)); list.Add(item); } if (clothing.glasses != 0) { ItemWrapper item = new ItemWrapper(new Item(clothing.glasses, 1, clothing.glassesQuality, clothing.glassesState)); list.Add(item); } if (clothing.hat != 0) { ItemWrapper item = new ItemWrapper(new Item(clothing.hat, 1, clothing.hatQuality, clothing.hatState)); list.Add(item); } if (clothing.mask != 0) { ItemWrapper item = new ItemWrapper(new Item(clothing.mask, 1, clothing.maskQuality, clothing.maskState)); list.Add(item); } if (clothing.shirt != 0) { ItemWrapper item = new ItemWrapper(new Item(clothing.shirt, 1, clothing.shirtQuality, clothing.shirtState)); list.Add(item); } if (clothing.vest != 0) { ItemWrapper item = new ItemWrapper(new Item(clothing.vest, 1, clothing.vestQuality, clothing.vestState)); list.Add(item); } if (clothing.pants != 0) { ItemWrapper item = new ItemWrapper(new Item(clothing.pants, 1, clothing.pantsQuality, clothing.pantsState)); list.Add(item); } return(list); }
public void SummonContainer(PlayerClothing clothing, ushort id) { var transform = BarricadeManager.dropBarricade(new Barricade(id), null, BarricadeLocation.ToVector3(), 0, 0, 0, 0, 0) .GetComponent <InteractableMannequin>(); if (!Plugin.Instance.Configuration.Instance.ClearClothing) { transform.clothes.visualShirt = clothing.shirt; transform.clothes.visualPants = clothing.pants; transform.clothes.visualHat = clothing.hat; transform.clothes.visualBackpack = clothing.backpack; transform.clothes.visualVest = clothing.vest; transform.clothes.visualMask = clothing.mask; transform.clothes.visualGlasses = clothing.glasses; } transform.rebuildState(); BarricadeManager.tryGetInfo(transform.transform, out byte x, out byte y, out ushort plant, out ushort index, out var region, out var drop); InstanceId = drop.instanceID; }
public static SerializableItem[] ToSerializableItems(this PlayerClothing clothing) { var serializableItems = new List <SerializableItem>(); if (clothing.hat != 0) { serializableItems.Add(new SerializableItem(clothing.hat.ToString(), clothing.hatState, 1, 100, clothing.hatQuality)); } if (clothing.glasses != 0) { serializableItems.Add(new SerializableItem(clothing.glasses.ToString(), clothing.glassesState, 1, 100, clothing.glassesQuality)); } if (clothing.mask != 0) { serializableItems.Add(new SerializableItem(clothing.mask.ToString(), clothing.maskState, 1, 100, clothing.maskQuality)); } if (clothing.shirt != 0) { serializableItems.Add(new SerializableItem(clothing.shirt.ToString(), clothing.shirtState, 1, 100, clothing.shirtQuality)); } if (clothing.vest != 0) { serializableItems.Add(new SerializableItem(clothing.vest.ToString(), clothing.vestState, 1, 100, clothing.vestQuality)); } if (clothing.backpack != 0) { serializableItems.Add(new SerializableItem(clothing.backpack.ToString(), clothing.backpackState, 1, 100, clothing.backpackQuality)); } if (clothing.pants != 0) { serializableItems.Add(new SerializableItem(clothing.pants.ToString(), clothing.pantsState, 1, 100, clothing.pantsQuality)); } return(serializableItems.ToArray()); }
public void Execute(IRocketPlayer caller, string[] command) { if (command.Length != 1) { UnturnedChat.Say(caller, Syntax); return; } #region vars UnturnedPlayer player = (UnturnedPlayer)caller; ulong id = player.CSteamID.m_SteamID; List <LItem> itemList = new List <LItem>(); PlayerClothing clo = player.Player.clothing; bool DebugMode = Loadout.Instance.Configuration.Instance.DebugMode; #endregion vars #region items if (DebugMode) { Logger.Log("Beginning item saves"); } for (byte p = 0; p < PlayerInventory.PAGES - 1; p++) { for (byte i = 0; i < player.Inventory.getItemCount(p); i++) { Item item = player.Inventory.getItem(p, i).item; if (Loadout.Instance.Configuration.Instance.ItemBlacklist.Contains(item.id)) { if (Loadout.Instance.Configuration.Instance.DenyOnBlacklist) { UnturnedChat.Say(caller, Loadout.Instance.Translate("denied", item.id)); return; } else { UnturnedChat.Say(caller, Loadout.Instance.Translate("blacklisted", item.id)); continue; } } itemList.Add(new LItem(item.id, item.metadata)); } } if (DebugMode) { Logger.Log("Beginning blacklist check"); } if (itemList.Count > Loadout.Instance.Configuration.Instance.ItemLimit) { UnturnedChat.Say(caller, Loadout.Instance.Translate("too_much", Loadout.Instance.Configuration.Instance.ItemLimit, itemList.Count)); return; } if (DebugMode) { Logger.Log("Item saves complete"); if (itemList == null) { Logger.Log("Null"); } } #endregion items #region clothing if (DebugMode) { Logger.Log("Beginning clothing save"); } LoadoutClothing hat = new LoadoutClothing(clo.hat, clo.hatQuality, clo.hatState); LoadoutClothing glasses = new LoadoutClothing(clo.glasses, clo.glassesQuality, clo.glassesState); LoadoutClothing mask = new LoadoutClothing(clo.mask, clo.maskQuality, clo.maskState); LoadoutClothing shirt = new LoadoutClothing(clo.shirt, clo.shirtQuality, clo.shirtState); LoadoutClothing vest = new LoadoutClothing(clo.vest, clo.vestQuality, clo.vestState); LoadoutClothing backpack = new LoadoutClothing(clo.backpack, clo.backpackQuality, clo.backpackState); LoadoutClothing pants = new LoadoutClothing(clo.pants, clo.pantsQuality, clo.pantsState); LoadoutClothes clothes = new LoadoutClothes(hat, glasses, mask, shirt, vest, backpack, pants); if (DebugMode) { Logger.Log("Clothing save complete"); if (clothes == null) { Logger.Log("Null"); } } #endregion clothing #region dictionary if (DebugMode) { Logger.Log("Beginning final dictionary save"); if (Loadout.Instance.playerInvs == null) { Logger.Log("Null"); } } if (!Loadout.Instance.playerInvs.ContainsKey(id)) { Loadout.Instance.playerInvs.Add(id, new LoadoutList(new Dictionary <string, LoadoutInventory>())); Loadout.Instance.playerInvs[id].inventories.Add(command[0], new LoadoutInventory(itemList, clothes)); UnturnedChat.Say(caller, Loadout.Instance.Translate("saved")); if (DebugMode) { Logger.Log("Player has no saves, adding to dictionary"); } } else { if (DebugMode) { Logger.Log("Player has saves"); } if (!Loadout.Instance.playerInvs[id].inventories.ContainsKey(command[0])) { Loadout.Instance.playerInvs[id].inventories.Add(command[0], new LoadoutInventory(itemList, clothes)); UnturnedChat.Say(caller, Loadout.Instance.Translate("saved")); if (DebugMode) { Logger.Log("Player saved a unique kit"); } } else { Loadout.Instance.playerInvs[id].inventories.Remove(command[0]); Loadout.Instance.playerInvs[id].inventories.Add(command[0], new LoadoutInventory(itemList, clothes)); UnturnedChat.Say(caller, Loadout.Instance.Translate("replaced")); if (DebugMode) { Logger.Log("Player has replaced a kit"); } } } #endregion dictionary }
public float armor(ELimb limb, Player player) { if (limb == ELimb.LEFT_FOOT || limb == ELimb.LEFT_LEG || limb == ELimb.RIGHT_FOOT || limb == ELimb.RIGHT_LEG) { if (player.clothing.pants != 0) { ItemClothingAsset itemClothingAsset = (ItemClothingAsset)Assets.find(EAssetType.ITEM, player.clothing.pants); if (itemClothingAsset != null) { if (Provider.modeConfigData.Items.Has_Durability && player.clothing.pantsQuality > 0) { PlayerClothing clothing = player.clothing; clothing.pantsQuality -= 1; player.clothing.sendUpdatePantsQuality(); } return(itemClothingAsset.armor + (1f - itemClothingAsset.armor) * (1f - (float)player.clothing.pantsQuality / 100f)); } } } else if (limb == ELimb.LEFT_HAND || limb == ELimb.LEFT_ARM || limb == ELimb.RIGHT_HAND || limb == ELimb.RIGHT_ARM) { if (player.clothing.shirt != 0) { ItemClothingAsset itemClothingAsset2 = (ItemClothingAsset)Assets.find(EAssetType.ITEM, player.clothing.shirt); if (itemClothingAsset2 != null) { if (Provider.modeConfigData.Items.Has_Durability && player.clothing.shirtQuality > 0) { PlayerClothing clothing2 = player.clothing; clothing2.shirtQuality -= 1; player.clothing.sendUpdateShirtQuality(); } return(itemClothingAsset2.armor + (1f - itemClothingAsset2.armor) * (1f - (float)player.clothing.shirtQuality / 100f)); } } } else { if (limb == ELimb.SPINE) { float num = 1f; if (player.clothing.vest != 0) { ItemClothingAsset itemClothingAsset3 = (ItemClothingAsset)Assets.find(EAssetType.ITEM, player.clothing.vest); if (itemClothingAsset3 != null) { if (Provider.modeConfigData.Items.Has_Durability && player.clothing.vestQuality > 0) { PlayerClothing clothing3 = player.clothing; clothing3.vestQuality -= 1; player.clothing.sendUpdateVestQuality(); } num *= itemClothingAsset3.armor + (1f - itemClothingAsset3.armor) * (1f - (float)player.clothing.vestQuality / 100f); } } if (player.clothing.shirt != 0) { ItemClothingAsset itemClothingAsset4 = (ItemClothingAsset)Assets.find(EAssetType.ITEM, player.clothing.shirt); if (itemClothingAsset4 != null) { if (Provider.modeConfigData.Items.Has_Durability && player.clothing.shirtQuality > 0) { PlayerClothing clothing4 = player.clothing; clothing4.shirtQuality -= 1; player.clothing.sendUpdateShirtQuality(); } num *= itemClothingAsset4.armor + (1f - itemClothingAsset4.armor) * (1f - (float)player.clothing.shirtQuality / 100f); } } return(num); } if (limb == ELimb.SKULL && player.clothing.hat != 0) { ItemClothingAsset itemClothingAsset5 = (ItemClothingAsset)Assets.find(EAssetType.ITEM, player.clothing.hat); if (itemClothingAsset5 != null) { if (Provider.modeConfigData.Items.Has_Durability && player.clothing.hatQuality > 0) { PlayerClothing clothing5 = player.clothing; clothing5.hatQuality -= 1; player.clothing.sendUpdateHatQuality(); } return(itemClothingAsset5.armor + (1f - itemClothingAsset5.armor) * (1f - (float)player.clothing.hatQuality / 100f)); } } } return(1f); }
public static void SaveKit(UnturnedPlayer fromPlayer, UnturnedPlayer toPlayer, string kitName, Dictionary <ulong, Dictionary <string, InventoryManager.Inventory> > database) { PlayerClothing clothing = fromPlayer.Player.clothing; InventoryManager.Hat hat = new InventoryManager.Hat(clothing.hat, clothing.hatQuality, clothing.hatState); InventoryManager.Mask mask = new InventoryManager.Mask(clothing.mask, clothing.maskQuality, clothing.maskState); InventoryManager.Shirt shirt = new InventoryManager.Shirt(clothing.shirt, clothing.shirtQuality, clothing.shirtState); InventoryManager.Vest vest = new InventoryManager.Vest(clothing.vest, clothing.vestQuality, clothing.vestState); InventoryManager.Backpack backpack = new InventoryManager.Backpack(clothing.backpack, clothing.backpackQuality, clothing.backpackState); InventoryManager.Pants pants = new InventoryManager.Pants(clothing.pants, clothing.pantsQuality, clothing.pantsState); InventoryManager.Clothing clothesList = new InventoryManager.Clothing(hat, mask, shirt, vest, backpack, pants); List <InventoryManager.Item> itemList = new List <InventoryManager.Item>(); string[] blackList = new string[0]; foreach (Plugin.CustomKitsConfig.Preset Preset in Plugin.CustomKitsPlugin.Instance.Configuration.Instance.Presets) { if (toPlayer.HasPermission(Plugin.CustomKitsPlugin.PERMISSION + Preset.Name)) { if (Preset.Blacklist != "") { blackList = Preset.Blacklist.Split(','); break; } } } List <int> bList = new List <int>(); if (blackList.Length > 0) { foreach (var itemID in blackList) { bList.Add(int.Parse(itemID)); } } //foreach (Items page in fromPlayer.Inventory.items) //{ // if (page == null || page.items == null || page.items.Count == 0) // continue; // int itemsCount = page.items.Count; // foreach (ItemJar item in page.items) // { // } //} for (byte page = 0; page < fromPlayer.Inventory.items.Length; page++) { if (fromPlayer.Inventory.items[page] == null || fromPlayer.Inventory.items[page].items == null || fromPlayer.Inventory.items[page].items.Count == 0) { continue; } for (byte index = 0; index < fromPlayer.Inventory.getItemCount(page); index++) { ItemJar iJar = fromPlayer.Inventory.getItem(page, index); if (!toPlayer.IsAdmin && bList.Contains(iJar.item.id)) { continue; } itemList.Add(new InventoryManager.Item(iJar.item.id, iJar.item.metadata, page, iJar.x, iJar.y, iJar.rot)); } } if (database.ContainsKey(toPlayer.CSteamID.m_SteamID)) { if (database[toPlayer.CSteamID.m_SteamID].ContainsKey(kitName)) { database[toPlayer.CSteamID.m_SteamID][kitName] = new InventoryManager.Inventory(itemList, clothesList); } else { database[toPlayer.CSteamID.m_SteamID].Add(kitName, new InventoryManager.Inventory(itemList, clothesList)); } } else { Dictionary <string, InventoryManager.Inventory> kit = new Dictionary <string, InventoryManager.Inventory> { { kitName, new InventoryManager.Inventory(itemList, clothesList) } }; database.Add(toPlayer.CSteamID.m_SteamID, kit); } Events.InvokeSaveKit(fromPlayer, toPlayer, kitName); }
private void Respawn() { Debug.Log("LocalPlayer -> Respawn"); if (LocalPlayer.Stats.Dead) { if (LocalPlayer.IsInEndgame) { GameObject gameObject = GameObject.FindWithTag("EndgameLoader"); if (gameObject) { SceneLoadTrigger component = gameObject.GetComponent <SceneLoadTrigger>(); component.ForceUnload(); } } EventRegistry.Player.Publish(TfEvent.ExitOverlookArea, null); EventRegistry.Player.Publish(TfEvent.ExitEndgame, null); LocalPlayer.GameObject.SendMessage("NotInACave"); PlayerInventory inventory = LocalPlayer.Inventory; PlayerClothing clothing = LocalPlayer.Clothing; AchievementsManager achievements = LocalPlayer.Achievements; SurvivalBookTodo componentInChildren = LocalPlayer.SpecialItems.GetComponentInChildren <SurvivalBookTodo>(); string name = LocalPlayer.Entity.GetState <IPlayerState>().name; bool value = LocalPlayer.SavedData.ReachedLowSanityThreshold; bool value2 = LocalPlayer.SavedData.ExitedEndgame; LocalPlayer.Inventory.HideAllEquiped(false, false); LocalPlayer.Inventory.enabled = false; if (Scene.SceneTracker.allPlayers.Contains(LocalPlayer.GameObject)) { Scene.SceneTracker.allPlayers.Remove(LocalPlayer.GameObject); } if (Scene.SceneTracker.allPlayerEntities.Contains(LocalPlayer.Entity)) { Scene.SceneTracker.allPlayerEntities.Remove(LocalPlayer.Entity); } BoltNetwork.Detach(LocalPlayer.Entity); GameObject gameObject2 = LocalPlayer.GameObject; BoltEntity entity = LocalPlayer.Entity; gameObject2.name = "player Corpse - " + name; gameObject2.tag = "Untagged"; LocalPlayer.MainCamTr.parent = LocalPlayer.Transform; LocalPlayer.Inventory.CurrentView = PlayerInventory.PlayerViews.Loot; if (LocalPlayer.AnimControl.swimming) { LocalPlayer.Rigidbody.useGravity = true; } for (int i = gameObject2.transform.childCount - 1; i >= 0; i--) { Transform child = gameObject2.transform.GetChild(i); UnityEngine.Object.Destroy(child.gameObject); } Component[] components = gameObject2.GetComponents(typeof(MonoBehaviour)); foreach (Component component2 in components) { if (!(component2 is BoltEntity)) { UnityEngine.Object.DestroyImmediate(component2); } } Transform transform = base.transform; GameObject gameObject3 = UnityEngine.Object.Instantiate <GameObject>(Prefabs.Instance.PlayerPrefab, transform.position, transform.rotation); gameObject3.transform.localEulerAngles = new Vector3(0f, gameObject3.transform.localEulerAngles.y, 0f); gameObject3.name = Prefabs.Instance.PlayerPrefab.name; LocalPlayer.Inventory.SetQuickSelectItemIds(inventory.QuickSelectItemIds); LocalPlayer.Achievements.Clone(achievements); LocalPlayer.SpecialItems.GetComponentInChildren <SurvivalBookTodo>().Clone(componentInChildren); LocalPlayer.SavedData.ReachedLowSanityThreshold.SetValue(value); LocalPlayer.SavedData.ExitedEndgame.SetValue(value2); LocalPlayer.FpCharacter.UnLockView(); LocalPlayer.CamFollowHead.enableMouseControl(false); LocalPlayer.MainCamTr.localEulerAngles = Vector3.zero; LocalPlayer.MainRotator.enabled = true; LocalPlayer.CamRotator.enabled = true; LocalPlayer.Stats.Health = 28f; LocalPlayer.Stats.HealthTarget = 28f; LocalPlayer.Stats.Energy = 100f; LocalPlayer.Stats.Fullness = 0.35f; LocalPlayer.Stats.Thirst = 0.35f; LocalPlayer.Stats.Invoke("CheckArmsStart", 2f); LocalPlayer.Stats.Invoke("PlayWakeMusic", 0.5f); LocalPlayer.Tuts.CloseColdTut(); Scene.RainFollowGO.GetComponent <SmoothTransformConstraint>().target = LocalPlayer.Transform; gameObject3.SetActive(true); CoopUtils.AttachLocalPlayer(gameObject3, name); Scene.SceneTracker.allPlayers.Add(LocalPlayer.GameObject); LocalPlayer.GreebleRoot.SetActive(true); LocalPlayer.Inventory.enabled = true; LocalPlayer.Transform.SendMessage("enableMpRenderers"); LocalPlayer.Transform.SendMessage("playerLoadedFromRespawn"); this._addedItems = false; StealItemTrigger stealItemTrigger = UnityEngine.Object.Instantiate <StealItemTrigger>(Prefabs.Instance.DeadBackpackPrefab, gameObject2.transform.position, gameObject2.transform.rotation); stealItemTrigger._entity = entity; stealItemTrigger.transform.parent = gameObject2.transform; gameObject2.AddComponent <DeathMPTut>(); ItemStorage itemStorage = gameObject2.AddComponent <ItemStorage>(); itemStorage._acceptedTypes = ~Item.Types.Story; for (int k = inventory._possessedItems.Count - 1; k >= 0; k--) { InventoryItem inventoryItem = inventory._possessedItems[k]; if (!LocalPlayer.Inventory.Owns(inventoryItem._itemId, false)) { if (inventoryItem.MaxAmount == 1) { InventoryItemView inventoryItemView = inventory.InventoryItemViewsCache[inventoryItem._itemId][0]; this.AddItemToStorage(inventoryItem._itemId, inventoryItem._amount, itemStorage, inventoryItemView.Properties); } else if (inventoryItem.MaxAmount > 0 && inventoryItem.MaxAmount < 2147483647) { while (inventory.Owns(inventoryItem._itemId, false)) { InventoryItemView inventoryItemView2 = inventory.InventoryItemViewsCache[inventoryItem._itemId][0]; inventory.SortInventoryViewsByBonus(inventoryItemView2, inventoryItemView2.Properties.ActiveBonus, true); int amount = inventory.AmountOfItemWithBonus(inventoryItem._itemId, inventoryItemView2.Properties.ActiveBonus); inventory.RemoveItem(inventoryItem._itemId, amount, true, false); this.AddItemToStorage(inventoryItem._itemId, amount, itemStorage, inventoryItemView2.Properties); } } else { this.AddItemToStorage(inventoryItem._itemId, inventoryItem._amount, itemStorage, null); } } } for (int l = 0; l < inventory.EquipmentSlots.Length; l++) { InventoryItemView inventoryItemView3 = inventory.EquipmentSlots[l]; if (inventoryItemView3 && inventoryItemView3._itemId > 0) { this.AddItemToStorage(inventoryItemView3._itemId, 1, itemStorage, inventoryItemView3.Properties); } } clothing.DropAll(gameObject2.transform.position, true, true); if (!this._addedItems) { UnityEngine.Object.Destroy(gameObject2); } animalAI[] array2 = UnityEngine.Object.FindObjectsOfType <animalAI>(); foreach (animalAI animalAI in array2) { animalAI.SendMessage("updatePlayerTargets"); } mutantAI[] array4 = UnityEngine.Object.FindObjectsOfType <mutantAI>(); foreach (mutantAI mutantAI in array4) { mutantAI.SendMessage("updatePlayerTargets"); } Fish[] array6 = UnityEngine.Object.FindObjectsOfType <Fish>(); mutantScriptSetup[] array7 = UnityEngine.Object.FindObjectsOfType <mutantScriptSetup>(); foreach (mutantScriptSetup mutantScriptSetup in array7) { mutantScriptSetup.setupPlayer(); mutantScriptSetup.search.refreshCurrentTarget(); } LocalPlayer.Transform.SendMessage("enableMpRenderers"); Terrain.activeTerrain.GetComponent <Collider>().enabled = true; Scene.Clock.IsNotCave(); } PlayerRespawnMP.Cancel(); if (this._bringUpPauseMenu) { this._bringUpPauseMenu = false; LocalPlayer.Inventory.TogglePauseMenu(); } }
public static void ragdollPlayer(Vector3 point, Quaternion rotation, Transform skeleton, Vector3 ragdoll, PlayerClothing clothes) { if (!GraphicsSettings.ragdolls) { return; } ragdoll.y += 8f; ragdoll.x += Random.Range(-16f, 16f); ragdoll.z += Random.Range(-16f, 16f); ragdoll *= (float)((!(Player.player != null) || Player.player.skills.boost != EPlayerBoost.FLIGHT) ? 32 : 256); Transform transform = ((GameObject)Object.Instantiate(Resources.Load("Characters/Ragdoll_Player"), point + Vector3.up * 0.1f, rotation * Quaternion.Euler(90f, 0f, 0f))).transform; transform.name = "Ragdoll"; transform.parent = Level.effects; if (skeleton != null) { RagdollTool.applySkeleton(skeleton, transform.FindChild("Skeleton")); } transform.FindChild("Skeleton").FindChild("Spine").GetComponent <Rigidbody>().AddForce(ragdoll); Object.Destroy(transform.gameObject, GraphicsSettings.effect); if (clothes != null && clothes.thirdClothes != null) { HumanClothes component = transform.GetComponent <HumanClothes>(); component.skin = clothes.skin; component.color = clothes.color; component.face = clothes.face; component.hair = clothes.hair; component.beard = clothes.beard; component.shirt = clothes.shirt; component.pants = clothes.pants; component.hat = clothes.hat; component.backpack = clothes.backpack; component.vest = clothes.vest; component.mask = clothes.mask; component.glasses = clothes.glasses; component.visualShirt = clothes.visualShirt; component.visualPants = clothes.visualPants; component.visualHat = clothes.visualHat; component.visualBackpack = clothes.visualBackpack; component.visualVest = clothes.visualVest; component.visualMask = clothes.visualMask; component.visualGlasses = clothes.visualGlasses; component.isVisual = clothes.isVisual; component.apply(); } }
internal static void InternalOnMaskChanged(PlayerClothing clothing) { UnturnedPlayer rp = UnturnedPlayer.FromPlayer(clothing.player); OnPlayerWear.TryInvoke(rp, Wearables.Mask, clothing.mask, clothing.maskQuality); }
internal static void InternalOnVestChanged(PlayerClothing clothing) { UnturnedPlayer rp = UnturnedPlayer.FromPlayer(clothing.player); OnPlayerWear.TryInvoke(rp, Wearables.Vest, clothing.vest, clothing.vestQuality); }
public void OnRevive(UnturnedPlayer Player, Vector3 Place, byte idk) { if (Autos.Contains(Player.CSteamID.m_SteamID) && ((IRocketPlayer)Player).HasPermission("loadout.autoload")) { LoadoutList List = playerInvs[Player.CSteamID.m_SteamID]; if (List.inventories.ContainsKey("default")) { LoadoutInventory Inventory = List.inventories["default"]; #region clothing PlayerClothing clo = Player.Player.clothing; LoadoutClothes clothes = Inventory.clothes; LoadoutClothing hat = clothes.hat; LoadoutClothing glasses = clothes.glasses; LoadoutClothing mask = clothes.mask; LoadoutClothing shirt = clothes.shirt; LoadoutClothing vest = clothes.vest; LoadoutClothing backpack = clothes.backpack; LoadoutClothing pants = clothes.pants; if (hat != null) { clo.askWearHat(hat.id, hat.quality, hat.state, true); } if (glasses != null) { clo.askWearGlasses(glasses.id, glasses.quality, glasses.state, true); } if (mask != null) { clo.askWearMask(mask.id, mask.quality, mask.state, true); } if (shirt != null) { clo.askWearShirt(shirt.id, shirt.quality, shirt.state, true); } if (vest != null) { clo.askWearVest(vest.id, vest.quality, vest.state, true); } if (backpack != null) { clo.askWearBackpack(backpack.id, backpack.quality, backpack.state, true); } if (pants != null) { clo.askWearPants(pants.id, pants.quality, pants.state, true); } #endregion clothing #region items for (int i = 0; i < Inventory.items.Count; i++) { LItem item = Inventory.items[i]; Item item2 = new Item(item.ID, true) { metadata = item.Meta }; Player.Inventory.tryAddItem(item2, true); } #endregion items UnturnedChat.Say(Player, Instance.Translate("auto_loaded")); } else { UnturnedChat.Say(Player, Instance.Translate("no_default")); } } }
public void Execute(IRocketPlayer caller, string[] command) { #region vars if (command.Length != 1) { UnturnedChat.Say(caller, Syntax); return; } UnturnedPlayer player = (UnturnedPlayer)caller; CSteamID id = player.CSteamID; List <LoadoutItem> itemList = new List <LoadoutItem>(); PlayerClothing clo = player.Player.clothing; #endregion vars #region items for (byte p = 0; p < PlayerInventory.PAGES - 1; p++) { for (byte i = 0; i < player.Inventory.getItemCount(p); i++) { Item item = player.Inventory.getItem(p, i).item; itemList.Add(new LoadoutItem(item.id, item.metadata)); } } #endregion items #region clothing LoadoutHat hat = new LoadoutHat(clo.hat, clo.hatQuality, clo.hatState); LoadoutGlasses glasses = new LoadoutGlasses(clo.glasses, clo.glassesQuality, clo.glassesState); LoadoutMask mask = new LoadoutMask(clo.mask, clo.maskQuality, clo.maskState); LoadoutShirt shirt = new LoadoutShirt(clo.shirt, clo.shirtQuality, clo.shirtState); LoadoutVest vest = new LoadoutVest(clo.vest, clo.vestQuality, clo.vestState); LoadoutBackpack backpack = new LoadoutBackpack(clo.backpack, clo.backpackQuality, clo.backpackState); LoadoutPants pants = new LoadoutPants(clo.pants, clo.pantsQuality, clo.pantsState); LoadoutClothes clothes = new LoadoutClothes(hat, glasses, mask, shirt, vest, backpack, pants); #endregion clothing #region dictionary if (!Loadout.Instance.playerInvs.ContainsKey(id)) { Loadout.Instance.playerInvs.Add(id, new LoadoutList(new Dictionary <string, LoadoutInventory>())); Loadout.Instance.playerInvs[player.CSteamID]._invs.Add(command[0], new LoadoutInventory(itemList, clothes)); UnturnedChat.Say(caller, Loadout.Instance.Translate("saved")); } else { if (!Loadout.Instance.playerInvs[id]._invs.ContainsKey(command[0])) { Loadout.Instance.playerInvs[player.CSteamID]._invs.Add(command[0], new LoadoutInventory(itemList, clothes)); UnturnedChat.Say(caller, Loadout.Instance.Translate("saved")); } else { Loadout.Instance.playerInvs[id]._invs.Remove(command[0]); Loadout.Instance.playerInvs[player.CSteamID]._invs.Add(command[0], new LoadoutInventory(itemList, clothes)); UnturnedChat.Say(caller, Loadout.Instance.Translate("replaced")); } } #endregion dictionary }
public void Execute(IRocketPlayer caller, string[] command) { UnturnedPlayer player = (UnturnedPlayer)caller; if (command.Length != 1) { UnturnedChat.Say(caller, Syntax); return; } if (!Loadout.Instance.playerInvs[player.CSteamID]._invs.ContainsKey(command[0])) { UnturnedChat.Say(player, Loadout.Instance.Translate("no_kit")); return; } #region clothing PlayerClothing clo = player.Player.clothing; LoadoutClothes clothes = Loadout.Instance.playerInvs[player.CSteamID]._invs[command[0]].clothes; LoadoutHat hat = clothes.hat; LoadoutGlasses glasses = clothes.glasses; LoadoutMask mask = clothes.mask; LoadoutShirt shirt = clothes.shirt; LoadoutVest vest = clothes.vest; LoadoutBackpack backpack = clothes.backpack; LoadoutPants pants = clothes.pants; if (hat != null) { clo.askWearHat(hat.id, hat.quality, hat.state, true); } if (glasses != null) { clo.askWearGlasses(glasses.id, glasses.quality, glasses.state, true); } if (mask != null) { clo.askWearMask(mask.id, mask.quality, mask.state, true); } if (shirt != null) { clo.askWearShirt(shirt.id, shirt.quality, shirt.state, true); } if (vest != null) { clo.askWearVest(vest.id, vest.quality, vest.state, true); } if (backpack != null) { clo.askWearBackpack(backpack.id, backpack.quality, backpack.state, true); } if (pants != null) { clo.askWearPants(pants.id, pants.quality, pants.state, true); } #endregion clothing #region items for (int i = 0; i < Loadout.Instance.playerInvs[player.CSteamID]._invs[command[0]].items.Count; i++) { LoadoutItem item = Loadout.Instance.playerInvs[player.CSteamID]._invs[command[0]].items[i]; Item item2 = new Item(item.id, true) { metadata = item.meta }; player.Inventory.tryAddItem(item2, true); } #endregion items UnturnedChat.Say(caller, Loadout.Instance.Translate("loaded")); }
public static void ClearInventory(this Player player) { Items[] items = player.inventory.items; for (byte b = 0; b < PlayerInventory.PAGES - 2; b++) { if (items[b]?.items?.Count == 0) { continue; } items[b].ReverseClear(); if (b < PlayerInventory.SLOTS) { player.equipment.sendSlot(b); } } PlayerClothing clothing = player.clothing; HumanClothes clothes = clothing.thirdClothes; // I like sendSwap better but it can only be receieved from owner I think // I also really hate everything past this point if (clothing.backpack != 0) { clothes.backpack = 0; clothing.askWearBackpack(0, 0, PlaceholderArray, true); } if (clothing.glasses != 0) { clothes.glasses = 0; clothing.askWearGlasses(0, 0, PlaceholderArray, true); } if (clothing.hat != 0) { clothes.hat = 0; clothing.askWearHat(0, 0, PlaceholderArray, true); } if (clothing.mask != 0) { clothes.mask = 0; clothing.askWearMask(0, 0, PlaceholderArray, true); } if (clothing.pants != 0) { clothes.pants = 0; clothing.askWearPants(0, 0, PlaceholderArray, true); } if (clothing.shirt != 0) { clothes.shirt = 0; clothing.askWearShirt(0, 0, PlaceholderArray, true); } if (clothing.vest != 0) { clothes.vest = 0; clothing.askWearVest(0, 0, PlaceholderArray, true); } }
public void Execute(IRocketPlayer caller, string[] command) { UnturnedPlayer player = (UnturnedPlayer)caller; if (command.Length != 1) { UnturnedChat.Say(caller, Syntax); return; } if (command[0].ToUpperInvariant() == "AUTO") { if (Loadout.Instance.Autos.Contains(player.CSteamID.m_SteamID)) { Loadout.Instance.Autos.Remove(player.CSteamID.m_SteamID); UnturnedChat.Say(player, "Auto loading toggled off."); return; } else { Loadout.Instance.Autos.Add(player.CSteamID.m_SteamID); UnturnedChat.Say(player, "Auto loading toggled on."); return; } } if (!Loadout.Instance.playerInvs[player.CSteamID.m_SteamID].inventories.ContainsKey(command[0])) { UnturnedChat.Say(player, Loadout.Instance.Translate("no_kit")); return; } #region clothing PlayerClothing clo = player.Player.clothing; LoadoutClothes clothes = Loadout.Instance.playerInvs[player.CSteamID.m_SteamID].inventories[command[0]].clothes; LoadoutClothing hat = clothes.hat; LoadoutClothing glasses = clothes.glasses; LoadoutClothing mask = clothes.mask; LoadoutClothing shirt = clothes.shirt; LoadoutClothing vest = clothes.vest; LoadoutClothing backpack = clothes.backpack; LoadoutClothing pants = clothes.pants; if (hat != null) { clo.askWearHat(hat.id, hat.quality, hat.state, true); } if (glasses != null) { clo.askWearGlasses(glasses.id, glasses.quality, glasses.state, true); } if (mask != null) { clo.askWearMask(mask.id, mask.quality, mask.state, true); } if (shirt != null) { clo.askWearShirt(shirt.id, shirt.quality, shirt.state, true); } if (vest != null) { clo.askWearVest(vest.id, vest.quality, vest.state, true); } if (backpack != null) { clo.askWearBackpack(backpack.id, backpack.quality, backpack.state, true); } if (pants != null) { clo.askWearPants(pants.id, pants.quality, pants.state, true); } #endregion clothing #region items for (int i = 0; i < Loadout.Instance.playerInvs[player.CSteamID.m_SteamID].inventories[command[0]].items.Count; i++) { LItem item = Loadout.Instance.playerInvs[player.CSteamID.m_SteamID].inventories[command[0]].items[i]; Item item2 = new Item(item.ID, true) { metadata = item.Meta }; player.Inventory.tryAddItem(item2, true); } #endregion items UnturnedChat.Say(caller, Loadout.Instance.Translate("loaded")); }