public void SetValue(XmlAttributeCollection inValue) { constructList.Add(new ItemConstruct()); // 构造函数 ItemConstruct construct = new ItemConstruct(new List<string>() { "System.String" }); construct.Struct.Statements.Add(Line("string[] ss", "inArg0.Split(\'^\')")); classer.CustomAttributes.Add(new CodeAttributeDeclaration("ProtoContract")); for (int i = 0; i < inValue.Count; i++) { fieldList.Add(new ItemField(inValue[i].Name, inValue[i].Value, MemberAttributes.Private)); ItemProperty item = new ItemProperty(inValue[i].Name); item.SetGetName(); item.SetSetName(); item.SetValueType(inValue[i].Value); item.SetModifier(MemberAttributes.Public | MemberAttributes.Final); item.SetField("ProtoMember", (i + 1).ToString()); propertyList.Add(item); Type t = Stringer.ToType(inValue[i].Value); string right = t == typeof(System.String) ? "ss[" + i + "]" : t == typeof(System.UInt32) ? "uint.Parse(ss[" + i + "])" : t == typeof(System.Single) ? "float.Parse(ss[" + i + "])" : "new " + t.ToString() + "(inValues[" + i + "])"; construct.Struct.Statements.Add(Line("_" + Stringer.FirstLetterLower(inValue[i].Name), right)); } constructList.Add(construct); Create(); }
public void OnAttack(ItemProperty itemProperty) { _playerBase.GetComponent<Animator>().Play("attack"); _actorBase = GetComponent<ActorBase> (); _animator = _actorBase.GetComponent<Animator>(); _animator.Play("attack"); attack (itemProperty); }
public static double GetDefaultValue(ItemProperty prop) { switch (prop) { case ItemProperty.Ancient: return 1; } return 0; }
private void AddProperty(object userData) { var data = (ItemProperty) userData; ItemProperty property = (ItemProperty)data.Clone(); property = new ItemProperty(property.PropertyName,property.PropertyValue); EditedItem.ItemProperties.Add(property); var index = EditedItem.ItemProperties.Count; }
public void SetNodeValue(XmlNode n) { for (int i = 0; i < n.Attributes.Count; i++) { string value = n.Attributes[i].Value; //AddField(n.Attributes[i].Name, value, MemberAttributes.Private); fieldList.Add(new ItemField(n.Attributes[i].Name, value, MemberAttributes.Private)); ItemProperty item = new ItemProperty(n.Attributes[i].Name); item.SetGetName(); item.SetValueType(value); item.SetModifier(MemberAttributes.Public | MemberAttributes.Final); propertyList.Add(item); CodeConditionStatement condition = new CodeConditionStatement(); condition.Condition = new CodeVariableReferenceExpression("inArg0.ContainsKey(\"" + n.Attributes[i].Name + "\")"); string parseLeft = ""; string parseRight = ""; if (Stringer.IsNumber(value)) { parseLeft = value.Contains(".") ? "float.Parse(" : "uint.Parse("; parseRight = ")"; } CodeVariableReferenceExpression right = new CodeVariableReferenceExpression(parseLeft + "inArg0[\"" + n.Attributes[i].Name + "\"]" + parseRight); CodePropertyReferenceExpression left = new CodePropertyReferenceExpression(new CodeThisReferenceExpression(), "_" + Stringer.FirstLetterLower(n.Attributes[i].Name)); if (Stringer.IsNumber(value)) { CodeConditionStatement numCondition = new CodeConditionStatement(); numCondition.Condition = new CodeVariableReferenceExpression("inArg0[\"" + n.Attributes[i].Name + "\"] == \"\""); numCondition.TrueStatements.Add(new CodeAssignStatement(left, new CodeVariableReferenceExpression("0"))); numCondition.FalseStatements.Add(new CodeAssignStatement(left, right)); condition.TrueStatements.Add(numCondition); } else { condition.TrueStatements.Add(new CodeAssignStatement(left, right)); } AddConditionStatement(condition); } Create(); }
/// <summary> /// Constructor. Deserializes the data from the specified file. /// </summary> /// <param name="filePath"></param> public ItemData(string filePath) { XmlItemSerialization.ItemData xmlData = XmlItemSerialization.ItemData.Deserialize(filePath); int numProperties = xmlData.Properties.Length; properties = new ItemProperty[numProperties]; for (int index = 0; index < numProperties; ++index) { properties[index] = new ItemProperty(xmlData.Properties[index]); } int numItems = xmlData.Items.Length; items = new Item[numItems]; for (int index = 0; index < numItems; ++index) { items[index] = new Item(properties, xmlData.Items[index]); } }
void attack(ItemProperty itemProperty) { GameObject projectile; Vector3 attackDirection = (_playerBase.PlayerMovement.goingLeft) ? Vector3.right : Vector3.left; switch (itemProperty.WeaponType) { // shot case 0: SoundManager.sharedManager.Play(SoundManager.sharedManager.projectile1); SpriteRenderer sr = _projectile.GetComponent<SpriteRenderer>(); sr.sprite = Resources.Load<Sprite>("Weapons/weapons_0" + itemProperty.ItemId); projectile = (GameObject) Instantiate(_projectile, GameObject.Find("muzzle").transform.position, Quaternion.identity); projectile.transform.constantForce.force = attackDirection * 100; projectile.transform.Translate( Vector3.forward ); break; // throw case 1: SoundManager.sharedManager.Play(SoundManager.sharedManager.projectile2); projectile = (GameObject) Instantiate(_projectile, GameObject.Find("muzzle").transform.position, Quaternion.identity); projectile.transform.constantForce.force = attackDirection * 50 + Vector3.up * 20; projectile.transform.Translate( Vector3.forward ); break; // flame thrower case 2: SoundManager.sharedManager.Play(SoundManager.sharedManager.projectile1); GameObject.Find("muzzle/fire_spray").GetComponent<ParticleSystem>(); GameObject.Find("muzzle/fire_spray").GetComponent<ParticleSystem>().Play(); break; // rocket launcher case 3: SoundManager.sharedManager.Play(SoundManager.sharedManager.projectile3); GameObject.Find("muzzle/rocket_launcher").GetComponent<ParticleSystem>().Play(); break; default: break; } }
public AttackableInfo(Item item, ItemProperty property, Item observer) : base(item, property, observer) { this.property = property as AttackableProperty; }
public CollidableInfo(Item item, ItemProperty property, Item observer) : base(item, property, observer) { this.property = property as CollidableProperty; }
private static bool EvaluateRule(CachedACDItem cItem, ItemProperty prop, double value, int variant, RuleType type = RuleType.Test) { var result = false; string friendlyVariant = string.Empty; double itemValue = 0; double ruleValue = 0; switch (prop) { case ItemProperty.Ancient: itemValue = cItem.IsAncient ? 1 : 0; ruleValue = value; result = cItem.IsAncient == (value == 1); break; case ItemProperty.PrimaryStat: itemValue = ItemDataUtils.GetMainStatValue(cItem.AcdItem); ruleValue = value; result = itemValue >= ruleValue; break; case ItemProperty.CriticalHitChance: itemValue = cItem.CritPercent; ruleValue = value; result = itemValue >= ruleValue; break; case ItemProperty.CriticalHitDamage: itemValue = cItem.CritDamagePercent; ruleValue = value; result = itemValue >= ruleValue; break; case ItemProperty.AttackSpeed: itemValue = ItemDataUtils.GetAttackSpeed(cItem.AcdItem); ruleValue = value; result = itemValue >= ruleValue; break; case ItemProperty.ResourceCost: itemValue = Math.Round(cItem.AcdItem.Stats.ResourceCostReductionPercent, MidpointRounding.AwayFromZero); ruleValue = value; result = itemValue >= ruleValue; break; case ItemProperty.Cooldown: itemValue = Math.Round(cItem.AcdItem.Stats.PowerCooldownReductionPercent, MidpointRounding.AwayFromZero); ruleValue = value; result = itemValue >= ruleValue; break; case ItemProperty.ResistAll: itemValue = cItem.AcdItem.Stats.ResistAll; ruleValue = value; result = itemValue >= ruleValue; break; case ItemProperty.Sockets: itemValue = cItem.AcdItem.Stats.Sockets; ruleValue = value; result = itemValue >= ruleValue; break; case ItemProperty.Vitality: itemValue = cItem.AcdItem.Stats.Vitality; ruleValue = value; result = itemValue >= ruleValue; break; case ItemProperty.AreaDamage: itemValue = cItem.AcdItem.Stats.OnHitAreaDamageProcChance; ruleValue = value; result = itemValue >= ruleValue; break; case ItemProperty.FireSkills: itemValue = cItem.AcdItem.Stats.FireSkillDamagePercentBonus; ruleValue = value; result = itemValue >= ruleValue; break; case ItemProperty.ColdSkills: itemValue = cItem.AcdItem.Stats.ColdSkillDamagePercentBonus; ruleValue = value; result = itemValue >= ruleValue; break; case ItemProperty.LightningSkills: itemValue = cItem.AcdItem.Stats.LightningSkillDamagePercentBonus; ruleValue = value; result = itemValue >= ruleValue; break; case ItemProperty.ArcaneSkills: itemValue = cItem.AcdItem.Stats.ArcaneSkillDamagePercentBonus; ruleValue = value; result = itemValue >= ruleValue; break; case ItemProperty.HolySkills: itemValue = cItem.AcdItem.Stats.HolySkillDamagePercentBonus; ruleValue = value; result = itemValue >= ruleValue; break; case ItemProperty.PoisonSkills: itemValue = cItem.AcdItem.Stats.PosionSkillDamagePercentBonus; ruleValue = value; result = itemValue >= ruleValue; break; case ItemProperty.PhysicalSkills: itemValue = cItem.AcdItem.Stats.PhysicalSkillDamagePercentBonus; ruleValue = value; result = itemValue >= ruleValue; break; case ItemProperty.DamageAgainstElites: itemValue = Math.Round(cItem.AcdItem.Stats.DamagePercentBonusVsElites, MidpointRounding.AwayFromZero); ruleValue = value; result = itemValue >= ruleValue; break; case ItemProperty.DamageFromElites: itemValue = Math.Round(cItem.AcdItem.Stats.DamagePercentReductionFromElites, MidpointRounding.AwayFromZero); ruleValue = value; result = itemValue >= ruleValue; break; case ItemProperty.BaseMaxDamage: itemValue = ItemDataUtils.GetMaxBaseDamage(cItem.AcdItem); ruleValue = value; result = itemValue >= ruleValue; break; case ItemProperty.SkillDamage: var skillId = variant; var skill = ItemDataUtils.GetSkillsForItemType(cItem.TrinityItemType, Trinity.Player.ActorClass).FirstOrDefault(s => s.Id == skillId); if (skill != null) { friendlyVariant = skill.Name; itemValue = cItem.AcdItem.SkillDamagePercent(skill.SNOPower); } ruleValue = value; result = itemValue >= ruleValue; break; case ItemProperty.ElementalDamage: var elementId = variant; var element = (Element)elementId; if (element != Element.Unknown) { friendlyVariant = ((EnumValue<Element>)element).Name; itemValue = Math.Round(ItemDataUtils.GetElementalDamage(cItem.AcdItem, element), MidpointRounding.AwayFromZero); } ruleValue = value; result = itemValue >= ruleValue; break; case ItemProperty.PercentDamage: itemValue = Math.Round(cItem.AcdItem.WeaponDamagePercent(), MidpointRounding.AwayFromZero); ruleValue = value; result = itemValue >= ruleValue; break; case ItemProperty.CriticalHitsGrantArcane: itemValue = Math.Round(cItem.ArcaneOnCrit, MidpointRounding.AwayFromZero); ruleValue = value; result = itemValue >= ruleValue; break; case ItemProperty.Armor: itemValue = Math.Round(cItem.Armor, MidpointRounding.AwayFromZero); ruleValue = value; result = itemValue >= ruleValue; break; case ItemProperty.ChanceToBlock: itemValue = Math.Round(cItem.BlockChance, MidpointRounding.AwayFromZero); ruleValue = value; result = itemValue >= ruleValue; break; case ItemProperty.HatredRegen: itemValue = Math.Round(cItem.HatredRegen, MidpointRounding.AwayFromZero); ruleValue = value; result = itemValue >= ruleValue; break; case ItemProperty.LifePercent: itemValue = Math.Round(cItem.LifePercent, MidpointRounding.AwayFromZero); ruleValue = value; result = itemValue >= ruleValue; break; case ItemProperty.LifePerHit: itemValue = Math.Round(cItem.LifeOnHit, MidpointRounding.AwayFromZero); ruleValue = value; result = itemValue >= ruleValue; break; case ItemProperty.RegenerateLifePerSecond: itemValue = Math.Round(cItem.AcdItem.Stats.HealthPerSecond, MidpointRounding.AwayFromZero); ruleValue = value; result = itemValue >= ruleValue; break; case ItemProperty.ManaRegen: itemValue = Math.Round(cItem.AcdItem.Stats.ManaRegen, MidpointRounding.AwayFromZero); ruleValue = value; result = itemValue >= ruleValue; break; case ItemProperty.MovementSpeed: itemValue = Math.Round(cItem.AcdItem.Stats.MovementSpeed, MidpointRounding.AwayFromZero); ruleValue = value; result = itemValue >= ruleValue; break; case ItemProperty.SpiritRegen: itemValue = Math.Round(cItem.AcdItem.Stats.SpiritRegen, MidpointRounding.AwayFromZero); ruleValue = value; result = itemValue >= ruleValue; break; case ItemProperty.WrathRegen: itemValue = Math.Round((double)cItem.AcdItem.GetAttribute<float>(ActorAttributeType.ResourceRegenPerSecondFaith), MidpointRounding.AwayFromZero); ruleValue = value; result = itemValue >= ruleValue; break; case ItemProperty.LifePerFury: itemValue = Math.Round((double)cItem.AcdItem.GetAttribute<float>(ActorAttributeType.SpendingResourceHealsPercentFury), MidpointRounding.AwayFromZero); ruleValue = value; result = itemValue >= ruleValue; break; case ItemProperty.LifePerSpirit: itemValue = Math.Round((double)cItem.AcdItem.GetAttribute<float>(ActorAttributeType.SpendingResourceHealsPercentSpirit), MidpointRounding.AwayFromZero); ruleValue = value; result = itemValue >= ruleValue; break; case ItemProperty.LifePerWrath: itemValue = Math.Round((double)cItem.AcdItem.GetAttribute<float>(ActorAttributeType.SpendingResourceHealsPercentFaith), MidpointRounding.AwayFromZero); ruleValue = value; result = itemValue >= ruleValue; break; } Logger.LogVerbose(" >> Evaluated {0} -- {1} {5} Type={6} (Item: {2} -v- Rule: {3}) = {4}", cItem.RealName, prop.ToString().AddSpacesToSentence(), itemValue, ruleValue, result, friendlyVariant, type); return result; }
public LRule(ItemProperty prop) { Id = (int) prop; Value = GetDefaultValue(prop); }
public GeoScannerModule(CategoryFlags ammoCategoryFlags, Scanner.Factory scannerFactory) : base(ammoCategoryFlags) { _scannerFactory = scannerFactory; _miningProbeAccuracy = new MiningProbeAccuracy(this); AddProperty(_miningProbeAccuracy); }
void updateProperty(ItemProperty pro, EquipmentItem item) { pro.guid = item.guid; pro.setNum(item.haveNum); pro.templateID = item.templateID; pro.setIcon(item.icon); pro.type = item.type; }
/// <summary> /// <para>0: 字段名</para> /// <para>1: a+i+0 指明类型及是否为Key值</para> /// <para>2: 注释</para> /// </summary> /// <param name="inList">0: 字段名</param> public void SetValue(List<string[]> inList) { ItemMethod mi = new ItemMethod("Set", MemberAttributes.Final | MemberAttributes.Public, new List<string>(){"List<string>"}); classer.CustomAttributes.Add(new CodeAttributeDeclaration("ProtoContract")); List<string> keyList = new List<string>();// key 值 for (int i = 0; i < inList.Count; i++) { string[] ss = inList[i][1].Split('+'); string typeString = ss[1]; CustumType ct = Stringer.StrToEnum<CustumType>(typeString, CustumType.None); if (ct != CustumType.None) // 基本类型或自定义类型 { //AddField(inList[i][0], inList[i][1], MemberAttributes.Private); fieldList.Add(new ItemField(inList[i][0], inList[i][1], MemberAttributes.Private)); ItemProperty item = new ItemProperty(inList[i][0]); item.SetGetName(); item.SetSetName(); item.SetComment(inList[i][2]); item.SetValueType(inList[i][1]); item.SetModifier(MemberAttributes.Public | MemberAttributes.Final); item.SetField("ProtoMember", (i + 1).ToString()); propertyList.Add(item); if (ss[2] == "1")// 如果该属性是类的Key值,则加入列表 { keyList.Add(inList[i][0]); } Type vType = Stringer.ToType(inList[i][1]); string left = "_" + Stringer.FirstLetterLower(inList[i][0]); CodeVariableReferenceExpression right = new CodeVariableReferenceExpression(); if (vType == typeof(System.String)) { right.VariableName = "inArg0[" + i + "]"; } else if (vType == typeof(System.UInt32)) { right.VariableName = "uint.Parse(inArg0[" + i + "])"; } else if (vType == typeof(System.Single)) { right.VariableName = "float.Parse(inArg0[" + i + "])"; } else { right.VariableName = "new " + vType.ToString() + "(inArg0[" + i + "])"; } CodeAssignStatement ass = new CodeAssignStatement(new CodeVariableReferenceExpression(left), right); mi.Method.Statements.Add(ass); } else // 从属表 { string subclassname = Stringer.FirstLetterUp(typeString); ItemMethod mis = new ItemMethod("Get" + subclassname, MemberAttributes.Final | MemberAttributes.Public, new List<string>() { "System.String" , "PBData"}); SetComment("获取" + inList[i][2], mis.Method); mis.Method.ReturnType = new CodeTypeReference(subclassname); mis.Method.Statements.Add(new CodeMethodReturnStatement(new CodeArgumentReferenceExpression("inArg1." + subclassname + "Dic[this.key + \"_\" + inArg0]"))); methodList.Add(mis); } } // Key 属性 ItemProperty keyPropertyItem = new ItemProperty("key"); if (keyList.Count == 1) { keyPropertyItem.SetGetName(keyList[0] + ".ToString()"); } else if (keyList.Count == 2) { keyPropertyItem.SetGetName(keyList[0] + ".ToString() + \"_\" +" + keyList[1] + ".ToString()"); } else if (keyList.Count == 3) { keyPropertyItem.SetGetName(keyList[0] + ".ToString() + \"_\" +" + keyList[1] + ".ToString() + \"_\" +" + keyList[2] + ".ToString()"); } keyPropertyItem.SetValueType(); keyPropertyItem.SetModifier(MemberAttributes.Public | MemberAttributes.Final); keyPropertyItem.SetComment("类的Key值"); propertyList.Add(keyPropertyItem); methodList.Add(mi); Create(); }
set => SetValue(ItemProperty, value);
void OnGUI() { if (_serializedObject != null) { if (_database.ItemList == null) { _database.ItemList = new List<Item>(); } GUILayout.Space(15); GUILayout.BeginHorizontal(); toolbarIndex = GUILayout.Toolbar(toolbarIndex, toolbarStrings); GUILayout.EndHorizontal(); //Items EditorUtility.SetDirty(_database); if (toolbarIndex == 0) { ReinitializeDatabase(); ReinitializeProperties(); GUILayout.Space(20); GUILayout.BeginHorizontal(); GUILayout.BeginVertical("Box", GUILayout.Width(350)); if (GUILayout.Button("Create New Item")) { Item newItem = new Item("New Item " + _database.ItemList.Count.ToString(), "Sample Description"); EditedItem = newItem; _database.ItemList.Add(newItem); ReinitializeDatabase(); } GUILayout.BeginVertical("Box", GUILayout.Height(650)); itemListVector = GUILayout.BeginScrollView(itemListVector, GUILayout.Height(650)); foreach (Item item in _database.ItemList) { GUILayout.Space(5); if (GUILayout.Button(item.Name)) { EditedItem = item; EditorGUI.FocusTextInControl(null); } } GUILayout.EndScrollView(); GUILayout.EndVertical(); GUILayout.EndVertical(); if (EditedItem != null) { if (ItemPropertyList == null || !ItemPropertyList.list.Equals(EditedItem.ItemProperties)) { if (_database.ItemList.Count > 0) { if (EditedItem.ItemProperties != null) { ItemPropertyList = new ReorderableList(EditedItem.ItemProperties, typeof (ItemProperty)); ItemPropertyList.drawElementCallback = (Rect rect, int index, bool active, bool focused) => { ItemProperty property = EditedItem.ItemProperties[index]; rect.y += 2; EditorGUI.LabelField( new Rect(rect.x + 25, rect.y, 150, EditorGUIUtility.singleLineHeight),property.PropertyName); property.PropertyValue = EditorGUI.TextField(new Rect(rect.x + 250, rect.y, 150, EditorGUIUtility.singleLineHeight), property.PropertyValue); }; ItemPropertyList.drawHeaderCallback = (Rect rect) => { EditorGUI.LabelField(new Rect(rect.x + 25, rect.y, rect.width, rect.height), "Name"); EditorGUI.LabelField(new Rect(rect.x + 250, rect.y, rect.width, rect.height), "Value"); }; //ItemPropertyList.onAddCallback = (ReorderableList l) => //{ // var index = EditedItem.ItemProperties.Count; // ItemProperty property = new ItemProperty(); // EditedItem.ItemProperties.Add(property); // property = EditedItem.ItemProperties[index]; // property.PropertyName = property.GetExisting(PropertyStrings); // property.PropertyValue = // _database.GetByNameProperty(property.PropertyName).PropertyValue; //}; ItemPropertyList.onAddDropdownCallback = (Rect rect, ReorderableList list) => { var menu = new GenericMenu(); for (int i = 0; i < _database.ItemProperties.Count; i++) { if (!EditedItem.ItemProperties.Contains(_database.ItemProperties[i])) { menu.AddItem(new GUIContent(_database.ItemProperties[i].PropertyName), false, AddProperty, _database.GetByNameProperty(_database.ItemProperties[i].PropertyName)); } } menu.ShowAsContext(); }; } } } GUILayout.BeginVertical("Box", GUILayout.Height(650)); if (GUILayout.Button("Delete this Item")) { ItemToDelete = EditedItem; } itemDataVector = GUILayout.BeginScrollView(itemDataVector, GUILayout.Height(650)); GUILayout.BeginVertical("Box"); GUILayout.BeginHorizontal(); GUILayout.Label("ID: "); GUILayout.Label(EditedItem.ID.ToString()); GUILayout.EndHorizontal(); GUILayout.Space(10); GUILayout.BeginHorizontal(); GUILayout.Label("Name"); EditedItem.Name = GUILayout.TextField(EditedItem.Name, GUILayout.Width(460)); GUILayout.EndHorizontal(); GUILayout.Space(10); GUILayout.BeginHorizontal(); GUILayout.Label("Description"); EditedItem.Description = GUILayout.TextArea(EditedItem.Description, GUILayout.Width(460)); GUILayout.EndHorizontal(); GUILayout.Space(10); GUILayout.BeginHorizontal(); GUILayout.Label("Max Stack's length"); int.TryParse(GUILayout.TextField(EditedItem.MaxStackCount.ToString(), GUILayout.Width(460)), out EditedItem.MaxStackCount); GUILayout.EndHorizontal(); GUILayout.EndVertical(); GUILayout.BeginVertical("Box"); GUILayout.BeginHorizontal(); GUILayout.Label("Icon"); EditedItem.Icon = (Sprite)EditorGUILayout.ObjectField(EditedItem.Icon, typeof(Sprite), GUILayout.Width(460)); GUILayout.EndHorizontal(); GUILayout.Space(10); GUILayout.BeginHorizontal(); GUILayout.Label("Prefab"); EditedItem.ItemPrefab = (GameObject) EditorGUILayout.ObjectField(EditedItem.ItemPrefab, typeof(GameObject), GUILayout.Width(460)); GUILayout.EndHorizontal(); GUILayout.Space(10); GUILayout.BeginHorizontal(); GUILayout.Label("On Use AudioClip"); EditedItem.OnUseAudioClip = (AudioClip) EditorGUILayout.ObjectField(EditedItem.OnUseAudioClip, typeof(AudioClip), GUILayout.Width(460)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("On Gear AudioClip"); EditedItem.OnGearAudioClip = (AudioClip) EditorGUILayout.ObjectField(EditedItem.OnGearAudioClip, typeof(AudioClip), GUILayout.Width(460)); GUILayout.EndHorizontal(); GUILayout.Space(10); GUILayout.BeginVertical("Box"); GUILayout.BeginHorizontal(); GUILayout.Label("Item Category"); EditedItem.categoryChoiceID = EditorGUILayout.Popup(EditedItem.categoryChoiceID, CategoryStrings); GUILayout.EndHorizontal(); GUILayout.EndVertical(); GUILayout.EndVertical(); GUILayout.Space(10); GUILayout.BeginVertical("Box"); //ReorderableListHere GUILayout.Label("Item Properties"); EditorUtility.SetDirty(_database); ItemPropertyList.DoLayoutList(); EditorUtility.SetDirty(_database); GUILayout.EndVertical(); GUILayout.EndScrollView(); GUILayout.EndVertical(); } GUILayout.EndHorizontal(); } else if (toolbarIndex == 1) //ItemCategories & Properties { ReinitializeDatabase(); ReinitializeProperties(); GUILayout.Space(20); GUILayout.BeginHorizontal(); GUILayout.BeginVertical("Box", GUILayout.Width(250)); newItemCategory = GUILayout.TextField(newItemCategory, GUILayout.Width(250)); if (GUILayout.Button("Create Item Category")) { if (!_database.CategoryExist(newItemCategory)) { _database.ItemCategories.Add(new ItemCategory(newItemCategory)); } } if (_database.ItemCategories.Count != 0) { categoryListVector = GUILayout.BeginScrollView(categoryListVector, GUILayout.Width(250)); GUILayout.BeginVertical("Box"); foreach (ItemCategory category in _database.ItemCategories) { GUILayout.Space(10); if (GUILayout.Button(category.Category)) { selectedCategory = category; } } GUILayout.EndVertical(); GUILayout.EndScrollView(); } GUILayout.Space(20); GUILayout.BeginVertical("Box"); if (GUILayout.Button("Remove")) { _database.ItemCategories.Remove(selectedCategory); selectedCategory = null; } GUILayout.EndVertical(); GUILayout.EndVertical(); GUILayout.BeginVertical("Box"); GUILayout.BeginHorizontal(); newItemProperty = GUILayout.TextField(newItemProperty, GUILayout.Width(250)); if (GUILayout.Button("Create Item Property")) { if (!_database.PropertyExist(newItemProperty)) { _database.ItemProperties.Add(new ItemProperty(newItemProperty, string.Empty)); } } GUILayout.EndHorizontal(); if (_database.ItemProperties.Count != 0) { propertyListVector2 = GUILayout.BeginScrollView(propertyListVector2, GUILayout.Height(650)); GUILayout.BeginVertical("Box"); foreach (ItemProperty property in _database.ItemProperties) { GUILayout.Space(10); GUILayout.BeginHorizontal(); GUILayout.Label("Name:"); property.PropertyName = GUILayout.TextField(property.PropertyName, GUILayout.Width(450)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Default Value:"); property.PropertyValue = GUILayout.TextField(property.PropertyValue.ToString(), GUILayout.Width(450)); GUILayout.EndHorizontal(); if (GUILayout.Button("Remove")) { foreach (Item i in _database.ItemList) { if (i.ItemProperties.Contains(property)) { i.ItemProperties.Remove(property); } } propertyToDelete = property; } } GUILayout.EndVertical(); GUILayout.EndScrollView(); } GUILayout.EndVertical(); GUILayout.EndHorizontal(); } else if (toolbarIndex == 2) { GUILayout.BeginHorizontal(); //EditorUtility.SetDirty(_database); //GUILayout.BeginVertical("box"); //if(GUILayout.Button("New Recipe")) //{ // _database.Recipes.Add(new Recipe()); //} //foreach (Recipe rec in _database.Recipes) //{ // GUILayout.Space(15); // int.TryParse(GUILayout.TextField(rec.OutputID.ToString()), out rec.OutputID); // if (GUILayout.Button("Remove Recipe")) // { // if (RecipeToRemove == null) // { // RecipeToRemove = rec; // } // } //} //GUILayout.EndVertical(); //GUILayout.BeginVertical("box"); //GUILayout.EndVertical(); //EditorUtility.SetDirty(_database); craftToolbarIndex = GUILayout.Toolbar(craftToolbarIndex, craftToolbarStrings); GUILayout.EndHorizontal(); if (craftToolbarIndex == 0) //Recipes { GUILayout.BeginHorizontal(); GUILayout.BeginVertical("box",GUILayout.Width(250)); //list GUILayout.BeginHorizontal(); newRecipe = GUILayout.TextField(newRecipe.ToString(), GUILayout.Width(150)); if (GUILayout.Button("Create Recipe")) { if(int.Parse(newRecipe) <= _database.ItemList.Count-1) { bool foundDuplicate = false; for (int i = 0; i < _database.Recipes.Count; i++) { if (_database.Recipes[i].OutputID == int.Parse(newRecipe)) { foundDuplicate = true; } } if (!foundDuplicate) { _database.Recipes.Add(new Recipe(int.Parse(newRecipe))); } } } GUILayout.EndHorizontal(); try { foreach (Recipe rec in _database.Recipes) { if (GUILayout.Button(_database.ItemByID(rec.OutputID).Name.ToString())) { EditedRecipe = rec; } } } catch(Exception ex) { } GUILayout.EndVertical(); if (EditedRecipe != null) { try { GUILayout.BeginVertical("box"); GUILayout.BeginHorizontal(); GUILayout.Label("Result Item"); GUILayout.Label(_database.ItemByID(EditedRecipe.OutputID).Name.ToString()); GUILayout.EndHorizontal(); GUILayout.Label("Ingredients"); if (GUILayout.Button("New Ingredient")) { EditedRecipe.RequiredData.Add(_database.ItemByID(0)); } if (EditedRecipe.RequiredData != null) { foreach (Item i in EditedRecipe.RequiredData) { GUILayout.Space(10); GUILayout.BeginHorizontal(); if (GUILayout.Button("Remove")) { CraftDataToRemove = i; } GUILayout.Label("Ingredient ID"); int.TryParse(GUILayout.TextField(i.ID.ToString()), out i.ID); GUILayout.EndHorizontal(); } } } catch(Exception ex) { } GUILayout.EndVertical(); } GUILayout.EndHorizontal(); } else if (craftToolbarIndex == 1) //BluePrints { GUILayout.BeginHorizontal(); GUILayout.BeginVertical("box", GUILayout.Width(250)); //list GUILayout.BeginHorizontal(); newBluePrint = GUILayout.TextField(newBluePrint.ToString(), GUILayout.Width(150)); EditorUtility.SetDirty(_database); if (GUILayout.Button("Create BluePrint")) { if (int.Parse(newBluePrint) <= _database.ItemList.Count - 1) { bool foundDuplicate = false; for (int i = 0; i < _database.BluePrints.Count; i++) { if (_database.BluePrints[i].OutputID == int.Parse(newBluePrint)) { foundDuplicate = true; } } if (!foundDuplicate) { _database.BluePrints.Add(new BluePrint(int.Parse(newBluePrint))); } } } GUILayout.EndHorizontal(); foreach (BluePrint bp in _database.BluePrints) { if (GUILayout.Button(_database.ItemByID(bp.OutputID).Name.ToString())) { EditedBluePrint = bp; } } GUILayout.EndVertical(); if (EditedBluePrint!= null) { GUILayout.BeginVertical("box", GUILayout.Width(200)); GUILayout.BeginHorizontal(); GUILayout.EndHorizontal(); GUILayout.BeginVertical(); GUILayout.BeginHorizontal(); EditedBluePrint.x1y1 = GUILayout.TextField(EditedBluePrint.x1y1.ToString(),GUILayout.Width(40)); EditedBluePrint.x1y2 = GUILayout.TextField(EditedBluePrint.x1y2.ToString(), GUILayout.Width(40)); EditedBluePrint.x1y3 = GUILayout.TextField(EditedBluePrint.x1y3.ToString(), GUILayout.Width(40)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); EditedBluePrint.x2y1 = GUILayout.TextField(EditedBluePrint.x2y1.ToString(), GUILayout.Width(40)); EditedBluePrint.x2y2 = GUILayout.TextField(EditedBluePrint.x2y2.ToString(), GUILayout.Width(40)); EditedBluePrint.x2y3 = GUILayout.TextField(EditedBluePrint.x2y3.ToString(), GUILayout.Width(40)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); EditedBluePrint.x3y1 = GUILayout.TextField(EditedBluePrint.x3y1.ToString(), GUILayout.Width(40)); EditedBluePrint.x3y2 = GUILayout.TextField(EditedBluePrint.x3y2.ToString(), GUILayout.Width(40)); EditedBluePrint.x3y3 = GUILayout.TextField(EditedBluePrint.x3y3.ToString(), GUILayout.Width(40)); GUILayout.EndHorizontal(); GUILayout.EndVertical(); GUILayout.EndVertical(); } GUILayout.EndHorizontal(); } } else if (toolbarIndex == 3) //Currencies { GUILayout.BeginHorizontal(); GUILayout.BeginVertical("box", GUILayout.Width(this.position.width / 2)); GUILayout.BeginHorizontal(); newCurrency = GUILayout.TextField(newCurrency, GUILayout.Width(125)); GUILayout.Space(20); if (GUILayout.Button("Create new currency", GUILayout.Width(200))) { if(!string.IsNullOrEmpty(newCurrency)) { if (!_database.CurrencyExist(newCurrency)) { Currency currency = new Currency(); currency.Name = newCurrency; _database.Currencies.Add(currency); } } } GUILayout.EndHorizontal(); foreach (var c in _database.Currencies) { GUILayout.Space(10); if (GUILayout.Button(c.Name)) { EditedCurrency = _database.CurrencyByName(c.Name); CurrencyDependencyList = new ReorderableList(EditedCurrency.Dependencies, typeof(CurrencyDependency)); EditorGUI.FocusTextInControl(null); } } GUILayout.EndVertical(); GUILayout.BeginVertical("box"); if (EditedCurrency != null) { if (CurrencyDependencyList == null) { CurrencyDependencyList = new ReorderableList(EditedCurrency.Dependencies, typeof(CurrencyDependency)); } if (CurrencyDependencyList != null || !CurrencyDependencyList.list.Equals(EditedCurrency.Dependencies)) { if (EditedCurrency.Dependencies != null) { CurrencyDependencyList.elementHeight = EditorGUIUtility.singleLineHeight * 5f; CurrencyDependencyList.drawHeaderCallback = (Rect rect) => { EditorGUI.LabelField(rect, "Currency Names and Currency Values"); }; CurrencyDependencyList.onAddCallback = (ReorderableList l) => { var index = EditedCurrency.Dependencies.Count; CurrencyDependency dependency = new CurrencyDependency(); EditedCurrency.Dependencies.Add(dependency); dependency = EditedCurrency.Dependencies[index]; dependency.FirstCurrency = EditedCurrency.Name; dependency.SecondCurrency = EditedCurrency.Name; dependency.FirstCurrencyCount = 1; dependency.SecondCurrencyCount = 1; }; CurrencyDependencyList.drawElementCallback = (Rect rect, int index, bool active, bool focused) => { try { CurrencyDependency dependency = EditedCurrency.Dependencies[index]; rect.y += 2; dependency.FirstCurrency = EditorGUI.TextField(new Rect(rect.x, rect.y, 90, EditorGUIUtility.singleLineHeight), dependency.FirstCurrency); dependency.SecondCurrency = EditorGUI.TextField(new Rect(rect.x, rect.y + 50, 90, EditorGUIUtility.singleLineHeight), dependency.SecondCurrency); int.TryParse(EditorGUI.TextField(new Rect(rect.x + 100, rect.y, 90, EditorGUIUtility.singleLineHeight), dependency.FirstCurrencyCount.ToString()), out dependency.FirstCurrencyCount); int.TryParse(EditorGUI.TextField(new Rect(rect.x + 100, rect.y + 50, 90, EditorGUIUtility.singleLineHeight), dependency.SecondCurrencyCount.ToString()), out dependency.SecondCurrencyCount); } catch (Exception ex) { } }; } } GUILayout.BeginHorizontal(); if (GUILayout.Button("Remove")) { CurrencyToRemove = EditedCurrency; } GUILayout.Label("Currency Name:"); EditedCurrency.Name = GUILayout.TextField(EditedCurrency.Name, GUILayout.Width(125)); GUILayout.EndHorizontal(); EditorUtility.SetDirty(_database); CurrencyDependencyList.DoLayoutList(); EditorUtility.SetDirty(_database); } GUILayout.EndVertical(); GUILayout.EndHorizontal(); } _serializedObject.Update(); _serializedObject.ApplyModifiedProperties(); } if (BluePrintToRemove != null) { _database.BluePrints.Remove(BluePrintToRemove); BluePrintToRemove = null; } if (CurrencyToRemove != null) { _database.Currencies.Remove(CurrencyToRemove); CurrencyToRemove = null; EditedCurrency = null; } if (CraftDataToRemove != null) { EditedRecipe.RequiredData.Remove(CraftDataToRemove); CraftDataToRemove = null; } if (RecipeToRemove != null) { _database.Recipes.Remove(RecipeToRemove); RecipeToRemove = null; } if (ItemToDelete != null) { if (ItemToDelete.ID != 0) { EditedItem = _database.ItemList[ItemToDelete.ID - 1]; } else if (_database.ItemList.Count == 1) { EditedItem = null; } else { EditedItem = _database.ItemList[ItemToDelete.ID + 1]; } _database.ItemList.Remove(ItemToDelete); ItemToDelete = null; ReinitializeDatabase(); } if (propertyToDelete != null) { _database.ItemProperties.Remove(propertyToDelete); propertyToDelete = null; } EditorUtility.SetDirty(_database); }
public NotificationArgs(StoreItem item, ChangeType type, HierarchicalChangeSource changeSource, ItemProperty changedProperty) { Item = item; ChangeType = type; ChangedProperty = changedProperty; ChangeSource = changeSource; }
public bool CustomPropertyByPath(ItemProperty path, out ItemReference propRef) { propRef = null; return(false); }
private void ApplyWeaponPenalties(NWPlayer oPC, NWItem oItem) { int skillID = GetWeaponSkillID(oItem); if (skillID <= 0) { return; } PCSkill pcSkill = GetPCSkill(oPC, skillID); if (pcSkill == null) { return; } int rank = pcSkill.Rank; int recommendedRank = oItem.RecommendedLevel; if (rank >= recommendedRank) { return; } int delta = rank - recommendedRank; int penalty; if (delta <= -20) { penalty = 99; } else if (delta <= -16) { penalty = 5; } else if (delta <= -12) { penalty = 4; } else if (delta <= -8) { penalty = 3; } else if (delta <= -4) { penalty = 2; } else if (delta <= 0) { penalty = 1; } else { penalty = 99; } // No combat damage penalty if (penalty == 99) { ItemProperty noDamage = _.ItemPropertyNoDamage(); noDamage = _.TagItemProperty(noDamage, IPPenaltyTag); _biowareXP2.IPSafeAddItemProperty(oItem, noDamage, 0.0f, AddItemPropertyPolicy.ReplaceExisting, false, false); penalty = 5; // Reset to 5 so that the following penalties apply. } // Decreased attack penalty ItemProperty ipPenalty = _.ItemPropertyAttackPenalty(penalty); ipPenalty = _.TagItemProperty(ipPenalty, IPPenaltyTag); _biowareXP2.IPSafeAddItemProperty(oItem, ipPenalty, 0.0f, AddItemPropertyPolicy.ReplaceExisting, false, false); // Decreased damage penalty ipPenalty = _.ItemPropertyDamagePenalty(penalty); ipPenalty = _.TagItemProperty(ipPenalty, IPPenaltyTag); _biowareXP2.IPSafeAddItemProperty(oItem, ipPenalty, 0.0f, AddItemPropertyPolicy.ReplaceExisting, false, false); // Decreased enhancement bonus penalty ipPenalty = _.ItemPropertyEnhancementPenalty(penalty); ipPenalty = _.TagItemProperty(ipPenalty, IPPenaltyTag); _biowareXP2.IPSafeAddItemProperty(oItem, ipPenalty, 0.0f, AddItemPropertyPolicy.ReplaceExisting, false, false); oPC.SendMessage("A penalty has been applied to your weapon '" + oItem.Name + "' due to your skill being under the recommended level."); }
public static string OnModuleExamine(string existingDescription, NWObject examinedObject) { if (examinedObject.ObjectType != ObjectType.Item) { return(existingDescription); } NWItem examinedItem = (examinedObject.Object); string description = ""; if (examinedItem.RecommendedLevel > 0) { description += ColorTokenService.Orange("Recommended Level: ") + examinedItem.RecommendedLevel; if (examinedItem.BaseItemType == BaseItem.Ring || examinedItem.BaseItemType == BaseItem.Amulet) { description += " (Uses your highest armor skill)"; } description += "\n"; } if (examinedItem.LevelIncrease > 0) { description += ColorTokenService.Orange("Level Increase: ") + examinedItem.LevelIncrease + "\n"; } if (examinedItem.AssociatedSkillType > 0) { Skill skill = DataService.Skill.GetByID((int)examinedItem.AssociatedSkillType); description += ColorTokenService.Orange("Associated Skill: ") + skill.Name + "\n"; } if (examinedItem.CustomAC > 0) { if (ShieldBaseItemTypes.Contains(examinedItem.BaseItemType)) { description += ColorTokenService.Orange("Damage Immunity: ") + (10 + examinedItem.CustomAC / 3) + "\n"; } else if (ArmorBaseItemTypes.Contains(examinedItem.BaseItemType)) { description += ColorTokenService.Orange("AC: ") + examinedItem.CustomAC + "\n"; } else { description += ColorTokenService.Red("AC (ignored due to item type): ") + examinedItem.CustomAC + "\n"; } } if (examinedItem.HPBonus > 0) { description += ColorTokenService.Orange("HP Bonus: ") + examinedItem.HPBonus + "\n"; } if (examinedItem.FPBonus > 0) { description += ColorTokenService.Orange("FP Bonus: ") + examinedItem.FPBonus + "\n"; } if (examinedItem.StructureBonus > 0) { description += ColorTokenService.Orange("Structure Bonus: ") + examinedItem.StructureBonus + "\n"; } if (examinedItem.StrengthBonus > 0) { description += ColorTokenService.Orange("Strength Bonus: ") + examinedItem.StrengthBonus + "\n"; } if (examinedItem.DexterityBonus > 0) { description += ColorTokenService.Orange("Dexterity Bonus: ") + examinedItem.DexterityBonus + "\n"; } if (examinedItem.ConstitutionBonus > 0) { description += ColorTokenService.Orange("Constitution Bonus: ") + examinedItem.ConstitutionBonus + "\n"; } if (examinedItem.WisdomBonus > 0) { description += ColorTokenService.Orange("Wisdom Bonus: ") + examinedItem.WisdomBonus + "\n"; } if (examinedItem.IntelligenceBonus > 0) { description += ColorTokenService.Orange("Intelligence Bonus: ") + examinedItem.IntelligenceBonus + "\n"; } if (examinedItem.CharismaBonus > 0) { description += ColorTokenService.Orange("Charisma Bonus: ") + examinedItem.CharismaBonus + "\n"; } if (examinedItem.CooldownRecovery > 0) { description += ColorTokenService.Orange("Cooldown Recovery: +") + examinedItem.CooldownRecovery + "%\n"; } else if (examinedItem.CooldownRecovery < 0) { description += ColorTokenService.Orange("Cooldown Recovery: -") + examinedItem.CooldownRecovery + "%\n"; } if (examinedItem.HarvestingBonus > 0) { description += ColorTokenService.Orange("Harvesting Bonus: ") + examinedItem.HarvestingBonus + "\n"; } if (examinedItem.CraftBonusArmorsmith > 0) { description += ColorTokenService.Orange("Armorsmith Bonus: ") + examinedItem.CraftBonusArmorsmith + "\n"; } if (examinedItem.CraftBonusEngineering > 0) { description += ColorTokenService.Orange("Engineering Bonus: ") + examinedItem.CraftBonusEngineering + "\n"; } if (examinedItem.CraftBonusFabrication > 0) { description += ColorTokenService.Orange("Fabrication Bonus: ") + examinedItem.CraftBonusFabrication + "\n"; } if (examinedItem.CraftBonusWeaponsmith > 0) { description += ColorTokenService.Orange("Weaponsmith Bonus: ") + examinedItem.CraftBonusWeaponsmith + "\n"; } if (examinedItem.CraftBonusCooking > 0) { description += ColorTokenService.Orange("Cooking Bonus: ") + examinedItem.CraftBonusCooking + "\n"; } if (examinedItem.CraftTierLevel > 0) { description += ColorTokenService.Orange("Tool Level: ") + examinedItem.CraftTierLevel + "\n"; } if (examinedItem.EnmityRate != 0) { description += ColorTokenService.Orange("Enmity: ") + examinedItem.EnmityRate + "%\n"; } if (examinedItem.LuckBonus > 0) { description += ColorTokenService.Orange("Luck Bonus: ") + examinedItem.LuckBonus + "\n"; } if (examinedItem.MeditateBonus > 0) { description += ColorTokenService.Orange("Meditate Bonus: ") + examinedItem.MeditateBonus + "\n"; } if (examinedItem.RestBonus > 0) { description += ColorTokenService.Orange("Rest Bonus: ") + examinedItem.RestBonus + "\n"; } if (examinedItem.ScanningBonus > 0) { description += ColorTokenService.Orange("Scanning Bonus: ") + examinedItem.ScanningBonus + "\n"; } if (examinedItem.ScavengingBonus > 0) { description += ColorTokenService.Orange("Scavenging Bonus: ") + examinedItem.ScavengingBonus + "\n"; } if (examinedItem.MedicineBonus > 0) { description += ColorTokenService.Orange("Medicine Bonus: ") + examinedItem.MedicineBonus + "\n"; } if (examinedItem.HPRegenBonus > 0) { description += ColorTokenService.Orange("HP Regen Bonus: ") + examinedItem.HPRegenBonus + "\n"; } if (examinedItem.FPRegenBonus > 0) { description += ColorTokenService.Orange("FP Regen Bonus: ") + examinedItem.FPRegenBonus + "\n"; } if (examinedItem.PilotingBonus > 0) { description += ColorTokenService.Orange("Piloting Bonus: ") + examinedItem.PilotingBonus + "\n"; } if (examinedItem.BaseAttackBonus > 0) { if (WeaponBaseItemTypes.Contains(examinedItem.BaseItemType)) { description += ColorTokenService.Orange("Base Attack Bonus: ") + examinedItem.BaseAttackBonus + "\n"; } else { description += ColorTokenService.Red("Base Attack Bonus (ignored due to item type): ") + examinedItem.BaseAttackBonus + "\n"; } } if (examinedItem.SneakAttackBonus > 0) { description += ColorTokenService.Orange("Sneak Attack Bonus: ") + examinedItem.SneakAttackBonus + "\n"; } if (examinedItem.DamageBonus > 0) { if (WeaponBaseItemTypes.Contains(examinedItem.BaseItemType)) { description += ColorTokenService.Orange("Damage Bonus: ") + examinedItem.DamageBonus + "\n"; } else { description += ColorTokenService.Red("Damage Bonus (ignored due to item type): ") + examinedItem.DamageBonus + "\n"; } } if (examinedItem.CustomItemType != CustomItemType.None) { string itemTypeProper = string.Concat(examinedItem.CustomItemType.ToString().Select(x => char.IsUpper(x) ? " " + x : x.ToString())).TrimStart(' '); description += ColorTokenService.Orange("Item Type: ") + itemTypeProper + "\n"; } // Check for properties that can only be applied to limited things, and flag them here. // Attack bonus, damage, base attack bonus: weapons only // AC - armor items only. ItemProperty ip = GetFirstItemProperty(examinedItem); while (GetIsItemPropertyValid(ip) == true) { if (GetItemPropertyType(ip) == ItemPropertyType.ComponentBonus) { switch (GetItemPropertySubType(ip)) { case (int)ComponentBonusType.ACUp: { description += ColorTokenService.Cyan("AC can only be applied to Shields, Armor and Helmets. On other items, it will be ignored.\n"); break; } case (int)ComponentBonusType.DamageUp: case (int)ComponentBonusType.AttackBonusUp: case (int)ComponentBonusType.BaseAttackBonusUp: { description += ColorTokenService.Cyan("Damage Up, Attack Bonus Up and Base Attack Bonus Up can only be applied to weapons (including gloves). On other items, it will be ignored.\n"); break; } } } ip = GetNextItemProperty(examinedItem); } return(existingDescription + "\n" + description); }
/// <summary> /// Try to get a custom property by the Item Type and name information /// </summary> public bool CustomPropertyByPath(ItemProperty path, out ItemReference propRef) { return _customProps.TryGetValue(path, out propRef); }
public ItemStatRange GetItemStatRange(ItemProperty property) { return ItemDataUtils.GetItemStatRange(_item, property); }
public void ApplyComponentBonus(NWItem product, ItemProperty sourceIP) { ComponentBonusType bonusType = (ComponentBonusType)_.GetItemPropertySubType(sourceIP); int amount = _.GetItemPropertyCostTableValue(sourceIP); ItemProperty prop = null; string sourceTag = string.Empty; // A note about the sourceTags: // It's not currently possible to create custom item properties on items. To get around this, // we look in an inaccessible container which holds the custom item properties. Then, we get the // item that has the item property we want. From there we take that item property and copy it to // the crafted item. // This is a really roundabout way to do it, but it's the only option for now. Hopefully a feature to // directly add the item properties comes in to NWNX in the future. for (int x = 1; x <= amount; x++) { switch (bonusType) { case ComponentBonusType.ModSocketRed: sourceTag = "rslot_red"; break; case ComponentBonusType.ModSocketBlue: sourceTag = "rslot_blue"; break; case ComponentBonusType.ModSocketGreen: sourceTag = "rslot_green"; break; case ComponentBonusType.ModSocketYellow: sourceTag = "rslot_yellow"; break; case ComponentBonusType.ModSocketPrismatic: sourceTag = "rslot_prismatic"; break; case ComponentBonusType.DurabilityUp: var maxDur = _durability.GetMaxDurability(product) + amount; _durability.SetMaxDurability(product, maxDur); _durability.SetDurability(product, maxDur); break; case ComponentBonusType.ChargesUp: product.Charges += amount; break; case ComponentBonusType.ACUp: product.CustomAC += amount; break; case ComponentBonusType.HarvestingUp: product.HarvestingBonus += amount; break; case ComponentBonusType.CastingSpeedUp: product.CastingSpeed += amount; break; case ComponentBonusType.ArmorsmithUp: product.CraftBonusArmorsmith += amount; break; case ComponentBonusType.WeaponsmithUp: product.CraftBonusWeaponsmith += amount; break; case ComponentBonusType.CookingUp: product.CraftBonusCooking += amount; break; case ComponentBonusType.EngineeringUp: product.CraftBonusEngineering += amount; break; case ComponentBonusType.FabricationUp: product.CraftBonusFabrication += amount; break; case ComponentBonusType.HPUp: product.HPBonus += amount; break; case ComponentBonusType.FPUp: product.FPBonus += amount; break; case ComponentBonusType.EnmityUp: product.EnmityRate += amount; break; case ComponentBonusType.EnmityDown: product.EnmityRate -= amount; break; case ComponentBonusType.DarkAbilityUp: product.DarkAbilityBonus += amount; break; case ComponentBonusType.LightAbilityUp: product.LightAbilityBonus += amount; break; case ComponentBonusType.LuckUp: product.LuckBonus += amount; break; case ComponentBonusType.MeditateUp: product.MeditateBonus += amount; break; case ComponentBonusType.RestUp: product.RestBonus += amount; break; case ComponentBonusType.MedicineUp: product.MedicineBonus += amount; break; case ComponentBonusType.HPRegenUp: product.HPRegenBonus += amount; break; case ComponentBonusType.FPRegenUp: product.FPRegenBonus += amount; break; case ComponentBonusType.BaseAttackBonusUp: product.BaseAttackBonus += amount; break; case ComponentBonusType.SneakAttackUp: product.SneakAttackBonus += amount; break; case ComponentBonusType.DamageUp: product.DamageBonus += amount; break; case ComponentBonusType.DarkAbilityDown: product.DarkAbilityBonus -= amount; break; case ComponentBonusType.LightAbilityDown: product.LightAbilityBonus -= amount; break; case ComponentBonusType.StructureBonusUp: product.StructureBonus += amount; break; case ComponentBonusType.StrengthUp: product.StrengthBonus += amount; break; case ComponentBonusType.DexterityUp: product.DexterityBonus += amount; break; case ComponentBonusType.ConstitutionUp: product.ConstitutionBonus += amount; break; case ComponentBonusType.WisdomUp: product.WisdomBonus += amount; break; case ComponentBonusType.IntelligenceUp: product.IntelligenceBonus += amount; break; case ComponentBonusType.CharismaUp: product.CharismaBonus += amount; break; case ComponentBonusType.AttackBonusUp: prop = _.ItemPropertyAttackBonus(amount); break; case ComponentBonusType.DurationUp: product.DurationBonus += amount; break; case ComponentBonusType.ScanningUp: product.ScanningBonus += amount; break; default: throw new ArgumentOutOfRangeException(); } if (!string.IsNullOrWhiteSpace(sourceTag)) { prop = _item.GetCustomItemPropertyByItemTag(sourceTag); } if (prop == null) { return; } _biowareXP2.IPSafeAddItemProperty(product, prop, 0.0f, AddItemPropertyPolicy.IgnoreExisting, true, true); } }
/// <summary> /// Returns the specified properties for the specified item. /// </summary> public Opc.Da.ItemPropertyCollection GetAvailableProperties( PropertyID[] propertyIDs, bool returnValues) { // initialize property collection. ItemPropertyCollection properties = new ItemPropertyCollection(); properties.ItemName = m_itemID; properties.ItemPath = null; properties.ResultID = ResultID.S_OK; properties.DiagnosticInfo = null; // fetch information for each requested property. foreach (PropertyID propertyID in propertyIDs) { ItemProperty property = new ItemProperty(); property.ID = propertyID; // read the property value. if (returnValues) { ItemValueResult result = Read(propertyID); if (result.ResultID.Succeeded()) { property.Value = result.Value; } property.ResultID = result.ResultID; property.DiagnosticInfo = result.DiagnosticInfo; } // just validate the property id. else { property.ResultID = ValidatePropertyID(propertyID, accessRights.readWritable); } // set status if one or more errors occur. if (property.ResultID.Failed()) { properties.ResultID = ResultID.S_FALSE; } else { // set property description. PropertyDescription description = PropertyDescription.Find(propertyID); if (description != null) { property.Description = description.Name; property.DataType = description.Type; } // set property item id. if (propertyID.Code >= ENGINEERINGUINTS && propertyID.Code <= TIMEZONE) { property.ItemName = m_itemID + ":" + propertyID.Code.ToString(); property.ItemPath = null; } } // add to collection. properties.Add(property); } // return collection. return properties; }
public MiningAmmo() { miningCycleTimeModifier = new MiningCycleTimeModifierProperty(this); AddProperty(miningCycleTimeModifier); }
/// <summary> /// Method to convert the name of a property to a string /// </summary> /// <param name="property">The effect which should be parsed to a string</param> /// <returns>The item effect as a string</returns> public static string PropertyToString(ItemProperty property) { switch (property) { case ItemProperty.Evade: return "Evade "; case ItemProperty.Block: return "Block "; case ItemProperty.Penetrate: return "Penetration "; case ItemProperty.ReduceDamage: return "Reduce Damage "; case ItemProperty.StealMana: return "Steal Mana "; case ItemProperty.IceDamage: return "Ice Damage "; case ItemProperty.FireProtect: return "Fire Protection "; case ItemProperty.IceProtect: return "Ice Protection "; case ItemProperty.DestroyWeapon: return "Destroy Weapon "; case ItemProperty.DestroyArmor: return "Destroy Armor "; case ItemProperty.Resist: return "Resist Effect "; case ItemProperty.Damage: return "Physical Damage "; case ItemProperty.FireDamage: return "Fire Damage "; case ItemProperty.StealHealth: return "Steal Health "; case ItemProperty.MaxHealth: return "Max. Health "; case ItemProperty.Mana: return "Mana "; case ItemProperty.MaxMana: return "Max. Mana "; case ItemProperty.Health: return "Health "; case ItemProperty.ManaRegen: return "Mana Regeneration "; case ItemProperty.HealthRegen: return "Health Regeneration "; } return ""; }
public EnergyVampireModule() { _energyVampiredAmount = new ModuleProperty(this, AggregateField.energy_vampired_amount); AddProperty(_energyVampiredAmount); }
private void VisitNode(XmlElement elem, ItemReference masterRef) { var textChildren = elem.ChildNodes.OfType<XmlText>().ToList(); // Add a dependency to the relevant itemTypes if (elem.LocalName == "Item" && elem.HasAttribute("type")) { ItemType itemType; if (_metadata.ItemTypeByName(elem.Attribute("type").ToLowerInvariant(), out itemType)) { AddDependency(itemType.Reference, elem, elem, masterRef); } else { AddDependency(new ItemReference("ItemType", ItemTypeByNameWhere + elem.Attributes["type"].Value + "'") { KeyedName = elem.Attributes["type"].Value }, elem, elem, masterRef); } } // Item property node if (elem.HasAttribute("type") && textChildren.Count == 1 && !string.IsNullOrEmpty(textChildren[0].Value)) { AddDependency(ItemReference.FromItemProp(elem), elem.Parent(), elem, masterRef); } else if (elem.LocalName == "sqlserver_body" && elem.Parent().LocalName == "Item" && elem.Parent().Attribute("type") == "SQL") { var names = GetInnovatorNames(elem.InnerText) .Select(n => n.FullName.StartsWith("innovator.", StringComparison.OrdinalIgnoreCase) ? n.FullName.Substring(10).ToLowerInvariant() : n.FullName.ToLowerInvariant()) .Distinct(); ItemType itemType; ItemReference sql; foreach (var name in names) { if (_metadata.ItemTypeByName(name.Replace('_', ' '), out itemType)) { AddDependency(itemType.Reference, elem.Parent(), elem, masterRef); } else if (_metadata.SqlRefByName(name, out sql)) { AddDependency(sql, elem.Parent(), elem, masterRef); } } } else if (elem.LocalName == "data_source" && textChildren.Count == 1 && !string.IsNullOrEmpty(textChildren[0].Value)) { // Property data source dependencies var parent = elem.ParentNode as XmlElement; if (parent != null && parent.LocalName == "Item" && parent.Attribute("type") == "Property") { var keyedName = elem.Attribute("keyed_name"); var itemtype = _metadata.ItemTypes.FirstOrDefault(i => i.Reference.Unique == elem.Parent().Parent().Parent().Attribute("id") && i.IsPolymorphic); if (itemtype == null) { var dataType = parent.Element("data_type"); if (dataType != null) { switch (dataType.InnerText.ToLowerInvariant()) { case "list": case "mv_list": case "filter list": AddDependency(new ItemReference("List", textChildren[0].Value) { KeyedName = keyedName }, parent, elem, masterRef); break; case "item": AddDependency(new ItemReference("ItemType", textChildren[0].Value) { KeyedName = keyedName }, parent, elem, masterRef); break; case "sequence": AddDependency(new ItemReference("Sequence", textChildren[0].Value) { KeyedName = keyedName }, parent, elem, masterRef); break; } } } } } else if (elem != _elem && elem.LocalName == "Item" && elem.HasAttribute("type") && elem.Attribute("action", "") == "get" && (elem.HasAttribute("id") || elem.HasAttribute("where"))) { // Item queries AddDependency(ItemReference.FromFullItem(elem, true), elem.Parent().Parent(), elem.Parent(), masterRef); } else if (textChildren.Count == 1 && textChildren[0].Value.StartsWith("vault:///?fileId=", StringComparison.OrdinalIgnoreCase)) { // Vault Id references for image properties AddDependency(new ItemReference("File", textChildren[0].Value.Substring(17)), elem.Parent(), elem, masterRef); } else { if (elem != _elem && elem.LocalName == "Item" && elem.HasAttribute("type") && elem.HasAttribute("id")) { _definitions.Add(ItemReference.FromFullItem(elem, elem.Attribute("type") == "ItemType")); } var isItem = (elem.LocalName == "Item" && elem.HasAttribute("type")); ItemProperty newProp; ItemReference propRef; foreach (var child in elem.Elements()) { if (isItem) { newProp = new ItemProperty() { ItemType = elem.Attributes["type"].Value, ItemTypeId = (elem.HasAttribute("typeid") ? elem.Attributes["typeid"].Value : null), Property = child.LocalName }; if (_metadata.CustomPropertyByPath(newProp, out propRef)) { propRef = propRef.Clone(); AddDependency(propRef, elem, child, masterRef); } } VisitNode(child, masterRef); } } }
/// <summary> /// Returns an object with the Min and Max values for a particular property and item /// Eg. Fire Damage 15-20% /// </summary> public static ItemStatRange GetItemStatRange(Item item, ItemProperty prop) { ItemStatRange statRange; var result = new ItemStatRange(); if(prop == ItemProperty.Ancient) return new ItemStatRange { Max = 1, Min = 0}; if (ItemPropertyLimitsByItemType.TryGetValue(new KeyValuePair<TrinityItemType, ItemProperty>(item.TrinityItemType,prop), out statRange)) result = statRange; if (SpecialItemsPropertyCases.TryGetValue(new Tuple<Item, ItemProperty>(item, prop), out statRange)) result = statRange; return result; }
private void ItemPropertyChanged(object sender, ItemProperty property) { switch (property) { case ItemProperty.Header: Content = (sender as HeaderedContentControl).Header; break; case ItemProperty.Image: Image = (sender as NavigationPaneItem).ImageSmall; break; } }
/// <summary> /// Get all the possible options for multi-value item properties. /// For example Skill Damage for Quiver can be for the Sentry, Cluster Arrow, Multishot etc. /// </summary> public static List<object> GetItemPropertyVariants(ItemProperty prop, TrinityItemType itemType) { var result = new List<object>(); switch (prop) { case ItemProperty.SkillDamage: var classRestriction = (Item.GetClassRestriction(itemType)); result = GetSkillsForItemType(itemType, classRestriction).Cast<object>().ToList(); break; case ItemProperty.ElementalDamage: result = new List<object> { Element.Poison.ToEnumValue(), Element.Holy.ToEnumValue(), Element.Cold.ToEnumValue(), Element.Arcane.ToEnumValue(), Element.Fire.ToEnumValue(), Element.Physical.ToEnumValue(), Element.Lightning.ToEnumValue(), Element.Any.ToEnumValue() }; break; case ItemProperty.ElementalResist: result = new List<object> { Element.Poison.ToEnumValue(), Element.Holy.ToEnumValue(), Element.Cold.ToEnumValue(), Element.Arcane.ToEnumValue(), Element.Fire.ToEnumValue(), Element.Physical.ToEnumValue(), Element.Lightning.ToEnumValue(), Element.Any.ToEnumValue() }; break; } return result; }
private static void LoadObjectDbXml(string file) { var xmlSettings = XElement.Load(file); // Load Colors foreach (var xElement in xmlSettings.Elements("GlobalColors").Elements("GlobalColor")) { string name = (string)xElement.Attribute("Name"); XNA.Color color = XnaColorFromString((string)xElement.Attribute("Color")); GlobalColors.Add(name, color); } foreach (var xElement in xmlSettings.Elements("Tiles").Elements("Tile")) { var curTile = new TileProperty(); // Read XML attributes curTile.Color = ColorFromString((string)xElement.Attribute("Color")); curTile.Name = (string)xElement.Attribute("Name"); curTile.Id = (int?)xElement.Attribute("Id") ?? 0; curTile.IsFramed = (bool?)xElement.Attribute("Framed") ?? false; curTile.IsSolid = (bool?)xElement.Attribute("Solid") ?? false; curTile.SaveSlope = (bool?)xElement.Attribute("SaveSlope") ?? false; curTile.IsSolidTop = (bool?)xElement.Attribute("SolidTop") ?? false; curTile.IsLight = (bool?)xElement.Attribute("Light") ?? false; curTile.IsAnimated = (bool?)xElement.Attribute("IsAnimated") ?? false; curTile.FrameSize = StringToVector2ShortArray((string)xElement.Attribute("Size"), 1, 1); // curTile.FrameSize = StringToVector2Short((string)xElement.Attribute("Size"), 1, 1); curTile.Placement = InLineEnumTryParse <FramePlacement>((string)xElement.Attribute("Placement")); curTile.TextureGrid = StringToVector2Short((string)xElement.Attribute("TextureGrid"), 16, 16); curTile.FrameGap = StringToVector2Short((string)xElement.Attribute("FrameGap"), 2, 2); curTile.IsGrass = "Grass".Equals((string)xElement.Attribute("Special")); /* Heathtech */ curTile.IsPlatform = "Platform".Equals((string)xElement.Attribute("Special")); /* Heathtech */ curTile.IsCactus = "Cactus".Equals((string)xElement.Attribute("Special")); /* Heathtech */ curTile.IsStone = (bool?)xElement.Attribute("Stone") ?? false; /* Heathtech */ curTile.CanBlend = (bool?)xElement.Attribute("Blends") ?? false; /* Heathtech */ curTile.MergeWith = (int?)xElement.Attribute("MergeWith") ?? null; /* Heathtech */ string frameNamePostfix = (string)xElement.Attribute("FrameNamePostfix") ?? null; foreach (var elementFrame in xElement.Elements("Frames").Elements("Frame")) { var curFrame = new FrameProperty(); // Read XML attributes curFrame.Name = (string)elementFrame.Attribute("Name"); curFrame.Variety = (string)elementFrame.Attribute("Variety"); curFrame.UV = StringToVector2Short((string)elementFrame.Attribute("UV"), 0, 0); curFrame.Anchor = InLineEnumTryParse <FrameAnchor>((string)elementFrame.Attribute("Anchor")); var frameSize = StringToVector2Short((string)elementFrame.Attribute("FrameSize"), curTile.FrameSize[0].X, curTile.FrameSize[0].Y); // Assign a default name if none existed if (string.IsNullOrWhiteSpace(curFrame.Name)) { curFrame.Name = curTile.Name; } curTile.Frames.Add(curFrame); string spriteName = null; if (curFrame.Name == curTile.Name) { if (!string.IsNullOrWhiteSpace(curFrame.Variety)) { spriteName += curFrame.Variety; } } else { spriteName += curFrame.Name; if (!string.IsNullOrWhiteSpace(curFrame.Variety)) { spriteName += " - " + curFrame.Variety; } } Sprites.Add(new Sprite { Anchor = curFrame.Anchor, IsPreviewTexture = false, Name = spriteName, Origin = curFrame.UV, Size = frameSize, Tile = (ushort)curTile.Id, /* SBlogic */ TileName = curTile.Name }); } if (curTile.Frames.Count == 0 && curTile.IsFramed) { var curFrame = new FrameProperty(); // Read XML attributes curFrame.Name = curTile.Name; curFrame.Variety = string.Empty; curFrame.UV = new Vector2Short(0, 0); //curFrame.Anchor = InLineEnumTryParse<FrameAnchor>((string)xElement.Attribute("Anchor")); curTile.Frames.Add(curFrame); Sprites.Add(new Sprite { Anchor = curFrame.Anchor, IsPreviewTexture = false, Name = null, Origin = curFrame.UV, Size = curTile.FrameSize[0], Tile = (ushort)curTile.Id, TileName = curTile.Name }); } TileProperties.Add(curTile); if (!curTile.IsFramed) { TileBricks.Add(curTile); } } for (int i = TileProperties.Count; i < 255; i++) { TileProperties.Add(new TileProperty(i, "UNKNOWN", Color.FromArgb(255, 255, 0, 255), true)); } foreach (var xElement in xmlSettings.Elements("Walls").Elements("Wall")) { var curWall = new WallProperty(); curWall.Color = ColorFromString((string)xElement.Attribute("Color")); curWall.Name = (string)xElement.Attribute("Name"); curWall.Id = (int?)xElement.Attribute("Id") ?? -1; WallProperties.Add(curWall); } foreach (var xElement in xmlSettings.Elements("Items").Elements("Item")) { var curItem = new ItemProperty(); curItem.Id = (int?)xElement.Attribute("Id") ?? -1; curItem.Name = (string)xElement.Attribute("Name"); curItem.Scale = (float?)xElement.Attribute("Scale") ?? 1f; ItemProperties.Add(curItem); _itemLookup.Add(curItem.Id, curItem); int tally = (int?)xElement.Attribute("Tally") ?? 0; if (tally > 0) { _tallynames.Add(tally, curItem.Name); } int head = (int?)xElement.Attribute("Head") ?? -1; if (head >= 0) { _armorHeadNames.Add(curItem.Id, curItem.Name); } int body = (int?)xElement.Attribute("Body") ?? -1; if (body >= 0) { _armorBodyNames.Add(curItem.Id, curItem.Name); } int legs = (int?)xElement.Attribute("Legs") ?? -1; if (legs >= 0) { _armorLegsNames.Add(curItem.Id, curItem.Name); } bool rack = (bool?)xElement.Attribute("Rack") ?? false; if (rack) { _rackable.Add(curItem.Id, curItem.Name); } bool food = (bool?)xElement.Attribute("IsFood") ?? false; if (food) { _foodNames.Add(curItem.Id, curItem.Name); curItem.IsFood = true; } bool acc = (bool?)xElement.Attribute("Accessory") ?? false; if (acc) { _accessoryNames.Add(curItem.Id, curItem.Name); } if (curItem.Name.Contains("Dye")) { _dyeNames.Add(curItem.Id, curItem.Name); } } foreach (var xElement in xmlSettings.Elements("Paints").Elements("Paint")) { var curPaint = new PaintProperty(); curPaint.Id = (int?)xElement.Attribute("Id") ?? -1; curPaint.Name = (string)xElement.Attribute("Name"); curPaint.Color = ColorFromString((string)xElement.Attribute("Color")); PaintProperties.Add(curPaint); } int chestId = 0; foreach (var tileElement in xmlSettings.Elements("Tiles").Elements("Tile")) { string tileName = (string)tileElement.Attribute("Name"); int type = (int)tileElement.Attribute("Id"); if (Tile.IsChest(type)) { foreach (var xElement in tileElement.Elements("Frames").Elements("Frame")) { var curItem = new ChestProperty(); curItem.Name = (string)xElement.Attribute("Name"); string variety = (string)xElement.Attribute("Variety"); if (variety != null) { if (tileName == "Dresser") { curItem.Name = variety + " " + "Dresser"; } else { curItem.Name = curItem.Name + " " + variety; } } curItem.ChestId = chestId++; curItem.UV = StringToVector2Short((string)xElement.Attribute("UV"), 0, 0); curItem.TileType = (ushort)type; ChestProperties.Add(curItem); } } } int signId = 0; foreach (var tileElement in xmlSettings.Elements("Tiles").Elements("Tile")) { var tileId = (int?)tileElement.Attribute("Id") ?? 0; string tileName = (string)tileElement.Attribute("Name"); if (Tile.IsSign(tileId)) { ushort type = (ushort)((int?)tileElement.Attribute("Id") ?? 55); foreach (var xElement in tileElement.Elements("Frames").Elements("Frame")) { var curItem = new SignProperty(); string variety = (string)xElement.Attribute("Variety"); string anchor = (string)xElement.Attribute("Anchor"); curItem.Name = $"{tileName} {variety} {anchor}"; curItem.SignId = signId++; curItem.UV = StringToVector2Short((string)xElement.Attribute("UV"), 0, 0); curItem.TileType = type; SignProperties.Add(curItem); } } } foreach (var xElement in xmlSettings.Elements("Npcs").Elements("Npc")) { int id = (int?)xElement.Attribute("Id") ?? -1; string name = (string)xElement.Attribute("Name"); NpcIds[name] = id; NpcNames[id] = name; var frames = StringToVector2Short((string)xElement.Attribute("Size"), 16, 40); NpcFrames[id] = frames; } foreach (var xElement in xmlSettings.Elements("ItemPrefix").Elements("Prefix")) { int id = (int?)xElement.Attribute("Id") ?? -1; string name = (string)xElement.Attribute("Name"); ItemPrefix.Add((byte)id, name); } foreach (var xElement in xmlSettings.Elements("ShortCutKeys").Elements("Shortcut")) { var key = InLineEnumTryParse <Key>((string)xElement.Attribute("Key")); var modifier = InLineEnumTryParse <ModifierKeys>((string)xElement.Attribute("Modifier")); var tool = (string)xElement.Attribute("Action"); ShortcutKeys.Add(tool, key, modifier); } XElement appSettings = xmlSettings.Element("App"); int appWidth = (int?)appSettings.Attribute("Width") ?? 800; int appHeight = (int?)appSettings.Attribute("Height") ?? 600; int clipboardSize = (int)XNA.MathHelper.Clamp((int?)appSettings.Attribute("ClipboardRenderSize") ?? 512, 64, 4096); _appSize = new Vector2(appWidth, appHeight); ClipboardBuffer.ClipboardRenderSize = clipboardSize; ToolDefaultData.LoadSettings(xmlSettings.Elements("Tools")); AltC = (string)xmlSettings.Element("AltC"); SteamUserId = (int?)xmlSettings.Element("SteamUserId") ?? null; }
public static ItemProperty NWNX_GetReturnValueItemProperty(string pluginName, string functionName) { ItemProperty ip = new ItemProperty(); return(_.TagItemProperty(ip, NWNX_INTERNAL_BuildString(pluginName, functionName, "POP"))); }
/// <summary> /// Determines whether <paramref name="prop"/>. /// </summary> /// <param name="prop">Item property.</param> /// <param name="value">Value of <paramref name="prop"/></param> /// <returns>true if property is special and contains a value, false otherwise.</returns> public static bool IsSpecialProperty(ItemProperty prop) { int i = (int)prop; return(m_Specials[i]); }
public WebberModule() : base(true) { optimalRange.AddEffectModifier(AggregateField.effect_ew_optimal_range_modifier); _effectMassivnesSpeedMaxModifier = new ModuleProperty(this, AggregateField.effect_massivness_speed_max_modifier); AddProperty(_effectMassivnesSpeedMaxModifier); }
/// <summary> /// Determine if an item can have a given property /// </summary> /// <param name="item"></param> /// <param name="prop"></param> /// <returns></returns> public static bool IsValidPropertyForItem(Item item, ItemProperty prop) { ItemStatRange statRange; if (prop == ItemProperty.Ancient) return true; if (ItemPropertyLimitsByItemType.TryGetValue(new KeyValuePair<TrinityItemType, ItemProperty>(item.TrinityItemType, prop), out statRange)) return true; if (SpecialItemsPropertyCases.ContainsKey(new Tuple<Item, ItemProperty>(item, prop))) return true; return false; }
private static void LoadObjectDbXml(string file) { var xmlSettings = XElement.Load(file); // Load Colors foreach (var xElement in xmlSettings.Elements("GlobalColors").Elements("GlobalColor")) { string name = (string)xElement.Attribute("Name"); XNA.Color color = XnaColorFromString((string)xElement.Attribute("Color")); GlobalColors.Add(name, color); } foreach (var xElement in xmlSettings.Elements("Tiles").Elements("Tile")) { var curTile = new TileProperty(); // Read XML attributes curTile.Color = ColorFromString((string)xElement.Attribute("Color")); curTile.Name = (string)xElement.Attribute("Name"); curTile.Id = (int?)xElement.Attribute("Id") ?? 0; curTile.IsFramed = (bool?)xElement.Attribute("Framed") ?? false; curTile.IsSolid = (bool?)xElement.Attribute("Solid") ?? false; curTile.IsSolidTop = (bool?)xElement.Attribute("SolidTop") ?? false; curTile.IsLight = (bool?)xElement.Attribute("Light") ?? false; curTile.FrameSize = StringToVector2Short((string)xElement.Attribute("Size"), 1, 1); curTile.Placement = InLineEnumTryParse <FramePlacement>((string)xElement.Attribute("Placement")); curTile.TextureGrid = StringToVector2Short((string)xElement.Attribute("TextureGrid"), 16, 16); curTile.IsGrass = "Grass".Equals((string)xElement.Attribute("Special")); /* Heathtech */ curTile.IsPlatform = "Platform".Equals((string)xElement.Attribute("Special")); /* Heathtech */ curTile.IsCactus = "Cactus".Equals((string)xElement.Attribute("Special")); /* Heathtech */ curTile.IsStone = (bool?)xElement.Attribute("Stone") ?? false; /* Heathtech */ curTile.CanBlend = (bool?)xElement.Attribute("Blends") ?? false; /* Heathtech */ curTile.MergeWith = (int?)xElement.Attribute("MergeWith") ?? null; /* Heathtech */ foreach (var elementFrame in xElement.Elements("Frames").Elements("Frame")) { var curFrame = new FrameProperty(); // Read XML attributes curFrame.Name = (string)elementFrame.Attribute("Name"); curFrame.Variety = (string)elementFrame.Attribute("Variety"); curFrame.UV = StringToVector2Short((string)elementFrame.Attribute("UV"), 0, 0); curFrame.Anchor = InLineEnumTryParse <FrameAnchor>((string)elementFrame.Attribute("Anchor")); // Assign a default name if none existed if (string.IsNullOrWhiteSpace(curFrame.Name)) { curFrame.Name = curTile.Name; } curTile.Frames.Add(curFrame); Sprites.Add(new Sprite { Anchor = curFrame.Anchor, IsPreviewTexture = false, Name = curFrame.Name + ", " + curFrame.Variety, Origin = curFrame.UV, Size = curTile.FrameSize, Tile = (byte)curTile.Id, TileName = curTile.Name }); } if (curTile.Frames.Count == 0 && curTile.IsFramed) { var curFrame = new FrameProperty(); // Read XML attributes curFrame.Name = curTile.Name; curFrame.Variety = string.Empty; curFrame.UV = new Vector2Short(0, 0); //curFrame.Anchor = InLineEnumTryParse<FrameAnchor>((string)xElement.Attribute("Anchor")); // Assign a default name if none existed if (string.IsNullOrWhiteSpace(curFrame.Name)) { curFrame.Name = curTile.Name; } curTile.Frames.Add(curFrame); Sprites.Add(new Sprite { Anchor = curFrame.Anchor, IsPreviewTexture = false, Name = curFrame.Name + ", " + curFrame.Variety, Origin = curFrame.UV, Size = curTile.FrameSize, Tile = (byte)curTile.Id, TileName = curTile.Name }); } TileProperties.Add(curTile); if (!curTile.IsFramed) { TileBricks.Add(curTile); } } for (int i = TileProperties.Count; i < 255; i++) { TileProperties.Add(new TileProperty(i, "UNKNOWN", Color.FromArgb(255, 255, 0, 255), true)); } foreach (var xElement in xmlSettings.Elements("Walls").Elements("Wall")) { var curWall = new WallProperty(); curWall.Color = ColorFromString((string)xElement.Attribute("Color")); curWall.Name = (string)xElement.Attribute("Name"); curWall.Id = (int?)xElement.Attribute("Id") ?? -1; curWall.IsHouse = (bool?)xElement.Attribute("IsHouse") ?? false; WallProperties.Add(curWall); } foreach (var xElement in xmlSettings.Elements("Items").Elements("Item")) { var curItem = new ItemProperty(); curItem.Id = (int?)xElement.Attribute("Id") ?? -1; curItem.Name = (string)xElement.Attribute("Name"); ItemProperties.Add(curItem); _itemLookup.Add(curItem.Id, curItem); } foreach (var xElement in xmlSettings.Elements("Npcs").Elements("Npc")) { int id = (int?)xElement.Attribute("Id") ?? -1; string name = (string)xElement.Attribute("Name"); NpcIds.Add(name, id); NpcNames.Add(id, name); int frames = (int?)xElement.Attribute("Frames") ?? 16; NpcFrames.Add(id, frames); } foreach (var xElement in xmlSettings.Elements("ItemPrefix").Elements("Prefix")) { int id = (int?)xElement.Attribute("Id") ?? -1; string name = (string)xElement.Attribute("Name"); ItemPrefix.Add((byte)id, name); } foreach (var xElement in xmlSettings.Elements("ShortCutKeys").Elements("Shortcut")) { var key = InLineEnumTryParse <Key>((string)xElement.Attribute("Key")); var tool = (string)xElement.Attribute("Tool"); ShortcutKeys.Add(key, tool); } XElement appSettings = xmlSettings.Element("App"); int appWidth = (int?)appSettings.Attribute("Width") ?? 800; int appHeight = (int?)appSettings.Attribute("Height") ?? 600; _appSize = new Vector2(appWidth, appHeight); ToolDefaultData.LoadSettings(xmlSettings.Elements("Tools")); AltC = (string)xmlSettings.Element("AltC"); }
set { SetValue(ItemProperty, value); }
this.SetValue(ItemProperty, value);
/// <summary> /// Constructor /// </summary> /// <param name="property">Which property this effect should be, no default value</param> /// <param name="effect">The intensity of that property, by default 0</param> /// <param name="duration">The duration of that property, by default 0</param> public ItemEffect(ItemProperty property = ItemProperty.Null, int effect = 0, int duration = 0) { _property = property; _effect = effect; _duration = duration; }
public static void NWNX_PushArgumentItemProperty(string pluginName, string functionName, ItemProperty value) { _.TagItemProperty(value, NWNX_INTERNAL_BuildString(pluginName, functionName, "PUSH")); }