コード例 #1
0
 public ItemObject(ItemObject itemToCopy)
     : base((MBObjectBase)itemToCopy)
 {
     this.ItemComponent             = itemToCopy.ItemComponent;
     this.MultiMeshName             = itemToCopy.MultiMeshName;
     this.HolsterMeshName           = itemToCopy.HolsterMeshName;
     this.HolsterWithWeaponMeshName = itemToCopy.HolsterWithWeaponMeshName;
     this.ItemHolsters         = itemToCopy.ItemHolsters;
     this.HolsterPositionShift = itemToCopy.HolsterPositionShift;
     this.FlyingMeshName       = itemToCopy.FlyingMeshName;
     this.BodyName             = itemToCopy.BodyName;
     this.HolsterBodyName      = itemToCopy.HolsterBodyName;
     this.CollisionBodyName    = itemToCopy.CollisionBodyName;
     this.RecalculateBody      = itemToCopy.RecalculateBody;
     this.PrefabName           = itemToCopy.PrefabName;
     this.Name            = itemToCopy.Name;
     this.ItemFlags       = itemToCopy.ItemFlags;
     this.Value           = itemToCopy.Value;
     this.Weight          = itemToCopy.Weight;
     this.Difficulty      = itemToCopy.Difficulty;
     this.ArmBandMeshName = itemToCopy.ArmBandMeshName;
     this.IsFood          = itemToCopy.IsFood;
     this.Type            = itemToCopy.Type;
     this.ScaleFactor     = itemToCopy.ScaleFactor;
     this.IsUniqueItem    = false;
 }
コード例 #2
0
 private void UpdateAllItemList()
 {
     if ((this.cboInvItemFilter.SelectedIndex == -1) || (this.cboInvItemFilter.SelectedIndex == 0))
     {
         this.UpdateAllItemListNoFilter();
     }
     else
     {
         ItemObject.ItemTypeEnum selectedIndex = (ItemObject.ItemTypeEnum) this.cboInvItemFilter.SelectedIndex;
         this.UpdateAllItemList(selectedIndex);
     }
 }
コード例 #3
0
        public static bool IsRangedUnit(CharacterObject troop)
        {
            bool             result = false;
            List <Equipment> list   = troop.BattleEquipments.ToList();

            if (list.Count > 0)
            {
                ItemObject.ItemTypeEnum itemType = list[0].GetEquipmentFromSlot(EquipmentIndex.WeaponItemBeginSlot).Item.ItemType;
                result = (itemType == ItemObject.ItemTypeEnum.Bow || itemType == ItemObject.ItemTypeEnum.Crossbow || itemType == ItemObject.ItemTypeEnum.Thrown);
            }
            return(result);
        }
        private static bool HasItemType(BasicCharacterObject character, ItemObject.ItemTypeEnum itemType)
        {
            for (EquipmentIndex equipmentIndex = EquipmentIndex.WeaponItemBeginSlot; equipmentIndex < EquipmentIndex.NumAllWeaponSlots; equipmentIndex++)
            {
                ItemObject item = character.Equipment[equipmentIndex].Item;
                if (item != null && item.Type == itemType)
                {
                    return(true);
                }
            }

            return(false);
        }
コード例 #5
0
 private void InitializeItem(
     List <ItemObject> items,
     ItemObject item,
     TextObject name,
     string meshName,
     ItemCategory category,
     int value,
     float weight,
     ItemObject.ItemTypeEnum itemType,
     bool isFood = false)
 {
     ItemObject.InitializeTradeGood(item, name, meshName, category, value, weight, itemType, isFood);
     items.Add(item);
 }
コード例 #6
0
 private void UpdateAllItemList(ItemObject.ItemTypeEnum itemType)
 {
     //this.lstAllItems.ShowGroups = false;
     //this.lstAllItems.PrimarySortColumn = null;
     //this.lstAllItems.PrimarySortOrder = SortOrder.None;
     this.lstAllItems.SetObjects(ItemObject.All
                                 .Where(x => x.ItemType == itemType)
                                 .OrderBy(x => (int)x.ItemType)
                                 .ThenBy(x => (int)x.Tier)
                                 .ThenBy(x => x.IsFood ? 1 : 0)
                                 .ThenBy(x => x.Name.ToString())
                                 );
     if (this.lstAllItems.PrimarySortColumn != null)
     {
         this.lstAllItems.Sort();
     }
 }
コード例 #7
0
        public override void Deserialize(MBObjectManager objectManager, XmlNode node)
        {
            base.Deserialize(objectManager, node);
            this.ID = node.Attributes["id"] != null ? node.Attributes["id"].Value : "";
            XmlAttribute attribute = node.Attributes["item_type"];

            if (attribute != null)
            {
                this.ItemTypeEnum = (ItemObject.ItemTypeEnum)Enum.Parse(typeof(ItemObject.ItemTypeEnum), attribute.Value, true);
            }
            this.ItemModifiersWithProbability = new Dictionary <string, ItemModifierProbability>();
            List <ItemModifier> itemModifierList = new List <ItemModifier>();

            foreach (XmlNode childNode in node.ChildNodes)
            {
                ItemModifierProbability modifierProbability = new ItemModifierProbability();
                string key = "";
                if (childNode.Attributes["id"] != null)
                {
                    if (childNode.Attributes["id"].Value != "no_modifier")
                    {
                        modifierProbability.ItemModifier = MBObjectManager.Instance.GetObject <ItemModifier>(childNode.Attributes["id"].Value);
                        key = childNode.Attributes["id"].Value;
                    }
                    else
                    {
                        modifierProbability.ItemModifier = (ItemModifier)null;
                    }
                }
                float result = 0.0f;
                if (childNode.Attributes["probability"] != null)
                {
                    float.TryParse(childNode.Attributes["probability"].Value, out result);
                }
                modifierProbability.Probability = result;
                this.ItemModifiersWithProbability.Add(key, modifierProbability);
                if (modifierProbability.ItemModifier != null)
                {
                    itemModifierList.Add(modifierProbability.ItemModifier);
                }
            }
            this._itemModifiers = itemModifierList.ToArray();
        }
コード例 #8
0
        private static string GetArmorTooltip(ItemRosterElement elem, ItemObject.ItemTypeEnum type)
        {
            switch (type)
            {
            case ItemObject.ItemTypeEnum.HeadArmor:
                return(elem.EquipmentElement.GetModifiedHeadArmor().ToString());

            case ItemObject.ItemTypeEnum.BodyArmor:
                return(elem.EquipmentElement.GetModifiedBodyArmor().ToString());

            case ItemObject.ItemTypeEnum.HorseHarness:
                return(elem.EquipmentElement.GetModifiedMountBodyArmor().ToString());

            case ItemObject.ItemTypeEnum.HandArmor:
                return(elem.EquipmentElement.GetModifiedArmArmor().ToString());

            case ItemObject.ItemTypeEnum.LegArmor:
                return(elem.EquipmentElement.GetModifiedLegArmor().ToString());
            }

            return(null);
        }
コード例 #9
0
 internal static ItemObject InitializeTradeGood(
     ItemObject item,
     TextObject name,
     string meshName,
     ItemCategory category,
     int value,
     float weight,
     ItemObject.ItemTypeEnum itemType,
     bool isFood)
 {
     item.Initialize();
     item.Name          = name;
     item.MultiMeshName = meshName;
     item.ItemCategory  = category;
     item.Value         = value;
     item.Weight        = weight;
     item.ItemType      = itemType;
     item.IsFood        = isFood;
     item.ItemComponent = (ItemComponent) new TradeItemComponent();
     item.AfterInitialized();
     item.ItemFlags |= ItemFlags.Civilian;
     return(item);
 }
コード例 #10
0
        internal static bool GetDefendCollisionResultsAuxPrefix(Mission __instance, Agent attackerAgent, Agent defenderAgent,
                                                                CombatCollisionResult collisionResult, int weaponKind, int currentUsageIndex, bool isAlternativeAttack,
                                                                StrikeType strikeType, Agent.UsageDirection attackDirection, float currentAttackSpeed, float collisionDistanceOnWeapon,
                                                                float attackProgress, bool attackIsParried, ref float defenderStunPeriod, ref float attackerStunPeriod, ref bool crushedThrough,
                                                                ref bool chamber)
        {
            ItemObject          itemFromWeaponKind  = ItemObject.GetItemFromWeaponKind(weaponKind);
            WeaponComponentData weaponComponentData = (itemFromWeaponKind != null) ? itemFromWeaponKind.GetWeaponWithUsageIndex(currentUsageIndex) : null;
            EquipmentIndex      wieldedItemIndex    = defenderAgent.GetWieldedItemIndex(Agent.HandIndex.OffHand);

            if (wieldedItemIndex == EquipmentIndex.None)
            {
                wieldedItemIndex = defenderAgent.GetWieldedItemIndex(Agent.HandIndex.MainHand);
            }
            WeaponComponentData weaponComponentData2 = (wieldedItemIndex != EquipmentIndex.None) ? defenderAgent.Equipment[wieldedItemIndex].CurrentUsageItem : null;
            float num = 10f;

            attackerStunPeriod = ((strikeType == StrikeType.Thrust) ? ManagedParameters.Instance.GetManagedParameter(ManagedParametersEnum.StunPeriodAttackerThrust) : ManagedParameters.Instance.GetManagedParameter(ManagedParametersEnum.StunPeriodAttackerSwing));
            chamber            = false;
            float num2 = 0f;

            if (weaponComponentData != null)
            {
                float z    = attackerAgent.GetCurWeaponOffset().z;
                float num3 = weaponComponentData.GetRealWeaponLength() + z;
                num2 = MBMath.ClampFloat((0.2f + collisionDistanceOnWeapon) / num3, 0.1f, 0.98f);
                float exraLinearSpeed = MissionReversePatches.ComputeRelativeSpeedDiffOfAgents(attackerAgent, defenderAgent);
                float num4;
                if (strikeType == StrikeType.Thrust)
                {
                    num4 = CombatStatCalculator.CalculateBaseBlowMagnitudeForThrust((float)itemFromWeaponKind.PrimaryWeapon.ThrustSpeed / 11.7647057f * MissionReversePatches.SpeedGraphFunction(Mission.Current, attackProgress, strikeType, attackDirection), itemFromWeaponKind.Weight, exraLinearSpeed);
                }
                else
                {
                    num4 = CombatStatCalculator.CalculateBaseBlowMagnitudeForSwing((float)itemFromWeaponKind.PrimaryWeapon.SwingSpeed / 4.5454545f * MissionReversePatches.SpeedGraphFunction(Mission.Current, strikeType, attackDirection), weaponComponentData.GetRealWeaponLength(), itemFromWeaponKind.Weight, weaponComponentData.Inertia, weaponComponentData.CenterOfMass, num2, exraLinearSpeed);
                }
                if (strikeType == StrikeType.Thrust)
                {
                    num4 *= 0.8f;
                }
                else if (attackDirection == Agent.UsageDirection.AttackUp)
                {
                    num4 *= 1.25f;
                }
                num += num4;
            }
            float num5 = 1f;

            defenderStunPeriod = num * ManagedParameters.Instance.GetManagedParameter(ManagedParametersEnum.StunMomentumTransferFactor);
            if (weaponComponentData2 != null)
            {
                if (weaponComponentData2.IsShield)
                {
                    float managedParameter = ManagedParameters.Instance.GetManagedParameter(ManagedParametersEnum.StunDefendWeaponWeightOffsetShield);
                    num5 += managedParameter * weaponComponentData2.Item.Weight;
                }
                else
                {
                    num5 = 0.9f;
                    float managedParameter2 = ManagedParameters.Instance.GetManagedParameter(ManagedParametersEnum.StunDefendWeaponWeightMultiplierWeaponWeight);
                    num5 += managedParameter2 * weaponComponentData2.Item.Weight;
                    ItemObject.ItemTypeEnum itemType = weaponComponentData2.Item.ItemType;
                    if (itemType == ItemObject.ItemTypeEnum.TwoHandedWeapon)
                    {
                        managedParameter2 = ManagedParameters.Instance.GetManagedParameter(ManagedParametersEnum.StunDefendWeaponWeightBonusTwoHanded);
                    }
                    else if (itemType == ItemObject.ItemTypeEnum.Polearm)
                    {
                        num5 += ManagedParameters.Instance.GetManagedParameter(ManagedParametersEnum.StunDefendWeaponWeightBonusPolearm);
                    }
                }
                if (collisionResult == CombatCollisionResult.Parried)
                {
                    attackerStunPeriod += 0.1f;
                    num5 += ManagedParameters.Instance.GetManagedParameter(ManagedParametersEnum.StunDefendWeaponWeightBonusActiveBlocked);


                    if (GCOToolbox.GCOToolbox.MeleeBalance.GCOCheckHyperArmorConfiguration(defenderAgent))
                    {
                        GCOToolbox.GCOToolbox.MeleeBalance.CreateHyperArmorBuff(defenderAgent);
                    }
                }
                else if (collisionResult == CombatCollisionResult.Blocked)
                {
                    if (GCOToolbox.GCOToolbox.MeleeBalance.GCOCheckHyperArmorConfiguration(defenderAgent))
                    {
                        GCOToolbox.GCOToolbox.MeleeBalance.CreateHyperArmorBuff(defenderAgent);
                    }
                }
                else if (collisionResult == CombatCollisionResult.ChamberBlocked)
                {
                    attackerStunPeriod += 0.2f;
                    num5   += ManagedParameters.Instance.GetManagedParameter(ManagedParametersEnum.StunDefendWeaponWeightBonusChamberBlocked);
                    chamber = true;
                }
            }
            if (!defenderAgent.GetIsLeftStance())
            {
                num5 += ManagedParameters.Instance.GetManagedParameter(ManagedParametersEnum.StunDefendWeaponWeightBonusRightStance);
            }
            defenderStunPeriod /= num5;
            float managedParameter3 = ManagedParameters.Instance.GetManagedParameter(ManagedParametersEnum.StunPeriodMax);

            attackerStunPeriod = Math.Min(attackerStunPeriod, managedParameter3);
            defenderStunPeriod = Math.Min(defenderStunPeriod, managedParameter3);
            crushedThrough     = (num > 38f && defenderStunPeriod > managedParameter3 - 0.03f && num2 > 0.5f);
            MissionGameModels.Current.AgentApplyDamageModel.CalculateEffects(attackerAgent, ref crushedThrough);
            if (chamber)
            {
                crushedThrough = false;
            }

            return(false);
        }
コード例 #11
0
        public override void Deserialize(MBObjectManager objectManager, XmlNode node)
        {
            base.Deserialize(objectManager, node);
            if (node.Name == "CraftedItem")
            {
                XmlNode attribute1 = (XmlNode)node.Attributes["multiplayer_item"];
                if (attribute1 != null && !string.IsNullOrEmpty(attribute1.InnerText))
                {
                    this.MultiplayerItem = attribute1.InnerText == "true";
                }
                XmlNode attribute2 = (XmlNode)node.Attributes["is_merchandise"];
                if (attribute2 != null && !string.IsNullOrEmpty(attribute2.InnerText))
                {
                    this.NotMerchandise = attribute2.InnerText != "true";
                }
                TextObject        weaponName        = new TextObject(node.Attributes["name"].InnerText);
                string            innerText1        = node.Attributes["crafting_template"].InnerText;
                int               num               = node.Attributes["has_modifier"] == null ? 1 : (node.Attributes["has_modifier"].InnerText != "false" ? 1 : 0);
                string            objectName        = node.Attributes["item_modifier_group"]?.Value;
                ItemModifierGroup itemModifierGroup = (ItemModifierGroup)null;
                if (num != 0)
                {
                    itemModifierGroup = objectName != null?Game.Current.ObjectManager.GetObject <ItemModifierGroup>(objectName) : CraftingTemplate.GetTemplateFromId(innerText1).ItemModifierGroup;
                }
                WeaponDesignElement[] usedPieces = new WeaponDesignElement[4];
                XmlNode xmlNode = (XmlNode)null;
                for (int i = 0; i < node.ChildNodes.Count; ++i)
                {
                    if (node.ChildNodes[i].Name == "Pieces")
                    {
                        xmlNode = node.ChildNodes[i];
                        break;
                    }
                }
                foreach (XmlNode childNode in xmlNode.ChildNodes)
                {
                    if (childNode.Name == "Piece")
                    {
                        XmlAttribute             attribute3    = childNode.Attributes["id"];
                        XmlAttribute             attribute4    = childNode.Attributes["Type"];
                        XmlAttribute             attribute5    = childNode.Attributes["scale_factor"];
                        string                   innerText2    = attribute3.InnerText;
                        CraftingPiece.PieceTypes pieceTypes    = (CraftingPiece.PieceTypes)Enum.Parse(typeof(CraftingPiece.PieceTypes), attribute4.InnerText);
                        CraftingPiece            craftingPiece = MBObjectManager.Instance.GetObject <CraftingPiece>(innerText2);
                        usedPieces[(int)pieceTypes] = WeaponDesignElement.CreateUsablePiece(craftingPiece);
                        if (attribute5 != null)
                        {
                            usedPieces[(int)pieceTypes].SetScale(int.Parse(attribute5.Value));
                        }
                    }
                }
                float weightOverriden = node.Attributes["weight"] != null?float.Parse(node.Attributes["weight"].Value) : 0.0f;

                int swingSpeedOverriden = node.Attributes["swing_speed"] != null?int.Parse(node.Attributes["swing_speed"].Value) : 0;

                int thrustSpeedOverriden = node.Attributes["thrust_speed"] != null?int.Parse(node.Attributes["thrust_speed"].Value) : 0;

                int swingDamageOverriden = node.Attributes["swing_damage"] != null?int.Parse(node.Attributes["swing_damage"].Value) : 0;

                int thrustDamageOverriden = node.Attributes["thrust_damage"] != null?int.Parse(node.Attributes["thrust_damage"].Value) : 0;

                ItemObject preCraftedWeapon = Crafting.CreatePreCraftedWeapon(this, usedPieces, innerText1, weaponName, new Crafting.OverrideData(weightOverriden, swingSpeedOverriden, thrustSpeedOverriden, swingDamageOverriden, thrustDamageOverriden), itemModifierGroup);
                if (DefaultItems.Instance != null && preCraftedWeapon == DefaultItems.Trash)
                {
                    MBObjectManager.Instance.UnregisterObject((MBObjectBase)this);
                    return;
                }
                this.Effectiveness = this.CalculateEffectiveness();
                this.Value         = node.Attributes["value"] != null?int.Parse(node.Attributes["value"].Value) : this.CalculateValue();

                if (node.Attributes["culture"] != null)
                {
                    this.Culture = (BasicCultureObject)objectManager.ReadObjectReferenceFromXml("culture", typeof(BasicCultureObject), node);
                }
                this.PrerequisiteItem = node.Attributes["prerequisite_item"] != null ? (ItemObject)objectManager.ReadObjectReferenceFromXml("prerequisite_item", typeof(ItemObject), node) : (ItemObject)null;
            }
            else
            {
                this.Name = new TextObject(node.Attributes["name"].InnerText);
                XmlNode attribute1 = (XmlNode)node.Attributes["multiplayer_item"];
                if (attribute1 != null && !string.IsNullOrEmpty(attribute1.InnerText))
                {
                    this.MultiplayerItem = attribute1.InnerText == "true";
                }
                XmlNode attribute2 = (XmlNode)node.Attributes["is_merchandise"];
                if (attribute2 != null && !string.IsNullOrEmpty(attribute2.InnerText))
                {
                    this.NotMerchandise = attribute2.InnerText != "true";
                }
                this.PrerequisiteItem = node.Attributes["prerequisite_item"] != null ? (ItemObject)objectManager.ReadObjectReferenceFromXml("prerequisite_item", typeof(ItemObject), node) : (ItemObject)null;
                XmlNode attribute3 = (XmlNode)node.Attributes["mesh"];
                if (attribute3 != null && !string.IsNullOrEmpty(attribute3.InnerText))
                {
                    this.MultiMeshName = attribute3.InnerText;
                }
                this.HolsterMeshName           = node.Attributes["holster_mesh"] != null ? node.Attributes["holster_mesh"].Value : (string)null;
                this.HolsterWithWeaponMeshName = node.Attributes["holster_mesh_with_weapon"] != null ? node.Attributes["holster_mesh_with_weapon"].Value : (string)null;
                this.FlyingMeshName            = node.Attributes["flying_mesh"] != null ? node.Attributes["flying_mesh"].Value : (string)null;
                this.HasLowerHolsterPriority   = false;
                if (node.Attributes["item_holsters"] != null)
                {
                    this.ItemHolsters = node.Attributes["item_holsters"].Value.Split(':');
                    if (node.Attributes["has_lower_holster_priority"] != null)
                    {
                        this.HasLowerHolsterPriority = bool.Parse(node.Attributes["has_lower_holster_priority"].Value);
                    }
                }
                this.HolsterPositionShift = node.Attributes["holster_position_shift"] != null?Vec3.Parse(node.Attributes["holster_position_shift"].Value) : Vec3.Zero;

                this.BodyName          = node.Attributes["body_name"] != null ? node.Attributes["body_name"].Value : (string)null;
                this.HolsterBodyName   = node.Attributes["holster_body_name"] != null ? node.Attributes["holster_body_name"].Value : (string)null;
                this.CollisionBodyName = node.Attributes["shield_body_name"] != null ? node.Attributes["shield_body_name"].Value : (string)null;
                this.RecalculateBody   = node.Attributes["recalculate_body"] != null && bool.Parse(node.Attributes["recalculate_body"].Value);
                XmlNode attribute4 = (XmlNode)node.Attributes["prefab"];
                this.PrefabName = attribute4 == null || string.IsNullOrEmpty(attribute4.InnerText) ? "" : attribute4.InnerText;
                this.Culture    = (BasicCultureObject)objectManager.ReadObjectReferenceFromXml("culture", typeof(BasicCultureObject), node);
                string objectName = node.Attributes["item_category"] != null ? node.Attributes["item_category"].Value : (string)null;
                if (!string.IsNullOrEmpty(objectName))
                {
                    this.ItemCategory = Game.Current.ObjectManager.GetObject <ItemCategory>(objectName);
                }
                this.Weight = node.Attributes["weight"] != null?float.Parse(node.Attributes["weight"].Value) : 1f;

                this.LodAtlasIndex = node.Attributes["lod_atlas_index"] != null?int.Parse(node.Attributes["lod_atlas_index"].Value) : -1;

                XmlAttribute attribute5 = node.Attributes["difficulty"];
                if (attribute5 != null)
                {
                    this.Difficulty = int.Parse(attribute5.Value);
                }
                XmlAttribute attribute6 = node.Attributes["appearance"];
                this.Appearance = attribute6 != null?float.Parse(attribute6.Value) : 0.5f;

                XmlAttribute attribute7 = node.Attributes["IsFood"];
                if (attribute7 != null)
                {
                    this.IsFood = Convert.ToBoolean(attribute7.InnerText);
                }
                this.IsUsingTableau = node.Attributes["using_tableau"] != null && Convert.ToBoolean(node.Attributes["using_tableau"].InnerText);
                XmlNode attribute8 = (XmlNode)node.Attributes["using_arm_band"];
                if (attribute8 != null)
                {
                    this.ArmBandMeshName = Convert.ToString(attribute8.InnerText);
                }
                this.ScaleFactor = node.Attributes["scale_factor"] != null?float.Parse(node.Attributes["scale_factor"].Value) : 1f;

                this.ItemFlags = (ItemFlags)0;
                foreach (XmlNode childNode1 in node.ChildNodes)
                {
                    if (childNode1.Name == "ItemComponent")
                    {
                        foreach (XmlNode childNode2 in childNode1.ChildNodes)
                        {
                            if (childNode2.NodeType != XmlNodeType.Comment)
                            {
                                string        name = childNode2.Name;
                                ItemComponent itemComponent;
                                if (!(name == "Armor"))
                                {
                                    if (!(name == "Weapon"))
                                    {
                                        if (!(name == "Horse"))
                                        {
                                            if (!(name == "Trade"))
                                            {
                                                if (!(name == "Food"))
                                                {
                                                    throw new Exception("Wrong ItemComponent type.");
                                                }
                                                itemComponent = (ItemComponent)null;
                                            }
                                            else
                                            {
                                                itemComponent = (ItemComponent) new TradeItemComponent();
                                            }
                                        }
                                        else
                                        {
                                            itemComponent = (ItemComponent) new HorseComponent();
                                        }
                                    }
                                    else
                                    {
                                        itemComponent = (ItemComponent) new WeaponComponent(this);
                                    }
                                }
                                else
                                {
                                    itemComponent = (ItemComponent) new ArmorComponent(this);
                                }
                                if (itemComponent != null)
                                {
                                    itemComponent.Deserialize(objectManager, childNode2);
                                    this.ItemComponent = itemComponent;
                                }
                            }
                        }
                    }
                    else if (childNode1.Name == "Flags")
                    {
                        foreach (ItemFlags itemFlags in Enum.GetValues(typeof(ItemFlags)))
                        {
                            XmlAttribute attribute9 = childNode1.Attributes[itemFlags.ToString()];
                            if (attribute9 != null && attribute9.Value.ToLowerInvariant() != "false")
                            {
                                this.ItemFlags |= itemFlags;
                            }
                        }
                    }
                }
                XmlAttribute attribute10 = node.Attributes["Type"];
                if (attribute10 != null)
                {
                    this.Type = (ItemObject.ItemTypeEnum)Enum.Parse(typeof(ItemObject.ItemTypeEnum), attribute10.Value, true);
                    if (this.WeaponComponent != null)
                    {
                        ItemObject.ItemTypeEnum itemType = this.WeaponComponent.GetItemType();
                        if (this.Type != itemType)
                        {
                            TaleWorlds.Library.Debug.Print("ItemType for \"" + this.StringId + "\" has been overridden by WeaponClass from \"" + (object)this.Type + "\" to \"" + (object)itemType + "\"", color: TaleWorlds.Library.Debug.DebugColor.Red, debugFilter: 64UL);
                        }
                        this.Type = itemType;
                    }
                }
                XmlAttribute attribute11 = node.Attributes["AmmoOffset"];
                if (attribute11 != null)
                {
                    string[] strArray = attribute11.Value.Split(',');
                    this.WeaponComponent.PrimaryWeapon.SetAmmoOffset(new Vec3());
                    if (strArray.Length == 3)
                    {
                        try
                        {
                            this.WeaponComponent.PrimaryWeapon.SetAmmoOffset(new Vec3(float.Parse(strArray[0], (IFormatProvider)CultureInfo.InvariantCulture), float.Parse(strArray[1], (IFormatProvider)CultureInfo.InvariantCulture), float.Parse(strArray[2], (IFormatProvider)CultureInfo.InvariantCulture)));
                        }
                        catch (Exception ex)
                        {
                        }
                    }
                }
                this.Effectiveness = this.CalculateEffectiveness();
                this.Value         = node.Attributes["value"] != null?int.Parse(node.Attributes["value"].Value) : this.CalculateValue();

                if (this.PrimaryWeapon != null)
                {
                    if (this.PrimaryWeapon.IsMeleeWeapon || this.PrimaryWeapon.IsRangedWeapon)
                    {
                        if (!string.IsNullOrEmpty(this.BodyName))
                        {
                            ;
                        }
                    }
                    else if (this.PrimaryWeapon.IsConsumable)
                    {
                        string.IsNullOrEmpty(this.HolsterBodyName);
                        if (!string.IsNullOrEmpty(this.BodyName))
                        {
                            ;
                        }
                    }
                    else if (this.PrimaryWeapon.IsShield)
                    {
                        if (!string.IsNullOrEmpty(this.BodyName))
                        {
                            int num = this.RecalculateBody ? 1 : 0;
                        }
                        string.IsNullOrEmpty(this.CollisionBodyName);
                    }
                }
            }
            this.DetermineItemCategoryForItem();
        }
コード例 #12
0
 public static IEnumerable <ItemObject> GetItemsByType(ItemObject.ItemTypeEnum type)
 {
     return(Items.FindAll(x => x.ItemType == type));
 }
コード例 #13
0
        private void GetItemPoseAndCamera(ItemObject item, Scene scene, ref Camera camera, 
	        ref MatrixFrame itemFrame, ref MatrixFrame itemFrame1, ref MatrixFrame itemFrame2)
		{
			if (item.IsCraftedWeapon)
			{
				GetItemPoseAndCameraForCraftedItem(item, scene, ref camera, ref itemFrame, ref itemFrame1, ref itemFrame2);
				return;
			}
			string str = "";
			bool flag = false;
			if (item.WeaponComponent != null)
			{
				WeaponClass weaponClass = item.WeaponComponent.PrimaryWeapon.WeaponClass;
				if (weaponClass - WeaponClass.OneHandedSword <= 1)
				{
					str = "sword";
					flag = true;
				}
			}
			else
			{
				ItemObject.ItemTypeEnum type = item.Type;
				if (type != ItemObject.ItemTypeEnum.HeadArmor)
				{
					if (type == ItemObject.ItemTypeEnum.BodyArmor)
					{
						str = "armor";
						flag = true;
					}
				}
				else
				{
					str = "helmet";
					flag = true;
				}
			}
			if (item.Type == ItemObject.ItemTypeEnum.Shield)
			{
				str = "shield";
				flag = true;
			}
			if (item.Type == ItemObject.ItemTypeEnum.Crossbow)
			{
				str = "crossbow";
				flag = true;
			}
			if (item.Type == ItemObject.ItemTypeEnum.Bow)
			{
				str = "bow";
				flag = true;
			}
			if (item.Type == ItemObject.ItemTypeEnum.LegArmor)
			{
				str = "boot";
				flag = true;
			}
			if (item.Type == ItemObject.ItemTypeEnum.Horse || item.Type == ItemObject.ItemTypeEnum.HorseHarness)
			{
				str = "horse";
				flag = true;
			}
			if (item.Type == ItemObject.ItemTypeEnum.Cape)
			{
				str = "cape";
				flag = true;
			}
			if (item.Type == ItemObject.ItemTypeEnum.HandArmor)
			{
				str = "glove";
				flag = true;
			}
			if (item.Type == ItemObject.ItemTypeEnum.Arrows)
			{
				str = "arrow";
				flag = true;
			}
			if (item.Type == ItemObject.ItemTypeEnum.Bolts)
			{
				str = "bolt";
				flag = true;
			}
			Game game = Game.Current;
			if (((game != null) ? game.DefaultItems : null) != null && (item == DefaultItems.IronOre || item == DefaultItems.HardWood || item == DefaultItems.Charcoal || item == DefaultItems.IronIngot1 || item == DefaultItems.IronIngot2 || item == DefaultItems.IronIngot3 || item == DefaultItems.IronIngot4 || item == DefaultItems.IronIngot5 || item == DefaultItems.IronIngot6 || item.ItemCategory == DefaultItemCategories.Silver))
			{
				str = "craftmat";
				flag = true;
			}
			string tag = str + "_cam";
			string tag2 = str + "_frame";
			if (flag)
			{
				GameEntity gameEntity = scene.FindEntityWithTag(tag);
				if (gameEntity != null)
				{
					camera = Camera.CreateCamera();
					Vec3 vec = default(Vec3);
					gameEntity.GetCameraParamsFromCameraScript(camera, ref vec);
				}
				GameEntity gameEntity2 = scene.FindEntityWithTag(tag2);
				if (gameEntity2 != null)
				{
					itemFrame = gameEntity2.GetGlobalFrame();
					gameEntity2.SetVisibilityExcludeParents(false);
				}
			}
			else
			{
				GameEntity gameEntity3 = scene.FindEntityWithTag("goods_cam");
				if (gameEntity3 != null)
				{
					camera = Camera.CreateCamera();
					Vec3 vec2 = default(Vec3);
					gameEntity3.GetCameraParamsFromCameraScript(camera, ref vec2);
				}
				GameEntity gameEntity4 = scene.FindEntityWithTag("goods_frame");
				if (gameEntity4 != null)
				{
					itemFrame = gameEntity4.GetGlobalFrame();
					gameEntity4.SetVisibilityExcludeParents(false);
					gameEntity4.UpdateGlobalBounds();
					MatrixFrame globalFrame = gameEntity4.GetGlobalFrame();
					MetaMesh itemMeshForInventory = new ItemRosterElement(item, 0, null).GetItemMeshForInventory(false);
					Vec3 vec3 = new Vec3(1000000f, 1000000f, 1000000f, -1f);
					Vec3 vec4 = new Vec3(-1000000f, -1000000f, -1000000f, -1f);
					if (itemMeshForInventory != null)
					{
						MatrixFrame identity = MatrixFrame.Identity;
						for (int num = 0; num != itemMeshForInventory.MeshCount; num++)
						{
							Vec3 boundingBoxMin = itemMeshForInventory.GetMeshAtIndex(num).GetBoundingBoxMin();
							Vec3 boundingBoxMax = itemMeshForInventory.GetMeshAtIndex(num).GetBoundingBoxMax();
							Vec3[] array = new Vec3[]
							{
								globalFrame.TransformToParent(new Vec3(boundingBoxMin.x, boundingBoxMin.y, boundingBoxMin.z, -1f)),
								globalFrame.TransformToParent(new Vec3(boundingBoxMin.x, boundingBoxMin.y, boundingBoxMax.z, -1f)),
								globalFrame.TransformToParent(new Vec3(boundingBoxMin.x, boundingBoxMax.y, boundingBoxMin.z, -1f)),
								globalFrame.TransformToParent(new Vec3(boundingBoxMin.x, boundingBoxMax.y, boundingBoxMax.z, -1f)),
								globalFrame.TransformToParent(new Vec3(boundingBoxMax.x, boundingBoxMin.y, boundingBoxMin.z, -1f)),
								globalFrame.TransformToParent(new Vec3(boundingBoxMax.x, boundingBoxMin.y, boundingBoxMax.z, -1f)),
								globalFrame.TransformToParent(new Vec3(boundingBoxMax.x, boundingBoxMax.y, boundingBoxMin.z, -1f)),
								globalFrame.TransformToParent(new Vec3(boundingBoxMax.x, boundingBoxMax.y, boundingBoxMax.z, -1f))
							};
							for (int i = 0; i < 8; i++)
							{
								vec3 = Vec3.Vec3Min(vec3, array[i]);
								vec4 = Vec3.Vec3Max(vec4, array[i]);
							}
						}
					}
					Vec3 v = (vec3 + vec4) * 0.5f;
					Vec3 v2 = gameEntity4.GetGlobalFrame().TransformToLocal(v);
					MatrixFrame globalFrame2 = gameEntity4.GetGlobalFrame();
					globalFrame2.origin -= v2;
					itemFrame = globalFrame2;
					MatrixFrame frame = camera.Frame;
					float f = (vec4 - vec3).Length * 6f;
					if (item.Type == ItemObject.ItemTypeEnum.Animal)
					{
						f = (vec4 - vec3).Length * 3f;
					}
					frame.origin += frame.rotation.u * f;
					camera.Frame = frame;
				}
			}
			if (camera == null)
			{
				camera = Camera.CreateCamera();
				camera.SetViewVolume(false, -1f, 1f, -0.5f, 0.5f, 0.01f, 100f);
				MatrixFrame identity2 = MatrixFrame.Identity;
				identity2.origin -= identity2.rotation.u * 7f;
				identity2.rotation.u = identity2.rotation.u * -1f;
				camera.Frame = identity2;
			}
			if (item.Type == ItemObject.ItemTypeEnum.Shield)
			{
				GameEntity gameEntity5 = scene.FindEntityWithTag(tag);
				MatrixFrame holsterFrameByIndex = MBItem.GetHolsterFrameByIndex(MBItem.GetItemHolsterIndex(item.ItemHolsters[0]));
				itemFrame.rotation = holsterFrameByIndex.rotation;
				MatrixFrame frame2 = itemFrame.TransformToParent(gameEntity5.GetFrame());
				camera.Frame = frame2;
			}
		}