/// <summary> /// Adds all the original vanilla items. /// </summary> internal static void FillVanilla() { for (int i = -24 /* some phasesabre */; i < ItemID.Count; i++) { //if (i > -19 /* phasesabres stop at -19 because Redigit */ && i <= 0) // copper etc items, using <=1.2-style netids instead of the new types (backwards compatibility needed for terraria code that still uses those netids) if (i == 0) continue; Item it = new Item(); it.netDefaults(i); ItemDef def = new ItemDef(Lang.itemName(it.type, true)); def.InternalName = it.name; def.Type = it.type; def.NetID = i; CopyItemToDef(def, it); DefFromType.Add(i, def); // TODO Fix overlapping names //VanillaDefFromName.Add(it.name, def); } Recipes.AddVanillaRecipeReferences(); }
private void SetItemCount(int numItems) { if (numItems < this.allItems.Count) { this.allItems.RemoveRange(numItems, this.allItems.Count - numItems); } else { for (int i = this.allItems.Count; i < numItems; i++) { string[] strArray = new string[] { "Ba", "Po", "Re", "Zu", "Meh", "Ra'", "B'k", "Adam", "Ben", "George" }; string[] strArray2 = new string[] { "Hoopler", "Hysleria", "Yeinydd", "Nekmit", "Novanoid", "Toog1t", "Yboiveth", "Resaix", "Voquev", "Yimello", "Oleald", "Digikiki", "Nocobot", "Morath", "Toximble", "Rodrup", "Chillaid", "Brewtine", "Surogou", "Winooze", "Hendassa", "Ekcle", "Noelind", "Animepolis", "Tupress", "Jeren", "Yoffa", "Acaer" }; string str = string.Format("[{0}] {1} {2}", i, strArray[UnityEngine.Random.Range(0, strArray.Length)], strArray2[UnityEngine.Random.Range(0, strArray2.Length)]); Color color = (Color) new Color32((byte) UnityEngine.Random.Range(0xc0, 0xff), (byte) UnityEngine.Random.Range(0xc0, 0xff), (byte) UnityEngine.Random.Range(0xc0, 0xff), 0xff); ItemDef item = new ItemDef(); item.name = str; item.color = color; item.time = UnityEngine.Random.Range(10, 0x3e8); item.score = (item.time * UnityEngine.Random.Range(0, 30)) / 60; this.allItems.Add(item); } } this.UpdateListGraphics(); this.numItemsTextMesh.text = "COUNT: " + numItems.ToString(); }
public static void CreateRecipe(ItemDef requiredItem, int createItemId, int requiredStack = 1, int createStack = 1) { newRecipe.createItem.SetDefaults(requiredItem.Type); newRecipe.createItem.stack = createStack; newRecipe.requiredItem[0].SetDefaults(createItemId); newRecipe.requiredItem[0].stack = requiredStack; addRecipe(); }
//Parent must not be null public void Draw(string SpriteName) { switch (ItemType) { case ItemType.Jawbreaker: Sprite = Resources.Load(SpriteName, typeof(Sprite)) as Sprite; SpriteRenderer.sprite = Sprite; ItemDef = new ItemJawbreaker(this); break; } }
static StaticCharge() { itemDef = MoreItemsPlugin.AddItem( "Static Charge", ItemTier.Tier2, "StaticCharge", "Your critical strikes build up static charge to shock the next enemy to attack you.", "Gain <style=cIsDamage>5% critical chance</style>. <style=cIsDamage>Critical strikes</style> grant you a stack of <style=cIsDamage>static charge</style>. The next time you are attacked, <style=cIsUtility>shock</style> the attacker, dealing <style=cIsDamage>5% <style=cStack>(+5% per stack)</style> damage</style> for each stack of <style=cIsDamage>static charge</style>.", "I can feel a buzz in the air... Don't get to close to me... " ); }
/// <summary> /// Registers an item def to the item catalog /// </summary> /// <param name="itemDef">The item def you want to register.</param> public static void RegisterItem(ItemDef itemDef) { //Check if the SurvivorDef has already been registered. if (ItemDefDefinitions.Contains(itemDef)) { LogCore.LogE(itemDef + " has already been registered, please do not register the same ItemDef twice."); return; } //If not, add it to our SurvivorDefinitions ItemDefDefinitions.Add(itemDef); }
public Sundial() { { LanguageAPI.Add("SUNDIAL_ITEM_TOKEN", "Rechargable Quantum Core"); LanguageAPI.Add("SUNDIAL_ITEM_DESCRIPTION_TOKEN", "Chance to become elite upon interaction. +5% chance per stack."); LanguageAPI.Add("SUNDIAL_ITEM_PICKUP_TOKEN", "Chance to become elite upon interaction."); ItemTag[] tags = new ItemTag[2] { ItemTag.Utility, ItemTag.AIBlacklist }; var itemDef = new ItemDef { pickupModelPath = "Prefabs/PickupModels/PickupMystery", pickupIconPath = "Textures/MiscIcons/texMysteryIcon", pickupToken = "SUNDIAL_ITEM_PICKUP_TOKEN", nameToken = "SUNDIAL_ITEM_TOKEN", name = "WeirdSundial", descriptionToken = "SUNDIAL_ITEM_DESCRIPTION_TOKEN", tier = ItemTier.Tier2, tags = tags }; BuffDef solarBuffDef = new BuffDef { buffColor = new Color(235, 182, 92), buffIndex = BuffIndex.Count, canStack = false, eliteIndex = EliteIndex.None, iconPath = "Textures/BuffIcons/texbuffpulverizeicon", isDebuff = false, name = "SolarGain" }; solarBuff = BuffAPI.Add(new CustomBuff(solarBuffDef)); //solarBuff = ItemAPI.Add(new CustomBuff(solarbuff.name, solarbuff)); var prefab = Resources.Load <GameObject>("Prefabs/PickupModels/PickupMystery"); var rule = new ItemDisplayRule { ruleType = ItemDisplayRuleType.ParentedPrefab, followerPrefab = prefab, childName = "Chest", localScale = new Vector3(0f, 0, 0f), localAngles = new Vector3(0f, 0f, 0f), localPos = new Vector3(0, 0f, 0f) }; var item = new CustomItem(itemDef, new[] { rule }); itemIndex = ItemAPI.Add(item); }; }
public string GetItemCompFromDef(ItemDef item) { foreach (ItemDef.CraftingComponent component in item.craftingComponents) { // if recipe contains component version of item... if (ContainsComp(component.itemDefId)) { return(CompToID(component.itemDefId)); } } return(null); }
// Token: 0x060021B3 RID: 8627 RVA: 0x0009EE18 File Offset: 0x0009D018 public void SetItem(ItemIndex itemIndex) { ItemDef itemDef = ItemCatalog.GetItemDef(itemIndex); this.titleText.token = itemDef.nameToken; this.descriptionText.token = itemDef.pickupToken; if (itemDef.pickupIconPath != null) { this.iconImage.texture = Resources.Load <Texture>(itemDef.pickupIconPath); } this.titleTMP.color = ColorCatalog.GetColor(itemDef.colorIndex); }
// Token: 0x060026C5 RID: 9925 RVA: 0x000A909C File Offset: 0x000A729C public void AddSimplePickup(PickupIndex pickupIndex) { ItemIndex itemIndex = pickupIndex.itemIndex; EquipmentIndex equipmentIndex = pickupIndex.equipmentIndex; string token = null; if (itemIndex != ItemIndex.None) { ItemDef itemDef = ItemCatalog.GetItemDef(itemIndex); this.AddDescriptionPanel(Language.GetString(itemDef.descriptionToken)); token = itemDef.loreToken; ulong statValueULong = this.statSheet.GetStatValueULong(PerItemStatDef.totalCollected.FindStatDef(itemIndex)); ulong statValueULong2 = this.statSheet.GetStatValueULong(PerItemStatDef.highestCollected.FindStatDef(itemIndex)); string stringFormatted = Language.GetStringFormatted("GENERIC_PREFIX_FOUND", new object[] { statValueULong }); string stringFormatted2 = Language.GetStringFormatted("ITEM_PREFIX_STACKCOUNT", new object[] { statValueULong2 }); this.AddSimpleTextPanel(new string[] { stringFormatted, stringFormatted2 }); } else if (equipmentIndex != EquipmentIndex.None) { EquipmentDef equipmentDef = EquipmentCatalog.GetEquipmentDef(equipmentIndex); this.AddDescriptionPanel(Language.GetString(equipmentDef.descriptionToken)); token = equipmentDef.loreToken; string stringFormatted3 = Language.GetStringFormatted("EQUIPMENT_PREFIX_COOLDOWN", new object[] { equipmentDef.cooldown }); string stringFormatted4 = Language.GetStringFormatted("EQUIPMENT_PREFIX_TOTALTIMEHELD", new object[] { this.statSheet.GetStatDisplayValue(PerEquipmentStatDef.totalTimeHeld.FindStatDef(equipmentIndex)) }); string stringFormatted5 = Language.GetStringFormatted("EQUIPMENT_PREFIX_USECOUNT", new object[] { this.statSheet.GetStatDisplayValue(PerEquipmentStatDef.totalTimesFired.FindStatDef(equipmentIndex)) }); this.AddSimpleTextPanel(stringFormatted3); this.AddSimpleTextPanel(new string[] { stringFormatted4, stringFormatted5 }); } this.AddNotesPanel(Language.IsTokenInvalid(token) ? Language.GetString("EARLY_ACCESS_LORE") : Language.GetString(token)); }
public void GetItemInfo(int pos, ItemDef itemDef) { switch (pos) { case 0: itemDef.ID = "VisualMenuBar.SingleSymbolCmd"; itemDef.Group = false; break; case 1: itemDef.ID = "VisualMenuBar.DotDensitySymbolsCmd"; itemDef.Group = false; break; case 2: itemDef.ID = "VisualMenuBar.GraduatedSymbolsCmd"; itemDef.Group = false; break; case 3: itemDef.ID = "VisualMenuBar.ProportionalSymbolsCmd"; itemDef.Group = false; break; case 4: itemDef.ID = "VisualMenuBar.StatisticsSymbolsCmd"; itemDef.Group = false; break; case 5: itemDef.ID = "VisualMenuBar.UniqueValuesSymbolCmd"; itemDef.Group = false; break; case 6: itemDef.ID = "VisualMenuBar.ClassBreaksRendererSymbolCmd"; itemDef.Group = false; break; case 7: itemDef.ID = "VisualMenuBar.StatisticsSymbolsCmd"; itemDef.Group = false; break; case 8: itemDef.ID = "VisualMenuBar.SymbolizationByLayerPropPageCmd"; itemDef.Group = false; break; default: break; } }
public bool IsEquipped(ItemDef itemDef) { if (_dictItems.TryGetValue(itemDef, out bool isEquipped)) { return(isEquipped); } else { Debug.LogWarning("No item " + itemDef.name + "!"); } return(false); }
public int Compare(ItemIndex x, ItemIndex y) { ItemDef itemDefx = ItemCatalog.GetItemDef(x); ItemDef itemDefy = ItemCatalog.GetItemDef(y); int result = itemDefx.tier.CompareTo(itemDefy.tier); if (result == 0) { result = Language.GetString(itemDefx.nameToken).CompareTo(Language.GetString(itemDefy.nameToken)); } return(result); }
// Token: 0x06001CA5 RID: 7333 RVA: 0x0007A94C File Offset: 0x00078B4C public static void RegisterStatDefs() { foreach (PerItemStatDef perItemStatDef in PerItemStatDef.instancesList) { foreach (ItemIndex itemIndex in ItemCatalog.allItems) { ItemDef itemDef = ItemCatalog.GetItemDef(itemIndex); StatDef statDef = StatDef.Register(perItemStatDef.prefix + "." + itemDef.name, perItemStatDef.recordType, perItemStatDef.dataType, 0.0, null); perItemStatDef.keyToStatDef[(int)itemIndex] = statDef; } } }
public static void Init() { LanguageAPI.Add("GENETIC_EMPTY_TOKEN", "This is better than null I guess"); tokenDict = new Dictionary <GeneStat, Dictionary <GeneMod, ItemDef> >(); //GeneToken Items foreach (GeneStat stat in Enum.GetValues(typeof(GeneStat))) { tokenDict.Add(stat, new Dictionary <GeneMod, ItemDef>()); foreach (GeneMod mod in Enum.GetValues(typeof(GeneMod))) { ItemDef def = ScriptableObject.CreateInstance <ItemDef>(); def.name = "GENETOKEN_" + stat.ToString().ToUpper() + "_" + mod.ToString().ToUpper(); def.nameToken = "GENETIC_EMPTY_TOKEN"; def.pickupToken = "GENETIC_EMPTY_TOKEN"; def.descriptionToken = "GENETIC_EMPTY_TOKEN"; def.loreToken = "GENETIC_EMPTY_TOKEN"; def.pickupIconSprite = null; def.pickupModelPrefab = null; def.tags = new ItemTag[] { ItemTag.CannotCopy, ItemTag.CannotSteal }; def.tier = ItemTier.NoTier; def.hidden = true; def.canRemove = false; CustomItem item = new CustomItem(def, new ItemDisplayRuleDict()); ItemAPI.Add(item); //ContentAddition.AddItemDef(def); tokenDict[stat].Add(mod, def); } } //GeneBlocker Item blockerDef = ScriptableObject.CreateInstance <ItemDef>(); blockerDef.name = "GENETOKEN_BLOCKER"; blockerDef.nameToken = "GENETIC_EMPTY_TOKEN"; blockerDef.pickupToken = "GENETIC_EMPTY_TOKEN"; blockerDef.descriptionToken = "GENETIC_EMPTY_TOKEN"; blockerDef.loreToken = "GENETIC_EMPTY_TOKEN"; blockerDef.pickupIconSprite = null; blockerDef.pickupModelPrefab = null; blockerDef.tags = new ItemTag[] { ItemTag.CannotCopy, ItemTag.CannotSteal }; blockerDef.tier = ItemTier.NoTier; blockerDef.hidden = true; blockerDef.canRemove = false; CustomItem blockerItem = new CustomItem(blockerDef, new ItemDisplayRuleDict()); ItemAPI.Add(blockerItem); //ContentAddition.AddItemDef(blockerDef); }
private void SetAggressor(Transform a_aggressor) { if (m_on && null != m_client && !Global.isServer) { ItemDef itemDef = Items.GetItemDef(m_client.GetHandItem()); m_hp -= itemDef.damage; if (m_hp < 0f) { SolveMission(); } } }
// Token: 0x06002C6A RID: 11370 RVA: 0x000BB74C File Offset: 0x000B994C public override void OnEnter() { base.OnEnter(); this.duration = FindItem.baseDuration / this.attackSpeedStat; base.PlayCrossfade("Body", "SitRummage", "Sit.playbackRate", this.duration, 0.1f); Util.PlaySound(FindItem.sound, base.gameObject); if (base.isAuthority) { WeightedSelection <List <PickupIndex> > weightedSelection = new WeightedSelection <List <PickupIndex> >(8); weightedSelection.AddChoice((from v in Run.instance.availableTier1DropList where ItemCatalog.GetItemDef(v.itemIndex) != null && ItemCatalog.GetItemDef(v.itemIndex).DoesNotContainTag(ItemTag.AIBlacklist) select v).ToList <PickupIndex>(), FindItem.tier1Chance); weightedSelection.AddChoice((from v in Run.instance.availableTier2DropList where ItemCatalog.GetItemDef(v.itemIndex) != null && ItemCatalog.GetItemDef(v.itemIndex).DoesNotContainTag(ItemTag.AIBlacklist) select v).ToList <PickupIndex>(), FindItem.tier2Chance); weightedSelection.AddChoice((from v in Run.instance.availableTier3DropList where ItemCatalog.GetItemDef(v.itemIndex) != null && ItemCatalog.GetItemDef(v.itemIndex).DoesNotContainTag(ItemTag.AIBlacklist) select v).ToList <PickupIndex>(), FindItem.tier3Chance); List <PickupIndex> list = weightedSelection.Evaluate(UnityEngine.Random.value); this.dropPickup = list[UnityEngine.Random.Range(0, list.Count)]; PickupDef pickupDef = PickupCatalog.GetPickupDef(this.dropPickup); if (pickupDef != null) { ItemDef itemDef = ItemCatalog.GetItemDef(pickupDef.itemIndex); if (itemDef != null) { this.itemsToGrant = 0; switch (itemDef.tier) { case ItemTier.Tier1: this.itemsToGrant = FindItem.tier1Count; break; case ItemTier.Tier2: this.itemsToGrant = FindItem.tier2Count; break; case ItemTier.Tier3: this.itemsToGrant = FindItem.tier3Count; break; default: this.itemsToGrant = 1; break; } } } } Transform transform = base.FindModelChild("PickupDisplay"); this.pickupDisplay = transform.GetComponent <PickupDisplay>(); this.pickupDisplay.SetPickupIndex(this.dropPickup, false); }
public static float GetNewValue(int a_type) { float result = 1f; ItemDef itemDef = GetItemDef(a_type); if (IsEatable(a_type)) { result = 4f + Mathf.Abs(itemDef.healing) * 0.2f; } else if (IsResource(a_type)) { result = 0.4f; } else if (IsCraftable(a_type)) { result = (float)(itemDef.wood + itemDef.metal + itemDef.stone + itemDef.cloth) * 0.4f * (1f + (float)itemDef.rankReq * 0.5f); } else if (5f < itemDef.damage && 0f < itemDef.attackdur) { result = (itemDef.damage - 5f) / itemDef.attackdur * 3f + itemDef.range * 5f; } else if (IsRareAmmo(a_type)) { result = 5f; } else if (IsMedicine(a_type)) { result = 10f; switch (a_type) { case 143: result = 70f; break; case 140: result = 5f; break; } } else if (IsBody(a_type)) { result = (1f - itemDef.healing) * 500f; } else if (IsShoes(a_type)) { result = itemDef.healing * 2000f; } else if (a_type == 30) { result = 200f; } return(result); }
public IconCA(ItemDef itemDef, GenericNotification genericNotification, int size) { Sprite sprite = Resources.Load <Sprite>(itemDef.pickupIconPath); GameObject image = ImageOBJ("Commander_Image"); image.GetComponent <Image>().sprite = sprite; image.transform.SetParent(genericNotification.transform); image.transform.position = Vector3.zero; image.GetComponent <RectTransform>().sizeDelta = new Vector2(size, size); this.image = image; this.ItemDef = itemDef; }
/// <summary> /// Returns true if the item matches our filter parameters. /// </summary> /// <param name="item"></param> /// <returns></returns> private static bool FilterDefList(ItemDef item) { // Result is true if item is under the 'Independant' resource path and // one of the allowed slots exists in its slotbinds. bool result = item.ResourcePath.Contains("Independant") && item.RequiredSlotBinds.ToList().Exists( slotBind => allowedSlots.Contains( ((ItemSlotDef)slotBind.RequiredSlot).SlotName )); return(result); }
/// <summary> /// Converts any potential items to their corresponding starter item /// </summary> private void ConvertPotentialItems(Inventory inv, ItemIndex itemIndex, int count) { ItemDef starterItemToCompare = ItemFromTier(ItemCatalog.GetItemDef(itemIndex).tier); // If they are different items if (starterItemToCompare != null && starterItemToCompare.itemIndex != itemIndex) { int itemCount = inv.GetItemCount(itemIndex); inv.RemoveItem(itemIndex, itemCount); inv.GiveItem(starterItemToCompare, itemCount); } }
private bool PickupIsNonBlacklistedItem(PickupIndex pickupIndex) { PickupDef pickupDef = PickupCatalog.GetPickupDef(pickupIndex); if (pickupDef == null) { return(false); } ItemDef itemDef = ItemCatalog.GetItemDef(pickupDef.itemIndex); return(itemDef != null && itemDef.DoesNotContainTag(ItemTag.AIBlacklist)); }
protected bool TryGenerateVobDef(Dictionary <int, VobDef> vobDefByID, IDAndEffectIDs idAndEffectIDs, Dictionary <int, Effect> effectByID) { Effect effect; List <Effect> effects = new List <Effect>(); foreach (var effectID in idAndEffectIDs.EffectIDs) { if (effectByID.TryGetValue(effectID, out effect)) { if (ContainsUnresolvedDependencies(effect)) { return(false); } effects.Add(effect); } } VobType vobType; if (!TryFindVobDefType(effectByID, idAndEffectIDs.EffectIDs, out vobType)) { MakeLogError("Couldn't find VobDefType for VobDef of id: " + idAndEffectIDs.ID); } VobDef vobDef = null; switch (vobType) { case VobType.Vob: vobDef = new VobDef(); break; case VobType.Item: vobDef = new ItemDef(); break; case VobType.NPC: vobDef = new NPCDef(); break; default: MakeLogError("The VobType " + vobType + " is not supported by the loading process!"); return(false); } // get the effectHander and hand all effects to it vobDef.EffectHandler.AddEffects(effects, true); return(true); }
private bool IsInteracting() { bool flag = false; if (Input.GetButtonDown("Interact") && !m_isMoving) { for (int i = 0; i < m_repairNpcs.Length; i++) { Vector3 position = m_repairNpcs[i].transform.position; Vector3 pos = m_client.GetPos(); if (!(Mathf.Abs(position.x - pos.x) < 1.4f) || !(Mathf.Abs(position.z - pos.z) < 1.4f)) { continue; } RemoteItem handItem = m_inventory.GetHandItem(); if (null != handItem) { if (Items.HasCondition(handItem.m_type) && handItem.m_amountOrCond < 100) { ItemDef itemDef = Items.GetItemDef(handItem.m_type); int num = (int)(1f + Items.GetValue(handItem.m_type, 100) * 0.01f * (float)(100 - handItem.m_amountOrCond)); num = (int)((float)num * m_repairNpcs[i].m_priceMultip + 0.5f); if (m_client.GetGoldCount() >= num) { string a_caption = LNG.Get("REPAIR") + "\n" + LNG.Get(itemDef.ident) + "\n" + handItem.m_amountOrCond + "%\nfor " + num + " " + LNG.Get("CURRENCY") + "?"; m_repairPopupSessionId = m_popupGui.ShowGui(true, a_caption); } else { string a_caption2 = LNG.Get("ITEMSHOP_TOO_LESS_GOLD") + "\n" + num + " " + LNG.Get("CURRENCY"); m_popupGui.ShowGui(true, a_caption2); } } else { m_popupGui.ShowGui(true, LNG.Get("REPAIR_NPC_NO_NEED")); } } else { m_popupGui.ShowGui(true, LNG.Get("REPAIR_NPC_HOWTO")); } flag = true; break; } if (flag) { } } return((Input.GetButton("Interact") && !flag) || m_forceInteractionTime > Time.time); }
static List <string> DefaultBannedItemsList() { List <string> bannedItems = new List <string>(); bannedItems.Add("# Make sure each item id is on it's own line"); bannedItems.Add("# Do not paste item's full name, only paste the id provided below"); //Items bannedItems.Add("# --Items--"); bannedItems.Add("I13"); //Brilliant Behemoth bannedItems.Add("I85"); //N'kuhana's Opinion bannedItems.Add("I105"); //Unstable Tesla Coil bannedItems.Add("I112"); //Little Disciple bannedItems.Add("I122"); //Razorwire bannedItems.Add("I76"); //Strides of Heresy //Equipment bannedItems.Add("# --Equipments--"); bannedItems.Add("E39"); //Spinel Tonic bannedItems.Add("E29"); //Glowing Meteorite bannedItems.Add("E11"); //Helfire Tincture bannedItems.Add("E9"); //Preon Accumulator bannedItems.Add("E10"); //Primordial Cube bannedItems.Add("E27"); //Royal Capacitor bannedItems.Add("E13"); //Disposable Missile Launcher bannedItems.Add("E19"); //Volcanic Egg bannedItems.Add("E24"); //The Crowdfunder bannedItems.Add("E17"); //The Back-up bannedItems.Add("E16"); //Forgive Me Please //Output all item names bannedItems.Add("# -----------------------------------------------------------------------------------------"); bannedItems.Add("# List of item ids and it's full name"); bannedItems.Add("# -----------------------------------------------------------------------------------------"); List <ItemIndex> items = ItemCatalog.allItems.ToList(); for (int i = 0; i < items.Count; i++) { ItemDef itemDef = ItemCatalog.GetItemDef(items[i]); bannedItems.Add("# ID: I" + itemDef.itemIndex + " FullName: " + Language.GetString(itemDef.nameToken)); } //Output all equipment names bannedItems.Add("# -----------------------------------------------------------------------------------------"); bannedItems.Add("# List of equipment ids and it's full name"); bannedItems.Add("# -----------------------------------------------------------------------------------------"); List <EquipmentIndex> equipments = EquipmentCatalog.allEquipment.ToList(); for (int i = 0; i < equipments.Count; i++) { EquipmentDef equipmentDef = EquipmentCatalog.GetEquipmentDef(equipments[i]); bannedItems.Add("# ID: E" + equipmentDef.equipmentIndex + " FullName: " + Language.GetString(equipmentDef.nameToken)); } return(bannedItems); }
private void ChooseItem(int a_index) { if (a_index < 0 || m_craftableItems[m_activePage].Count <= a_index) { return; } m_selectedItem = a_index; int num = m_craftableItemTypes[m_activePage][m_selectedItem]; TextMesh txtItem = m_txtItem; ItemDef itemDef = m_craftableItems[m_activePage][m_selectedItem]; txtItem.text = LNG.Get(itemDef.ident); SetCraftAmount(1); if (null != m_itemForDisplay) { Object.Destroy(m_itemForDisplay); } GameObject gameObject = (GameObject)Resources.Load("items/item_" + num); if (null != gameObject) { m_itemForDisplay = (GameObject)Object.Instantiate(gameObject, m_itemDisplayParent.position, Quaternion.identity); m_itemForDisplay.transform.parent = m_itemDisplayParent; m_itemForDisplay.transform.localScale = Vector3.one * 2f; m_itemForDisplay.transform.localRotation = Quaternion.identity; Renderer[] componentsInChildren = m_itemForDisplay.GetComponentsInChildren <Renderer>(); Renderer[] array = componentsInChildren; foreach (Renderer renderer in array) { renderer.gameObject.layer = 17; } Transform transform = m_itemForDisplay.transform.FindChild("Particles"); if (null != transform) { transform.gameObject.SetActive(false); } Transform transform2 = m_itemForDisplay.transform.FindChild("Point light"); if (null != transform2) { transform2.gameObject.SetActive(false); } m_txtInfoStats.text = Items.GetStatsText(num, -1); ItemDef itemDef2 = Items.GetItemDef(num); if (itemDef2.ident != null && itemDef2.ident.Length > 0 && string.Empty == m_txtInfoStats.text) { m_txtInfoStats.text = LNG.Get(itemDef2.ident + "_DESC"); } } UpdateNeedHave(); }
public static int GetCountHighestFromPlayers(ItemDef itemDef, bool requiresAlive = false) { var playerTotal = PlayerCharacterMasterController.instances; int highestCount = 0; for (int i = 0; i < playerTotal.Count; i++) { if (playerTotal[i].master.inventory.GetItemCount(itemDef) > 0 && (!requiresAlive || !playerTotal[i].master.IsDeadAndOutOfLivesServer())) { highestCount = Mathf.Max(highestCount, playerTotal[i].master.inventory.GetItemCount(itemDef)); } } return(highestCount); }
//ItemDefs should be added by ItemAPI, but this method is here purely for completion sake. /// <summary> /// Adds an ItemDef to your Mod's ContentPack /// <para>ItemDefs should be added by ItemAPI's Add methods.</para> /// </summary> /// <param name="itemDef">The ItemDef to Add.</param> /// <returns>true if valid and added, false if one of the requirements is not met</returns> public static bool AddItemDef(ItemDef itemDef) { var asm = Assembly.GetCallingAssembly(); if (CatalogBlockers.GetAvailability <ItemDef>()) { R2API.Logger.LogInfo($"Assembly {asm.GetName().Name} is adding an {itemDef} via {nameof(ContentAddition)}.{nameof(AddItemDef)}()" + $"The assembly should ideally add them via {nameof(ItemAPI)} so that they can use ItemAPI's IDRS systems, adding anyways."); ItemAPI.AddInternal(new CustomItem(itemDef, Array.Empty <ItemDisplayRule>()), asm); return(true); } RejectContent(itemDef, asm, "ItemDef", "but the ItemCatalog has already initialized!"); return(false); }
//I sometimes think to myself, is there something as "too many methods?" public static int GetUniqueCountFromPlayers(ItemDef itemDef, bool requiresAlive = false) { var playerUnique = PlayerCharacterMasterController.instances; //Remove this and replace it with ANYTHING master, not just players. Add parameter for a teamindex int stackCount = 0; for (int i = 0; i < playerUnique.Count; i++) { if (playerUnique[i].master.inventory.GetItemCount(itemDef) > 0 && (!requiresAlive || !playerUnique[i].master.IsDeadAndOutOfLivesServer())) { stackCount++; } } return(stackCount); }
public static int GetCountFromPlayers(ItemDef itemDef, bool requiresAlive = false) { var playerTotal = PlayerCharacterMasterController.instances; //Remove this and replace it with ANYTHING master, not just players int totalCount = 0; for (int i = 0; i < playerTotal.Count; i++) { if (playerTotal[i].master.inventory.GetItemCount(itemDef) > 0 && (!requiresAlive || !playerTotal[i].master.IsDeadAndOutOfLivesServer())) { totalCount += playerTotal[i].master.inventory.GetItemCount(itemDef); } } return(totalCount); }
public void PickupItems() { if (!master.inventory) { return; } List <GenericPickupController> pickups = InstanceTracker.GetInstancesList <GenericPickupController>(); for (int i = 0; i < pickups.Count; i++) { GenericPickupController pickup = pickups[i]; // Skip lunar coins if (PickupCatalog.GetPickupDef(pickup.pickupIndex).coinValue > 0) { continue; } // Skip these ItemDef def = ItemCatalog.GetItemDef(PickupCatalog.GetPickupDef(pickup.pickupIndex).itemIndex); if (def != null && def.tier == ItemTier.Lunar) { continue; } EquipmentIndex equipmentIndex = PickupCatalog.GetPickupDef(pickup.pickupIndex).equipmentIndex; if (equipmentIndex != EquipmentIndex.None) { if (EquipmentCatalog.GetEquipmentDef(equipmentIndex).isLunar) { continue; } if (master.inventory.currentEquipmentIndex != EquipmentIndex.None) { continue; } } if (pickup.GetInteractability(this.bodyInteractor) == Interactability.Available) { // Move to pickup item if within 60 meters float dist = PlayerBotUtils.GetFastDist(master.GetBody().transform.position, pickup.gameObject.transform.position); if (dist <= (60f * 60f)) { this.ai.customTarget.gameObject = pickup.gameObject; return; } } } }
public static ItemLib.CustomItem HurtMePlenty() { ItemDef HurtMePlenty = new ItemDef { tier = ItemTier.Tier3, pickupModelPath = "", pickupIconPath = "", nameToken = name, pickupToken = "This pain will make me stronger.", descriptionToken = "At low health, go completely nutters." }; return(new ItemLib.CustomItem(HurtMePlenty, null, icon, _itemDisplayRules)); }
private void DamageItem(float a_x, float a_y) { DatabaseItem itemFromPos = m_inventory.GetItemFromPos(a_x, a_y); ItemDef itemDef = Items.GetItemDef(itemFromPos.type); if (!(0f < itemDef.durability) || !(1f > itemDef.durability) || !(Random.Range(0f, 1f) > itemDef.durability) || !m_inventory.DeclineItem(a_x, a_y)) { return; } m_updateContainersFlag = true; if (itemFromPos.amount != 1) { return; } m_updateInfoFlag = true; m_server.SendSpecialEvent(this, eSpecialEvent.itemBroke); if (0 < itemDef.wood) { int num = Random.Range(0, itemDef.wood); if (0 < num) { m_server.CreateFreeWorldItem(130, num, GetPosition()); } } if (0 < itemDef.metal) { int num2 = Random.Range(0, itemDef.metal); if (0 < num2) { m_server.CreateFreeWorldItem(131, num2, GetPosition()); } } if (0 < itemDef.stone) { int num3 = Random.Range(0, itemDef.stone); if (0 < num3) { m_server.CreateFreeWorldItem(132, num3, GetPosition()); } } if (0 < itemDef.cloth) { int num4 = Random.Range(0, itemDef.cloth); if (0 < num4) { m_server.CreateFreeWorldItem(133, num4, GetPosition()); } } }
public bool CanAcceptItemOfDef(ItemDef itemDef) { if (_filterIds.Any()) { foreach (var filter in GetItemFilters()) { if (!filter.CanAcceptItemOfDef(itemDef)) { return(false); } } } return(Config.CanReceiveItems); }
void ITocContextMenu.AddItem(object item, bool beginGroup, int subType) { try { object obj = item; ItemDef itemDef = new ItemDef(item.ToString(), beginGroup, subType); //obj = Activator.CreateInstance(Type.GetTypeFromProgID(itemDef.itemDef)); if (obj is Labelor) { ILabelView lb= GPropertiesView.CallMe; ((Labelor)obj).LabelView = lb; } m_toolbarMenu.AddItem(obj, subType, -1, beginGroup, esriCommandStyles.esriCommandStyleIconAndText); } catch (Exception ex) { System.Diagnostics.Trace.WriteLine(ex.Message); } }
// Populate the backing fields with some values void SetItemCount(int numItems) { if (numItems < allItems.Count) { allItems.RemoveRange(numItems, allItems.Count - numItems); } else { for (int j = allItems.Count; j < numItems; ++j) { string[] firstPart = { "Ba", "Po", "Re", "Zu", "Meh", "Ra'", "B'k", "Adam", "Ben", "George" }; string[] secondPart = { "Hoopler", "Hysleria", "Yeinydd", "Nekmit", "Novanoid", "Toog1t", "Yboiveth", "Resaix", "Voquev", "Yimello", "Oleald", "Digikiki", "Nocobot", "Morath", "Toximble", "Rodrup", "Chillaid", "Brewtine", "Surogou", "Winooze", "Hendassa", "Ekcle", "Noelind", "Animepolis", "Tupress", "Jeren", "Yoffa", "Acaer" }; string name = string.Format( "[{0}] {1} {2}", j, firstPart[Random.Range(0, firstPart.Length)], secondPart[Random.Range(0, secondPart.Length)] ); Color color = new Color32((byte)Random.Range(192, 255), (byte)Random.Range(192, 255), (byte)Random.Range(192, 255), 255); ItemDef item = new ItemDef(); item.name = name; item.color = color; item.time = Random.Range(10, 1000); item.score = (item.time * Random.Range(0, 30)) / 60; allItems.Add(item); } } UpdateListGraphics(); numItemsTextMesh.text = "COUNT: " + numItems.ToString(); }
static void LoadTextures(ItemDef def) { // def.GetTexture itself should be checked when it's loaded var t = def.GetTexture(); if (t == null) throw new ArgumentNullException("GetTexture return value is null for ItemDef " + def.InternalName + " from mod " + def.Mod + "."); Main.itemTexture[def.Type] = def.GetTexture(); var ad = def.ArmourData; if (ad.Helmet != null) { t = ad.Helmet(); if (t == null) throw new ArgumentNullException("ArmourData.Helmet return value is null for ItemDef " + def.InternalName + " from mod " + def.Mod + "."); int id = Main.armorHeadTexture.Length; Array.Resize(ref Main.armorHeadTexture, Main.armorHeadTexture.Length + 1); Array.Resize(ref Main.armorHeadLoaded, Main.armorHeadLoaded.Length + 1); Main.armorHeadLoaded[id] = true; Main.armorHeadTexture[id] = t; ad.headId = id; } if (ad.MaleBodyArmour != null) { t = ad.MaleBodyArmour(); if (t == null) throw new ArgumentNullException("ArmourData.MaleBodyArmour return value is null for ItemDef " + def.InternalName + " from mod " + def.Mod + "."); int id = Main.armorBodyTexture.Length; Array.Resize(ref Main.armorBodyTexture, Main.armorBodyTexture.Length + 1); Array.Resize(ref Main.armorBodyLoaded, Main.armorBodyLoaded.Length + 1); Main.armorBodyLoaded[id] = true; Main.armorBodyTexture[id] = t; ad.maleBodyId = id; t = ad.FemaleBodyArmour(); if (t == null) throw new ArgumentNullException("ArmourData.FemaleBodyArmour return value is null for ItemDef " + def.InternalName + " from mod " + def.Mod + "."); id = Main.femaleBodyTexture.Length; if (Main.femaleBodyTexture.Length <= id) Array.Resize(ref Main.femaleBodyTexture, id + 1); Main.femaleBodyTexture[id] = t; ad.femaleBodyId = id; } if (ad.Greaves != null) { t = ad.Greaves(); if (t == null) throw new ArgumentNullException("ArmourData.Greaves return value is null for ItemDef " + def.InternalName + " from mod " + def.Mod + "."); int id = Main.armorLegTexture.Length; Array.Resize(ref Main.armorLegTexture, Main.armorLegTexture.Length + 1); Array.Resize(ref Main.armorLegsLoaded, Main.armorLegsLoaded.Length + 1); Main.armorLegsLoaded[id] = true; Main.armorLegTexture[id] = t; ad.legsId = id; } }
// set properties aren't copied, type/netid is preserved static void CopyDefToItem(Item tar, ItemDef source) { tar.damage = source.Damage; tar.useAnimation = source.UseAnimation; tar.useTime = source.UseTime; tar.reuseDelay = source.ReuseDelay; tar.mana = source.ManaConsumption; tar.width = source.Width; tar.height = source.Height; tar.maxStack = source.MaxStack; tar.placeStyle = source.PlacementStyle; tar.alpha = source.Alpha; tar.defense = source.Defense; tar.crit = source.CritChanceModifier; tar.pick = source.PickaxePower; tar.axe = source.AxePower / 5; // f*****g red tar.hammer = source.HammerPower; tar.healLife = source.LifeHeal; tar.healMana = source.ManaHeal; tar.shootSpeed = source.ShootVelocity; tar.knockBack = source.Knockback; tar.scale = source.Scale; tar.noMelee = source.NoMelee; tar.consumable = source.IsConsumable; tar.useTurn = source.TurnPlayerOnUse; tar.autoReuse = source.AutoReuse; tar.noUseGraphic = source.HideUseGraphic; tar.accessory = source.IsAccessory; tar.expertOnly = source.IsExpertModeOnly; tar.channel = source.IsChanneled; tar.color = source.Colour; if (source.Rarity == ItemRarity.Amber) tar.questItem = true; else if (source.Rarity == ItemRarity.Rainbow) tar.expert = true; else tar.rare = (int)source.Rarity; tar.useStyle = (int)source.UseStyle; tar.holdStyle = (int)source.HoldStyle; switch (source.DamageType) { case DamageType.Melee: tar.melee = true; break; case DamageType.Ranged: tar.ranged = true; break; case DamageType.Magic: tar.magic = true; break; case DamageType.Minion: tar.summon = true; break; case DamageType.Thrown: tar.thrown = true; break; // None -> all false } tar.value = source.Value.Value; tar.vanity = source.Description.ShowVanity; tar.notAmmo = source.Description.HideAmmoFlag; tar.toolTip = source.Description.Description; tar.toolTip2 = source.Description.ExtraDescription; tar.buffTime = source.Buff.Duration; tar.buffType = source.Buff.Type; if (source.UsedAmmo != null) tar.useAmmo = source.UsedAmmo.Resolve().Type; tar.shoot = source.ShootProjectile; tar.ammo = source.AmmoType; tar.useSound = source.UseSound; tar.createTile = source.CreateTile; tar.createWall = source.CreateWall; tar.name = source.InternalName; Main.itemName[tar.type] = source.DisplayName; }
static void CopyItemToDef(ItemDef tar, Item source) { tar.Damage = source.damage; tar.UseAnimation = source.useAnimation; tar.UseTime = source.useTime; tar.ReuseDelay = source.reuseDelay; tar.ManaConsumption = source.mana; tar.Width = source.width; tar.Height = source.height; tar.MaxStack = source.maxStack; tar.PlacementStyle = source.placeStyle; tar.Alpha = source.alpha; tar.Defense = source.defense; tar.CritChanceModifier = source.crit; tar.PickaxePower = source.pick; tar.AxePower = source.axe * 5; // again, red, why did you do this? tar.HammerPower = source.hammer; tar.LifeHeal = source.healLife; tar.ManaHeal = source.healMana; tar.ShootVelocity = source.shootSpeed; tar.Knockback = source.knockBack; tar.Scale = source.scale; tar.NoMelee = source.noMelee; tar.IsConsumable = source.consumable; tar.TurnPlayerOnUse = source.useTurn; tar.AutoReuse = source.autoReuse; tar.HideUseGraphic = source.noUseGraphic; tar.IsAccessory = source.accessory; tar.IsExpertModeOnly = source.expertOnly; tar.IsChanneled = source.channel; tar.Colour = source.color; tar.Rarity = (ItemRarity)source.rare; if (source.questItem) tar.Rarity = ItemRarity.Amber; if (source.expert) tar.Rarity = ItemRarity.Rainbow; tar.UseStyle = (ItemUseStyle)source.useStyle; tar.HoldStyle = (ItemHoldStyle)source.holdStyle; tar.DamageType = DamageType.None; if (source.melee) tar.DamageType = DamageType.Melee; else if (source.ranged) tar.DamageType = DamageType.Ranged; else if (source.magic) tar.DamageType = DamageType.Magic; else if (source.summon) tar.DamageType = DamageType.Minion; else if (source.thrown) tar.DamageType = DamageType.Thrown; tar.Value = new CoinValue(source.value); tar.Description = new ItemDescription(source.toolTip, source.toolTip2, source.vanity, source.notAmmo); tar.Buff = new BuffDef(source.buffType, source.buffTime); if (source.useAmmo != 0) tar.UsedAmmo = new ItemRef(source.useAmmo); tar.ShootProjectile = source.shoot; tar.AmmoType = source.ammo; tar.UseSound = source.useSound; tar.CreateTile = source.createTile; tar.CreateWall = source.createWall; tar.GetTexture = () => Main.itemTexture[source.type]; tar.InternalName = source.name; tar.DisplayName = Main.itemName[source.type]; }
void IMapContextMenu.AddItem(object item, bool beginGroup, int subType) { try { object obj = item; if (item == null) { MessageBox.Show("line 114 MapContextMenu"); } ItemDef itemDef = new ItemDef(item.ToString(), beginGroup, subType); //obj = Activator.CreateInstance(Type.GetTypeFromProgID(itemDef.itemDef)); if (obj is XemTatCaVungGiaDaCongBo) { if (_keyName != null) { ((XemTatCaVungGiaDaCongBo)obj).SetKeyName(_keyName); } if (!(_lstView == null || _lstView.Count <= 0)) { foreach (LandpriceViewPair p in _lstView) { if (p.Key == "giadatcongbo") { //MessageBox.Show(p.View.Config.NamApDung.ToString()); ((XemTatCaVungGiaDaCongBo)obj).SetView(p.View); } } } } if (obj is XemTatCaVungGiaDaTinh) { if (_keyName != null) { ((XemTatCaVungGiaDaTinh)obj).SetKeyName(_keyName); } if (!(_lstView == null || _lstView.Count <= 0)) { foreach (LandpriceViewPair p in _lstView) { if (p.Key == "giadatdatinh") { //MessageBox.Show(p.View.Config.NamApDung.ToString()); ((XemTatCaVungGiaDaTinh)obj).SetView(p.View); } } } } if (obj is SetHesoVitri) { ((ICallerHskView)_editPosView).SetCalcMethodBuilderView(_calcMethodBuilderView); ((SetHesoVitri)obj).View = _editPosView; } m_toolbarMenu.AddItem(obj, subType, -1, beginGroup, esriCommandStyles.esriCommandStyleIconAndText); } catch (Exception ex) { System.Diagnostics.Trace.WriteLine(String.Format("line 111 MapContextMenu,ex when add item: \n{0}",ex.Message)); } }
static void LoadSetProperties(ItemDef def) { // assuming space is allocated in the ExtendArrays call Main.itemName[def.Type] = def.DisplayName; ItemID.Sets.AnimatesAsSoul[def.Type] = def.IsSoul; ItemID.Sets.ExoticPlantsForDyeTrade[def.Type] = def.IsStrangePlant; ItemID.Sets.gunProj[def.Type] = def.IsBullet; ItemID.Sets.ItemIconPulse[def.Type] = def.Pulses; ItemID.Sets.ItemNoGravity[def.Type] = def.NoGravity; ItemID.Sets.NebulaPickup[def.Type] = def.IsNebulaPickup; ItemID.Sets.NeverShiny[def.Type] = def.NeverShiny; ItemID.Sets.ExtractinatorMode[def.Type] = def.ExtractinatorMode; ItemID.Sets.StaffMinionSlotsRequired[def.Type] = def.RequiredStaffMinionSlots; }
private bool loadItem(ItemDef item) { bool result = false; try { txtID.Text = item.id; cboType.SelectedIndex = cboType.FindString(item.type.ToString()); loadUIRep(item.uirep); txtPrefab.Text = item.equipPrefabName; cboAnimType.SelectedIndex = cboAnimType.FindString(item.anim_type.ToString()); cboCoreAttribute.SelectedIndex = cboCoreAttribute.FindString(item.coreAttribute.ToString()); cboCoreSkill.SelectedIndex = cboCoreSkill.FindString(item.coreSkill.ToString()); cboCoreSpec.SelectedIndex = cboCoreSpec.FindString(item.coreSpecialization.ToString()); nudAmmo.Value = item.maxAmmo; nudAP.Value = item.apCost; StringBuilder prereqs = new StringBuilder(); foreach (string pr in item.prereqStrings) { prereqs.Append(String.Format("{0};", pr)); //not sure how this is delimited, leave as ; for now } txtPrereq.Text = prereqs.ToString(); nudHPDmg.Value = (decimal)item.baseHPDamage; nudAPDmg.Value = (decimal)item.baseAPDamage; //BindingList<float> bl = new BindingList<float>(item.rangeModTable); //dgRangeModTable.DataSource = bl; for (int i = 0; i <= item.rangeModTable.Count - 1; i++) //range mod table { dgRangeModTable.Rows.Add(1); dgRangeModTable[0, i].Value = i; dgRangeModTable[1, i].Value = item.rangeModTable[i]; } nudNoiseLvl.Value = (decimal)item.noiseLevel; nudNoiseRds.Value = item.noiseRounds; nudReload.Value = item.ammoReloadAPCost; for (int i = 0; i <= item.abilityModes.Count - 1; i++) //ability modes checked list { chklstAbilityModes.Items.Add(item.abilityModes[i]); //these aren't enumerated in ShadowrunDTO.dll anywhere, chklstAbilityModes.SetItemChecked(i, true); //need a way to add new ones (burst fire, full auto, etc) } nudPrice.Value = item.store_cost; chkAffectsEnemy.Checked = item.affectsEnemy; chkTargetActor.Checked = item.canTargetActor; txtSortingGroup.Text = item.sorting_group; if (item.equippedStatusEffects != null) { for (int i = 0; i <= item.equippedStatusEffects.statMods.Count - 1; i++) //equip status table { StatMod sm = item.equippedStatusEffects.statMods[i]; dgEquipStatus.Rows.Add(1); dgEquipStatus[0, i].Value = sm.attribute; dgEquipStatus[1, i].Value = sm.floatModValue; dgEquipStatus[2, i].Value = sm.intModValue; dgEquipStatus[3, i].Value = sm.skill; dgEquipStatus[4, i].Value = sm.specialization; } } else { dgEquipStatus.Rows.Add(1); //to add your own } result = true; } catch (Exception ex) { MessageBox.Show(String.Format("Error during load: {0}", ex.Message)); result = false; } return result; }
private ItemDef saveItem() { var item = new ItemDef(); item.id = txtID.Text; item.type = (ItemType)cboAnimType.SelectedItem; saveUIRep(item); item.equipPrefabName = txtPrefab.Text; item.anim_type = (AnimType)cboAnimType.SelectedItem; item.coreAttribute = (isogame.Attribute)cboCoreAttribute.SelectedItem; item.coreSkill = (Skill)cboCoreSkill.SelectedItem; item.coreSpecialization = (Specialization)cboCoreSpec.SelectedItem; item.maxAmmo = (int)nudAmmo.Value; item.apCost = (int)nudAP.Value; foreach (string prereq in txtPrereq.Text.Split(';')) { if (prereq.Length > 0) item.prereqStrings.Add(prereq); } item.baseHPDamage = (int)nudHPDmg.Value; item.baseAPDamage = (int)nudAPDmg.Value; foreach (DataGridViewRow mod in dgRangeModTable.Rows) { if (mod.Cells[1].Value != null) item.rangeModTable.Add((float)mod.Cells[1].Value); } item.noiseLevel = (int)nudNoiseLvl.Value; item.noiseRounds = (int)nudNoiseRds.Value; item.ammoReloadAPCost = (int)nudReload.Value; for (int i = 0; i < chklstAbilityModes.Items.Count; i++) { if (chklstAbilityModes.GetItemChecked(i)) { item.abilityModes.Add(chklstAbilityModes.Items[i].ToString()); } } item.store_cost = (int)nudPrice.Value; item.affectsEnemy = chkAffectsEnemy.Checked; item.canTargetActor = chkTargetActor.Checked; item.sorting_group = txtSortingGroup.Text; foreach (DataGridViewRow es in dgEquipStatus.Rows) { if (es.Cells[1].Value != null) //there is a better way to do this { StatMod sm = new StatMod(); sm.attribute = (isogame.Attribute)es.Cells[0].Value; sm.floatModValue = (float)es.Cells[1].Value; sm.intModValue = (int)es.Cells[2].Value; sm.skill = (Skill)es.Cells[3].Value; sm.specialization = (Specialization)es.Cells[4].Value; item.equippedStatusEffects.statMods.Add(sm); } } return item; }
private void saveUIRep(ItemDef item) { UIRep uirep = new UIRep(); uirep.name = txtName.Text; uirep.icon = txtIcon.Text; uirep.description = txtDescription.Text; item.uirep = uirep; }
static int ConsumeItem(ItemDef id, int stack) { var mp = Main.player[Main.myPlayer]; var inv = mp.inventory; Item item = null; for (int i = 0; i < Main.maxInventory && stack > 0; i++) { item = inv[i]; if (item.netID != id.NetID) continue; if (item.stack > stack) { item.stack -= stack; stack = 0; } else { stack -= item.stack; item.SetDefaults(0); item.stack = 0; } } if (mp.chest != -1) { if (mp.chest == -2) inv = mp.bank.item; else if (mp.chest == -3) inv = mp.bank2.item; else inv = Main.chest[mp.chest].item; for (int i = 0; i < Chest.maxItems && stack > 0; i++) { item = inv[i]; if (item.netID != id.NetID) continue; if (item.stack > stack) { item.stack -= stack; if (Main.netMode == 1 && mp.chest >= 0) NetMessage.SendData(MessageID.SyncChestItem, -1, -1, String.Empty, mp.chest, i, 0f, 0f, 0, 0, 0); stack = 0; } else { stack -= item.stack; item.SetDefaults(0); item.stack = 0; if (Main.netMode == 1 && mp.chest >= 0) NetMessage.SendData(MessageID.SyncChestItem, -1, -1, String.Empty, mp.chest, i, 0f, 0f, 0, 0, 0); } } } return stack; }