示例#1
0
        private void Deserialize(string path)
        {
            XmlDocument doc = new XmlDocument();

            doc.Load(path);
            foreach (XmlNode node in doc.DocumentElement)
            {
                if (node.NodeType == XmlNodeType.Comment)
                {
                    continue;
                }

                PatrolData      dat        = new PatrolData();
                MBObjectManager objManager = Game.Current.ObjectManager;

                if (node.Name == "DetachmentSignifier")
                {
                    dat.templateName = node.Attributes["template"] == null ? "" : node.Attributes["template"].InnerText;
                    dat.name         = node.Attributes["name"] == null ? "" : node.Attributes["name"].InnerText;
                    dat.description  = node.Attributes["desc"] == null ? "" : node.Attributes["desc"].InnerText;
                    dat.sizes        = node.Attributes["sizes"] == null ? "small" : node.Attributes["sizes"].InnerText;

                    dat.basePrice = node.Attributes["base_price"] == null ? 0 : int.Parse(node.Attributes["base_price"].InnerText);
                    dat.priceStep = node.Attributes["price_step"] == null ? 1 : int.Parse(node.Attributes["price_step"].InnerText);
                    dat.culture   = (CultureObject)objManager.ReadObjectReferenceFromXml("culture", typeof(CultureObject), node);
                }

                patrols.Add(dat);
            }
        }
        public static bool Prefix(ref string __result, ref string baseSkinsXmlPath)
        {
            Debug.Print(DebugString.ToString());

            // Why do I have to clone and modify two separate methods? - Designer225
            List <string> usedPaths = new List <string>();
            List <Tuple <string, string> > toBeMerged = new List <Tuple <string, string> >();
            List <string> xsltList = new List <string>();

            List <MbObjectXmlInformation> mbprojXmlList = XmlResource.MbprojXmls.Where(x => x.Id == "soln_skins").ToList();

            mbprojXmlList.Reverse(); // restored for compatibility reason with mods that modify skin.xml that load later.

            foreach (MbObjectXmlInformation mbprojXml in mbprojXmlList)
            {
                if (File.Exists(ModuleInfo.GetXmlPathForNative(mbprojXml.ModuleName, mbprojXml.Name)))
                {
                    usedPaths.Add(ModuleInfo.GetXmlPathForNativeWBase(mbprojXml.ModuleName, mbprojXml.Name));
                    toBeMerged.Add(Tuple.Create(ModuleInfo.GetXmlPathForNative(mbprojXml.ModuleName, mbprojXml.Name), string.Empty));
                }
                string xsltPathForNative = ModuleInfo.GetXsltPathForNative(mbprojXml.ModuleName, mbprojXml.Name);

                xsltList.Add(File.Exists(xsltPathForNative) ? xsltPathForNative : string.Empty);
            }
            XmlDocument mergedXmlForNative = MBObjectManager.CreateMergedXmlFile(toBeMerged, xsltList, true);

            System.IO.StringWriter stringWriter  = new System.IO.StringWriter();
            XmlTextWriter          xmlTextWriter = new XmlTextWriter(stringWriter);

            mergedXmlForNative.WriteTo(xmlTextWriter);
            baseSkinsXmlPath = usedPaths.First();
            __result         = stringWriter.ToString();

            return(false);
        }
        protected override void OnInitialize()
        {
            Game currentGame = this.CurrentGame;

            currentGame.FirstInitialize(false);
            this.InitializeGameTexts(currentGame.GameTextManager);
            IGameStarter gameStarter = (IGameStarter) new BasicGameStarter();

            this.InitializeGameModels(gameStarter);
            this.GameManager.OnGameStart(this.CurrentGame, gameStarter);
            MBObjectManager objectManager = currentGame.ObjectManager;

            currentGame.SecondInitialize(gameStarter.Models);
            currentGame.CreateGameManager();
            this.GameManager.BeginGameStart(this.CurrentGame);
            this.CurrentGame.ThirdInitialize();
            currentGame.CreateObjects();
            currentGame.InitializeDefaultGameObjects();
            currentGame.LoadBasicFiles(false);
            this.LoadCustomGameXmls();
            objectManager.ClearEmptyObjects();
            currentGame.SetDefaultEquipments((IReadOnlyDictionary <string, Equipment>) new Dictionary <string, Equipment>());
            currentGame.CreateLists();
            objectManager.ClearEmptyObjects();
            this.GameManager.OnCampaignStart(this.CurrentGame, (object)null);
            this.GameManager.OnAfterCampaignStart(this.CurrentGame);
            this.GameManager.OnGameInitializationFinished(this.CurrentGame);
        }
 protected override void OnRegisterTypes(MBObjectManager objectManager)
 {
     objectManager.RegisterType <BasicCharacterObject>("NPCCharacter", "MPCharacters", 43U, true);
     objectManager.RegisterType <BasicCultureObject>("Culture", "BasicCultures", 17U, true);
     objectManager.RegisterType <MultiplayerClassDivisions.MPHeroClass>("MPClassDivision", "MPClassDivisions",
                                                                        45U, true);
 }
        protected override void OnInitialize()
        {
            TaleWorlds.Core.Game currentGame = this.CurrentGame;
            currentGame.FirstInitialize(false);
            InitializeGameTexts(currentGame.GameTextManager);
            IGameStarter gameStarter = new BasicGameStarter();

            InitializeGameModels(gameStarter);
            GameManager.OnGameStart(currentGame, gameStarter);
            MBObjectManager objectManager = currentGame.ObjectManager;

            currentGame.SecondInitialize(gameStarter.Models);
            currentGame.CreateGameManager();
            GameManager.BeginGameStart(currentGame);
            currentGame.ThirdInitialize();
            currentGame.CreateObjects();
            currentGame.InitializeDefaultGameObjects();
            currentGame.LoadBasicFiles(false);
            LoadXmls();
            currentGame.SetDefaultEquipments((IReadOnlyDictionary <string, Equipment>) new Dictionary <string, Equipment>());
            currentGame.CreateLists();
            ObjectManager.LoadXML("MPClassDivisions");
            objectManager.ClearEmptyObjects();
            MultiplayerClassDivisions.Initialize();
            GameManager.OnCampaignStart(this.CurrentGame, (object)null);
            GameManager.OnAfterCampaignStart(this.CurrentGame);
            GameManager.OnGameInitializationFinished(this.CurrentGame);
            CurrentGame.AddGameHandler <ChatBox>();
        }
        public static bool Prefix(ref string __result, ref string baseSkinsXmlPath)
        {
            List <string> elementNameList             = new List <string>();
            List <Tuple <string, string> > toBeMerged = new List <Tuple <string, string> >();
            List <string> xsltList = new List <string>();
            List <MbObjectXmlInformation> mbprojXmlList = XmlResource.MbprojXmls.Where(x => x.Id == "soln_skins").ToList();

            mbprojXmlList.Reverse();

            foreach (MbObjectXmlInformation mbprojXml in mbprojXmlList)
            {
                if (File.Exists(ModuleHelper.GetXmlPathForNative(mbprojXml.ModuleName, mbprojXml.Name)))
                {
                    elementNameList.Add(ModuleHelper.GetXmlPathForNativeWBase(mbprojXml.ModuleName, mbprojXml.Name));
                    toBeMerged.Add(Tuple.Create(ModuleHelper.GetXmlPathForNative(mbprojXml.ModuleName, mbprojXml.Name), string.Empty));
                }
                string xsltPathForNative = ModuleHelper.GetXsltPathForNative(mbprojXml.ModuleName, mbprojXml.Name);

                xsltList.Add(File.Exists(xsltPathForNative) ? xsltPathForNative : string.Empty);
            }
            XmlDocument mergedXmlForNative = MBObjectManager.CreateMergedXmlFile(toBeMerged, xsltList, true);

            System.IO.StringWriter stringWriter  = new System.IO.StringWriter();
            XmlTextWriter          xmlTextWriter = new XmlTextWriter(stringWriter);

            mergedXmlForNative.WriteTo(xmlTextWriter);
            baseSkinsXmlPath = elementNameList.First();
            __result         = stringWriter.ToString();

            return(false);
        }
 public static void ActivateSceneEditorPresentation()
 {
     Monster.GetBoneIndexWithId = new Func <string, string, sbyte>(MBActionSet.GetBoneIndexWithId);
     MBObjectManager.Init();
     MBObjectManager.Instance.RegisterType <Monster>("Monster", "Monsters", 2U);
     MBObjectManager.Instance.LoadXML("Monsters", skipXmlFilterForEditor: true);
     MBAPI.IMBEditor.ActivateSceneEditorPresentation();
 }
示例#8
0
        // all of this is really really bad but idc
        public static List <InquiryElement> AssemblePatrolSizes(PatrolData dat)
        {
            MBObjectManager       objManager = Game.Current.ObjectManager;
            List <InquiryElement> list       = new List <InquiryElement>();

            CharacterObject ch1 = objManager.GetObject <CharacterObject>("looter");
            CharacterObject ch2 = objManager.GetObject <CharacterObject>("imperial_recruit");
            CharacterObject ch3 = objManager.GetObject <CharacterObject>("imperial_infantryman");
            CharacterObject ch4 = objManager.GetObject <CharacterObject>("imperial_veteran_infantryman");

            if (dat.sizes.Contains("small"))
            {
                list.Add(new InquiryElement(dat, "Small " + "(" + dat.basePrice.ToString() + " gold)", new ImageIdentifier(CharacterCode.CreateFrom(ch1))));
            }
            if (dat.sizes.Contains("medium"))
            {
                if (Hero.MainHero.Gold >= dat.basePrice + dat.priceStep)
                {
                    list.Add(new InquiryElement(dat, "Medium " + "(" + (dat.basePrice + dat.priceStep).ToString() + " gold)", new ImageIdentifier(CharacterCode.CreateFrom(ch2))));
                }
                else
                {
                    list.Add(new InquiryElement(dat, "Medium " + "(" + (dat.basePrice + dat.priceStep).ToString() + " gold)", new ImageIdentifier(CharacterCode.CreateFrom(ch2)), false, "You do not have enough gold to purchase this size"));
                }
            }
            if (dat.sizes.Contains("large"))
            {
                if (Hero.MainHero.Gold >= dat.basePrice + (dat.priceStep * 2))
                {
                    list.Add(new InquiryElement(dat, "Large " + "(" + (dat.basePrice + (dat.priceStep * 2)).ToString() + " gold)", new ImageIdentifier(CharacterCode.CreateFrom(ch3))));
                }
                else
                {
                    list.Add(new InquiryElement(dat, "Large " + "(" + (dat.basePrice + (dat.priceStep * 2)).ToString() + " gold)", new ImageIdentifier(CharacterCode.CreateFrom(ch3)), false, "You do not have enough gold to purchase this size"));
                }
            }
            if (dat.sizes.Contains("huge"))
            {
                if (Hero.MainHero.Gold >= dat.basePrice + (dat.priceStep * 3))
                {
                    list.Add(new InquiryElement(dat, "Large " + "(" + (dat.basePrice + (dat.priceStep * 3)).ToString() + " gold)", new ImageIdentifier(CharacterCode.CreateFrom(ch4))));
                }
                else
                {
                    list.Add(new InquiryElement(dat, "Large " + "(" + (dat.basePrice + (dat.priceStep * 3)).ToString() + " gold)", new ImageIdentifier(CharacterCode.CreateFrom(ch4)), false, "You do not have enough gold to purchase this size"));
                }
            }

            if (list.Count == 0)
            {
                throw new Exception("Assembling sizes of patrol {" + dat.templateName + "} failed");
            }
            else
            {
                return(list);
            }
        }
示例#9
0
        /// <summary>
        /// Loads settings from XML files into memory. Fails if there is no default file.
        /// If both default and custom files are present, checks if custom has "override"
        /// element and either merges both lists or only uses custom.
        /// </summary>
        /// <returns><see langword="true"/> if successful, <see langword="false"/> if failed.</returns>
        private bool LoadSettings()
        {
            if (!File.Exists(DefaultFilePath))
            {
                return(false);
            }

            if (File.Exists(CustomFilePath))
            {
                XmlDocument defaultItems = MBObjectManager.ToXmlDocument(XDocument.Load(DefaultFilePath));
                XmlDocument customItems  = MBObjectManager.ToXmlDocument(XDocument.Load(CustomFilePath));

                bool shouldOverride = bool.Parse(customItems.GetElementsByTagName("Override")[0].InnerText);

                if (shouldOverride)
                {
                    settings = ReadXml("CustomItems");
                }
                else
                {
                    XmlDocument mergedItems = MBObjectManager.MergeTwoXmls(defaultItems, customItems);

                    settings = MergeItemsInXDocument(MBObjectManager.ToXDocument(mergedItems));
                }
            }
            else
            {
                settings = ReadXml("DefaultItems");
            }

            if (Directory.Exists(ModsDir))
            {
                string[] files = Directory.GetFiles(ModsDir);

                if (files.Length < 1)
                {
                    return(true);
                }

                foreach (string file in files)
                {
                    if (!file.EndsWith(".xml"))
                    {
                        continue;
                    }

                    XmlDocument modXml      = MBObjectManager.ToXmlDocument(XDocument.Load(file));
                    XmlDocument mergedItems = MBObjectManager.MergeTwoXmls(modXml, MBObjectManager.ToXmlDocument(settings));

                    settings = MergeItemsInXDocument(MBObjectManager.ToXDocument(mergedItems));
                }
            }

            return(true);
        }
示例#10
0
            public override void Deserialize(MBObjectManager objectManager, XmlNode node)
            {
                base.Deserialize(objectManager, node);
                this.HeroCharacter  = MultiplayerClassDivisions.GetMPCharacter(node.Attributes["hero"].Value);
                this.TroopCharacter = MultiplayerClassDivisions.GetMPCharacter(node.Attributes["troop"].Value);
                string stringId = node.Attributes["banner_bearer"]?.Value;

                if (stringId != null)
                {
                    this.BannerBearerCharacter = MultiplayerClassDivisions.GetMPCharacter(stringId);
                }
                this.HeroIdleAnim       = node.Attributes["hero_idle_anim"]?.Value;
                this.HeroMountIdleAnim  = node.Attributes["hero_mount_idle_anim"]?.Value;
                this.TroopIdleAnim      = node.Attributes["troop_idle_anim"]?.Value;
                this.TroopMountIdleAnim = node.Attributes["troop_mount_idle_anim"]?.Value;
                this.Culture            = this.HeroCharacter.Culture;
                this.ClassGroup         = new MultiplayerClassDivisions.MPHeroClassGroup(this.HeroCharacter.DefaultFormationClass.GetName());
                this.TroopMultiplier    = (float)Convert.ToDouble(node.Attributes["multiplier"].Value);
                this.TroopCost          = Convert.ToInt32(node.Attributes["cost"].Value);
                this.ArmorValue         = Convert.ToInt32(node.Attributes["armor"].Value);
                this.Health             = 100;
                this.MeleeAI            = 50;
                this.RangedAI           = 50;
                XmlNode attribute = (XmlNode)node.Attributes["hitpoints"];

                if (attribute != null)
                {
                    this.Health = Convert.ToInt32(attribute.Value);
                }
                this.MovementSpeedMultiplier       = (float)Convert.ToDouble(node.Attributes["movement_speed"].Value);
                this.CombatMovementSpeedMultiplier = (float)Convert.ToDouble(node.Attributes["combat_movement_speed"].Value);
                this.TopSpeedReachDuration         = (float)Convert.ToDouble(node.Attributes["acceleration"].Value);
                this.MeleeAI  = Convert.ToInt32(node.Attributes["melee_ai"].Value);
                this.RangedAI = Convert.ToInt32(node.Attributes["ranged_ai"].Value);
                TargetIconType result;

                if (Enum.TryParse <TargetIconType>(node.Attributes["icon"].Value, true, out result))
                {
                    this.IconType = result;
                }
                foreach (XmlNode childNode1 in node.ChildNodes)
                {
                    if (childNode1.NodeType != XmlNodeType.Comment && childNode1.Name == "Perks")
                    {
                        this._perks = new List <IReadOnlyPerkObject>();
                        foreach (XmlNode childNode2 in childNode1.ChildNodes)
                        {
                            if (childNode2.NodeType != XmlNodeType.Comment)
                            {
                                this._perks.Add(MPPerkObject.Deserialize(childNode2));
                            }
                        }
                    }
                }
            }
        public override void Deserialize(MBObjectManager objectManager, XmlNode node)
        {
            this.Initialize();
            foreach (XmlNode childNode in node.ChildNodes)
            {
                if (childNode.NodeType != XmlNodeType.Comment)
                {
                    XmlAttributeCollection attributes = childNode.Attributes;
                    string      objectName            = attributes["id"].Value;
                    string      str       = attributes["value"].Value;
                    SkillObject attribute = Game.Current.ObjectManager.GetObject <SkillObject>(objectName);
                    if (attribute != null)
                    {
                        int num = str != null?Convert.ToInt32(str) : 1;

                        this.SetPropertyValue(attribute, num);
                    }
                }
            }
            foreach (XmlNode childNode in node.ChildNodes)
            {
                if (childNode.NodeType != XmlNodeType.Comment)
                {
                    string objectName = childNode.Name;
                    int    num        = 1;
                    if (objectName == "skill")
                    {
                        objectName = (string)null;
                        if (childNode.Attributes != null)
                        {
                            XmlAttribute attribute = childNode.Attributes["id"];
                            if (attribute != null)
                            {
                                objectName = attribute.InnerText;
                            }
                        }
                    }
                    if (objectName != null)
                    {
                        SkillObject attribute1 = Game.Current.ObjectManager.GetObject <SkillObject>(objectName);
                        if (attribute1 != null)
                        {
                            XmlAttribute attribute2 = childNode.Attributes["value"];
                            if (attribute2 != null)
                            {
                                string str = attribute2.Value;
                                num = str != null?Convert.ToInt32(str) : 1;
                            }
                            this.SetPropertyValue(attribute1, num);
                        }
                    }
                }
            }
        }
示例#12
0
        public static bool Prefix(ref string __result, ref string baseSkinsXmlPath)
        {
            Debug.Print(DebugString.ToString());

            // Why do I have to clone and modify two separate methods? - Designer225
            List <string> elementNameList             = new List <string>();
            List <Tuple <string, string> > toBeMerged = new List <Tuple <string, string> >();
            List <string> xsltList = new List <string>();

            List <MbObjectXmlInformation> mbprojXmlList = XmlResource.MbprojXmls.Where(x => x.Id == "soln_skins").ToList();

            //mbprojXmlList = mbprojXmlList.Reverse();

            for (int i = 0; i < mbprojXmlList.Count; i++)
            {
                var mbproj = mbprojXmlList[i];

                if (mbproj.ModuleName == "Native")
                {
                    mbprojXmlList.RemoveAt(i);
                    mbprojXmlList.Add(mbproj);
                    break;
                }
            }

            foreach (MbObjectXmlInformation mbprojXml in mbprojXmlList)
            {
                if (File.Exists(ModuleInfo.GetXmlPathForNative(mbprojXml.ModuleName, mbprojXml.Name)))
                {
                    elementNameList.Add(mbprojXml.Name);
                    toBeMerged.Add(Tuple.Create(ModuleInfo.GetXmlPathForNative(mbprojXml.ModuleName, mbprojXml.Name), string.Empty));
                }
                string xsltPathForNative = ModuleInfo.GetXsltPathForNative(mbprojXml.ModuleName, mbprojXml.Name);
                if (File.Exists(xsltPathForNative))
                {
                    xsltList.Add(xsltPathForNative);
                }
                else
                {
                    xsltList.Add("");
                }
            }
            XmlDocument mergedXmlForNative = MBObjectManager.CreateMergedXmlFile(toBeMerged, xsltList, true);

            System.IO.StringWriter stringWriter  = new System.IO.StringWriter();
            XmlTextWriter          xmlTextWriter = new XmlTextWriter(stringWriter);

            mergedXmlForNative.WriteTo(xmlTextWriter);
            baseSkinsXmlPath = elementNameList.First();
            __result         = stringWriter.ToString();

            return(false);
        }
示例#13
0
        public static MissionWeapon ReadMissileWeaponReferenceFromPacket(
            MBObjectManager objectManager,
            ref bool bufferReadValid)
        {
            MBObjectBase mbObjectBase = GameNetworkMessage.ReadObjectReferenceFromPacket(objectManager, CompressionBasic.GUIDCompressionInfo, ref bufferReadValid);
            short        num          = (short)GameNetworkMessage.ReadIntFromPacket(CompressionMission.WeaponUsageIndexCompressionInfo, ref bufferReadValid);

            return(new MissionWeapon(mbObjectBase as ItemObject, (ItemModifier)null, (Banner)null, (short)1)
            {
                CurrentUsageIndex = (int)num
            });
        }
示例#14
0
        public static MBObjectBase ReadObjectReferenceFromPacket(
            MBObjectManager objectManager,
            CompressionInfo.UnsignedInteger compressionInfo,
            ref bool bufferReadValid)
        {
            uint id = GameNetworkMessage.ReadUintFromPacket(compressionInfo, ref bufferReadValid);

            if (!bufferReadValid || id <= 0U)
            {
                return((MBObjectBase)null);
            }
            MBGUID objectId = new MBGUID(id);

            return(objectManager.GetObject(objectId));
        }
示例#15
0
 public override void Deserialize(MBObjectManager objectManager, XmlNode node)
 {
     base.Deserialize(objectManager, node);
     this.Name            = new TextObject(XmlHelper.ReadString(node, "name"));
     this._damage         = XmlHelper.ReadInt(node, "damage");
     this._speed          = XmlHelper.ReadInt(node, "speed");
     this._missileSpeed   = XmlHelper.ReadInt(node, "missile_speed");
     this._armor          = XmlHelper.ReadInt(node, "armor");
     this._mountSpeed     = XmlHelper.ReadFloat(node, "horse_speed");
     this._maneuver       = XmlHelper.ReadFloat(node, "maneuver");
     this._chargeDamage   = XmlHelper.ReadFloat(node, "charge_damage");
     this._mountHitPoints = XmlHelper.ReadFloat(node, "horse_hit_points");
     this._hitPoints      = (short)XmlHelper.ReadInt(node, "hit_points");
     this._stackCount     = (short)XmlHelper.ReadInt(node, "stack_count");
     this.PriceMultiplier = XmlHelper.ReadFloat(node, "price_factor", 1f);
 }
        public static void LoadXML(
            this MBObjectManager objectManager,
            string id,
            Type typeOfGameMenusCallbacks = null,
            bool skipXmlFilterForEditor   = false)
        {
            Game   current       = Game.Current;
            bool   isDevelopment = false;
            string gameType      = "";

            if (current != null)
            {
                isDevelopment = current.GameType.IsDevelopment;
                gameType      = current.GameType.GetType().Name;
            }
            objectManager.LoadXML(id, isDevelopment, gameType, typeOfGameMenusCallbacks, skipXmlFilterForEditor);
        }
示例#17
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();
        }
        public override void Deserialize(MBObjectManager objectManager, XmlNode childNode)
        {
            this.Initialize();
            XmlAttribute attribute1 = childNode.Attributes["stack_amount"];
            XmlAttribute attribute2 = childNode.Attributes["blade_length"];
            XmlAttribute attribute3 = childNode.Attributes["blade_width"];
            XmlAttribute attribute4 = childNode.Attributes["physics_material"];
            XmlAttribute attribute5 = childNode.Attributes["body_name"];
            XmlAttribute attribute6 = childNode.Attributes["holster_mesh"];
            XmlAttribute attribute7 = childNode.Attributes["holster_body_name"];
            XmlAttribute attribute8 = childNode.Attributes["holster_mesh_length"];

            this.StackAmount = attribute1 != null?short.Parse(attribute1.Value) : (short)1;

            this.BladeLength       = attribute2 != null ? 0.01f * float.Parse(attribute2.Value) : this.BladeLength;
            this.BladeWidth        = attribute3 != null ? 0.01f * float.Parse(attribute3.Value) : (float)(0.150000005960464 + (double)this.BladeLength * 0.300000011920929);
            this.PhysicsMaterial   = attribute4?.InnerText;
            this.BodyName          = attribute5?.InnerText;
            this.HolsterMeshName   = attribute6?.InnerText;
            this.HolsterBodyName   = attribute7?.InnerText;
            this.HolsterMeshLength = (float)(0.00999999977648258 * (attribute8 != null ? (double)float.Parse(attribute8.Value) : 0.0));
            foreach (XmlNode childNode1 in childNode.ChildNodes)
            {
                string name = childNode1.Name;
                if (!(name == "Thrust"))
                {
                    if (name == "Swing")
                    {
                        XmlAttribute attribute9  = childNode1.Attributes["damage_type"];
                        XmlAttribute attribute10 = childNode1.Attributes["damage_factor"];
                        this.SwingDamageType   = (DamageTypes)Enum.Parse(typeof(DamageTypes), attribute9.Value, true);
                        this.SwingDamageFactor = float.Parse(attribute10.Value);
                    }
                }
                else
                {
                    XmlAttribute attribute9  = childNode1.Attributes["damage_type"];
                    XmlAttribute attribute10 = childNode1.Attributes["damage_factor"];
                    this.ThrustDamageType   = (DamageTypes)Enum.Parse(typeof(DamageTypes), attribute9.Value, true);
                    this.ThrustDamageFactor = float.Parse(attribute10.Value);
                }
            }
        }
 public override void Deserialize(MBObjectManager objectManager, XmlNode node)
 {
     base.Deserialize(objectManager, node);
     this.Name   = new TextObject(node.Attributes["name"].Value);
     this.Color  = node.Attributes["color"] == null ? uint.MaxValue : Convert.ToUInt32(node.Attributes["color"].Value, 16);
     this.Color2 = node.Attributes["color2"] == null ? uint.MaxValue : Convert.ToUInt32(node.Attributes["color2"].Value, 16);
     this.ClothAlternativeColor   = node.Attributes["cloth_alternative_color1"] == null ? uint.MaxValue : Convert.ToUInt32(node.Attributes["cloth_alternative_color1"].Value, 16);
     this.ClothAlternativeColor2  = node.Attributes["cloth_alternative_color2"] == null ? uint.MaxValue : Convert.ToUInt32(node.Attributes["cloth_alternative_color2"].Value, 16);
     this.BackgroundColor1        = node.Attributes["banner_background_color1"] == null ? uint.MaxValue : Convert.ToUInt32(node.Attributes["banner_background_color1"].Value, 16);
     this.ForegroundColor1        = node.Attributes["banner_foreground_color1"] == null ? uint.MaxValue : Convert.ToUInt32(node.Attributes["banner_foreground_color1"].Value, 16);
     this.BackgroundColor2        = node.Attributes["banner_background_color2"] == null ? uint.MaxValue : Convert.ToUInt32(node.Attributes["banner_background_color2"].Value, 16);
     this.ForegroundColor2        = node.Attributes["banner_foreground_color2"] == null ? uint.MaxValue : Convert.ToUInt32(node.Attributes["banner_foreground_color2"].Value, 16);
     this.IsMainCulture           = node.Attributes["is_main_culture"] != null && Convert.ToBoolean(node.Attributes["is_main_culture"].Value);
     this.EncounterBackgroundMesh = node.Attributes["encounter_background_mesh"] == null ? (string)null : node.Attributes["encounter_background_mesh"].Value;
     this.BannerKey         = node.Attributes["faction_banner_key"] == null ? (string)null : node.Attributes["faction_banner_key"].Value;
     this.IsBandit          = false;
     this.IsBandit          = node.Attributes["is_bandit"] != null && Convert.ToBoolean(node.Attributes["is_bandit"].Value);
     this.CanHaveSettlement = false;
     this.CanHaveSettlement = node.Attributes["can_have_settlement"] != null && Convert.ToBoolean(node.Attributes["can_have_settlement"].Value);
 }
示例#20
0
        public static MissionWeapon ReadWeaponReferenceFromPacket(
            MBObjectManager objectManager,
            ref bool bufferReadValid)
        {
            if (GameNetworkMessage.ReadBoolFromPacket(ref bufferReadValid))
            {
                return(MissionWeapon.Invalid);
            }
            MBObjectBase mbObjectBase1 = GameNetworkMessage.ReadObjectReferenceFromPacket(objectManager, CompressionBasic.GUIDCompressionInfo, ref bufferReadValid);
            int          num1          = GameNetworkMessage.ReadIntFromPacket(CompressionGeneric.ItemDataValueCompressionInfo, ref bufferReadValid);
            int          num2          = GameNetworkMessage.ReadIntFromPacket(CompressionMission.WeaponReloadPhaseCompressionInfo, ref bufferReadValid);
            short        num3          = (short)GameNetworkMessage.ReadIntFromPacket(CompressionMission.WeaponUsageIndexCompressionInfo, ref bufferReadValid);
            int          num4          = GameNetworkMessage.ReadBoolFromPacket(ref bufferReadValid) ? 1 : 0;
            Banner       banner        = (Banner)null;

            if (num4 != 0)
            {
                string bannerKey = GameNetworkMessage.ReadStringFromPacket(ref bufferReadValid);
                if (bufferReadValid)
                {
                    banner = new Banner(bannerKey);
                }
            }
            ItemObject    primaryItem1 = mbObjectBase1 as ItemObject;
            bool          flag         = GameNetworkMessage.ReadBoolFromPacket(ref bufferReadValid);
            MissionWeapon missionWeapon;

            if (bufferReadValid & flag)
            {
                MBObjectBase mbObjectBase2 = GameNetworkMessage.ReadObjectReferenceFromPacket(objectManager, CompressionBasic.GUIDCompressionInfo, ref bufferReadValid);
                int          num5          = GameNetworkMessage.ReadIntFromPacket(CompressionGeneric.ItemDataValueCompressionInfo, ref bufferReadValid);
                ItemObject   primaryItem2  = mbObjectBase2 as ItemObject;
                missionWeapon = new MissionWeapon(primaryItem1, (ItemModifier)null, banner, (short)num1, (short)num2, new MissionWeapon?(new MissionWeapon(primaryItem2, (ItemModifier)null, banner, (short)num5)));
            }
            else
            {
                missionWeapon = new MissionWeapon(primaryItem1, (ItemModifier)null, banner, (short)num1, (short)num2, new MissionWeapon?());
            }
            missionWeapon.CurrentUsageIndex = (int)num3;
            return(missionWeapon);
        }
示例#21
0
        public override void Deserialize(MBObjectManager objectManager, XmlNode node)
        {
            base.Deserialize(objectManager, node);
            this.Name        = new TextObject(node.Attributes["name"].InnerText);
            this.Description = new TextObject(node.Attributes["description"].InnerText);
            XmlAttribute attribute = node.Attributes["max_hit_points"];

            this.BaseHitPoints          = attribute == null ? 1 : Convert.ToInt32(attribute.Value);
            this.Difficulty             = Convert.ToInt32(node.Attributes["difficulty"]?.Value);
            this.ToolCost               = Convert.ToInt32(node.Attributes["tool_cost"].Value);
            this.HitChance              = (float)Convert.ToDouble(node.Attributes["hit_chance"].Value);
            this.IsAntiPersonnel        = Convert.ToBoolean(node.Attributes["is_anti_personnel"].Value);
            this.AntiPersonnelHitChance = this.IsAntiPersonnel ? (float)Convert.ToDouble(node.Attributes["anti_personnel_hit_chance"].Value) : 0.0f;
            this.IsConstructible        = Convert.ToBoolean(node.Attributes["is_constructible"].Value);
            this.IsRanged               = Convert.ToBoolean(node.Attributes["is_ranged"].Value);
            this.Damage     = Convert.ToInt32(node.Attributes["damage"].Value);
            this.ManDayCost = Convert.ToInt32(node.Attributes["man_day_cost"].Value);
            this.CampaignRateOfFirePerDay = (float)Convert.ToDouble(node.Attributes["campaign_rate_of_fire_per_day"].Value);
            this.MovementSpeed            = (float)Convert.ToDouble(node.Attributes["movement_speed"].Value);
            this.ProjectileSpeed          = (float)Convert.ToDouble(node.Attributes["projectile_speed"].Value);
        }
示例#22
0
        protected override void OnInitialize()
        {
            base.OnInitialize();
            Game currentGame = this.CurrentGame;

            currentGame.FirstInitialize();
            IGameStarter gameStarter = (IGameStarter) new BasicGameStarter();

            this.InitializeGameModels(gameStarter);
            this.GameManager.OnGameStart(this.CurrentGame, gameStarter);
            MBObjectManager objectManager = currentGame.ObjectManager;

            currentGame.SecondInitialize(gameStarter.Models);
            currentGame.CreateGameManager();
            this.GameManager.BeginGameStart(this.CurrentGame);
            this.CurrentGame.RegisterBasicTypes();
            this.CurrentGame.ThirdInitialize();
            currentGame.CreateObjects();
            currentGame.InitializeDefaultGameObjects();
            currentGame.LoadBasicFiles(false);
            this.ObjectManager.LoadXML("Items", (Type)null);
            this.ObjectManager.LoadXML("MPCharacters", (Type)null);
            this.ObjectManager.LoadXML("BasicCultures", (Type)null);
            this.ObjectManager.LoadXML("MPClassDivisions", (Type)null);
            objectManager.ClearEmptyObjects();
            currentGame.SetDefaultEquipments((IReadOnlyDictionary <string, Equipment>) new Dictionary <string, Equipment>());
            ModuleLogger.Writer.WriteLine(currentGame.BasicModels);
            ModuleLogger.Writer.Flush();
            if (currentGame.BasicModels.SkillList == null)
            {
                throw new Exception("haha");
            }
            currentGame.CreateLists();
            objectManager.ClearEmptyObjects();
            this.AddGameTexts();
            this.GameManager.OnCampaignStart(this.CurrentGame, (object)null);
            this.GameManager.OnAfterCampaignStart(this.CurrentGame);
            this.GameManager.OnGameInitializationFinished(this.CurrentGame);
        }
        private static TownPatrolData SpawnTownPatrol(string name, string size, PatrolData dat, bool isPlayerSpawn, Settlement spawnSettlement = null)
        {
            MBObjectManager objManager = Game.Current.ObjectManager;
            TextObject      pName      = new TextObject(name);

            PartyTemplateObject templateObject = (PartyTemplateObject)objManager.GetObject <PartyTemplateObject>(dat.templateName + "_" + size);

            spawnSettlement = isPlayerSpawn ? Settlement.CurrentSettlement : spawnSettlement;

            MobileParty patrol = objManager.CreateObject <MobileParty>(dat.templateName + "_" + size + "_" + 1);

            patrol.InitializeMobileParty(MenuUtils.ConstructTroopRoster(templateObject, patrol.Party), new TroopRoster(patrol.Party), isPlayerSpawn ? Settlement.CurrentSettlement.GatePosition : spawnSettlement.GatePosition, 0);

            patrol.SetCustomName(pName);
            patrol.Party.Owner = spawnSettlement.MapFaction.Leader == null?spawnSettlement.OwnerClan.Heroes.ToList().First() : spawnSettlement.OwnerClan.Leader;

            patrol.Party.Visuals.SetMapIconAsDirty();
            patrol.ActualClan     = spawnSettlement.OwnerClan;
            patrol.HomeSettlement = spawnSettlement;
            MenuUtils.CreatePartyTrade(patrol);

            foreach (ItemObject obj in ItemObject.All)
            {
                if (obj.IsFood)
                {
                    int num = MBRandom.RandomInt(patrol.MemberRoster.TotalManCount / 3, patrol.MemberRoster.TotalManCount);
                    if (num > 0)
                    {
                        patrol.ItemRoster.AddToCounts(obj, num);
                    }
                }
            }

            patrol.SetMovePatrolAroundSettlement(spawnSettlement);

            return(new TownPatrolData(pName.ToString(), size, patrol));
        }
 public override void Deserialize(MBObjectManager objectManager, XmlNode node)
 {
     base.Deserialize(objectManager, node);
     foreach (XmlNode childNode in node.ChildNodes)
     {
         if (childNode.Name == "BodyPropertiesMin")
         {
             BodyProperties.FromXmlNode(childNode, out this._bodyPropertyMin);
         }
         else if (childNode.Name == "BodyPropertiesMax")
         {
             BodyProperties.FromXmlNode(childNode, out this._bodyPropertyMax);
         }
     }
     if ((double)this._bodyPropertyMax.Age <= 0.0)
     {
         this._bodyPropertyMax = this._bodyPropertyMin;
     }
     if ((double)this._bodyPropertyMin.Age > 0.0)
     {
         return;
     }
     this._bodyPropertyMin = this._bodyPropertyMax;
 }
示例#25
0
 public static EquipmentElement ReadItemReferenceFromPacket(
     MBObjectManager objectManager,
     ref bool bufferReadValid)
 {
     return(new EquipmentElement(GameNetworkMessage.ReadObjectReferenceFromPacket(objectManager, CompressionBasic.GUIDCompressionInfo, ref bufferReadValid) as ItemObject));
 }
示例#26
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();
        }
 public MultiplayerStarter(MBObjectManager objectManager) => this._objectManager = objectManager;
示例#28
0
        public override void Deserialize(MBObjectManager objectManager, XmlNode node)
        {
            base.Deserialize(objectManager, node);
            XmlAttribute attribute1 = node.Attributes["action_set"];

            if (attribute1 != null && !string.IsNullOrEmpty(attribute1.Value))
            {
                this.ActionSetCode = attribute1.Value;
            }
            XmlAttribute attribute2 = node.Attributes["monster_usage"];

            this.MonsterUsage = attribute2 == null || string.IsNullOrEmpty(attribute2.Value) ? "" : attribute2.Value;
            this.Weight       = 1;
            XmlAttribute attribute3 = node.Attributes["weight"];
            int          result1;

            if (attribute3 != null && !string.IsNullOrEmpty(attribute3.Value) && int.TryParse(attribute3.Value, out result1))
            {
                this.Weight = result1;
            }
            this.HitPoints = 1;
            XmlAttribute attribute4 = node.Attributes["hit_points"];
            int          result2;

            if (attribute4 != null && !string.IsNullOrEmpty(attribute4.Value) && int.TryParse(attribute4.Value, out result2))
            {
                this.HitPoints = result2;
            }
            this.NumPaces = 0;
            XmlAttribute attribute5 = node.Attributes["num_paces"];
            int          result3;

            if (attribute5 != null && !string.IsNullOrEmpty(attribute5.Value) && int.TryParse(attribute5.Value, out result3))
            {
                this.NumPaces = result3;
            }
            XmlAttribute attribute6 = node.Attributes["walking_speed_limit"];
            float        result4;

            if (attribute6 != null && !string.IsNullOrEmpty(attribute6.Value) && float.TryParse(attribute6.Value, out result4))
            {
                this.WalkingSpeedLimit = result4;
            }
            XmlAttribute attribute7 = node.Attributes["crouch_walking_speed_limit"];

            if (attribute7 != null && !string.IsNullOrEmpty(attribute7.Value))
            {
                float result5;
                if (float.TryParse(attribute7.Value, out result5))
                {
                    this.CrouchWalkingSpeedLimit = result5;
                }
            }
            else
            {
                this.CrouchWalkingSpeedLimit = this.WalkingSpeedLimit;
            }
            XmlAttribute attribute8 = node.Attributes["jump_acceleration"];
            float        result6;

            if (attribute8 != null && !string.IsNullOrEmpty(attribute8.Value) && float.TryParse(attribute8.Value, out result6))
            {
                this.JumpAcceleration = result6;
            }
            XmlAttribute attribute9 = node.Attributes["absorbed_damage_ratio"];

            if (attribute9 != null && !string.IsNullOrEmpty(attribute9.Value))
            {
                float result5;
                if (float.TryParse(attribute9.Value, out result5))
                {
                    if ((double)result5 < 0.0)
                    {
                        result5 = 0.0f;
                    }
                    this.AbsorbedDamageRatio = result5;
                }
            }
            else
            {
                this.AbsorbedDamageRatio = 1f;
            }
            XmlAttribute attribute10 = node.Attributes["sound_and_collision_info_class"];

            if (attribute10 != null && !string.IsNullOrEmpty(attribute10.Value))
            {
                this.SoundAndCollisionInfoClassName = attribute10.Value;
            }
            this.RiderCameraHeightAdder = 0.0f;
            XmlAttribute attribute11 = node.Attributes["rider_camera_height_adder"];
            float        result7;

            if (attribute11 != null && !string.IsNullOrEmpty(attribute11.Value) && float.TryParse(attribute11.Value, out result7))
            {
                this.RiderCameraHeightAdder = result7;
            }
            this.RiderBodyCapsuleHeightAdder = 0.0f;
            XmlAttribute attribute12 = node.Attributes["rider_body_capsule_height_adder"];
            float        result8;

            if (attribute12 != null && !string.IsNullOrEmpty(attribute12.Value) && float.TryParse(attribute12.Value, out result8))
            {
                this.RiderBodyCapsuleHeightAdder = result8;
            }
            this.RiderBodyCapsuleForwardAdder = 0.0f;
            XmlAttribute attribute13 = node.Attributes["rider_body_capsule_forward_adder"];
            float        result9;

            if (attribute13 != null && !string.IsNullOrEmpty(attribute13.Value) && float.TryParse(attribute13.Value, out result9))
            {
                this.RiderBodyCapsuleForwardAdder = result9;
            }
            XmlAttribute attribute14 = node.Attributes["preliminary_collision_capsule_radius_multiplier"];

            if (attribute14 != null)
            {
                string.IsNullOrEmpty(attribute14.Value);
            }
            XmlAttribute attribute15 = node.Attributes["rider_preliminary_collision_capsule_height_multiplier"];

            if (attribute15 != null)
            {
                string.IsNullOrEmpty(attribute15.Value);
            }
            XmlAttribute attribute16 = node.Attributes["rider_preliminary_collision_capsule_height_adder"];

            if (attribute16 != null)
            {
                string.IsNullOrEmpty(attribute16.Value);
            }
            this.StandingEyeHeight = 0.0f;
            XmlAttribute attribute17 = node.Attributes["standing_eye_height"];
            float        result10;

            if (attribute17 != null && !string.IsNullOrEmpty(attribute17.Value) && float.TryParse(attribute17.Value, out result10))
            {
                this.StandingEyeHeight = result10;
            }
            this.CrouchEyeHeight = 0.0f;
            XmlAttribute attribute18 = node.Attributes["crouch_eye_height"];
            float        result11;

            if (attribute18 != null && !string.IsNullOrEmpty(attribute18.Value) && float.TryParse(attribute18.Value, out result11))
            {
                this.CrouchEyeHeight = result11;
            }
            this.MountedEyeHeight = 0.0f;
            XmlAttribute attribute19 = node.Attributes["mounted_eye_height"];
            float        result12;

            if (attribute19 != null && !string.IsNullOrEmpty(attribute19.Value) && float.TryParse(attribute19.Value, out result12))
            {
                this.MountedEyeHeight = result12;
            }
            this.RiderEyeHeightAdder = 0.0f;
            XmlAttribute attribute20 = node.Attributes["rider_eye_height_adder"];
            float        result13;

            if (attribute20 != null && !string.IsNullOrEmpty(attribute20.Value) && float.TryParse(attribute20.Value, out result13))
            {
                this.RiderEyeHeightAdder = result13;
            }
            this.EyeOffsetWrtHead = new Vec3(0.01f, 0.01f, 0.01f);
            XmlAttribute attribute21 = node.Attributes["eye_offset_wrt_head"];
            Vec3         v1;

            if (attribute21 != null && !string.IsNullOrEmpty(attribute21.Value) && Monster.ReadVec3(attribute21.Value, out v1))
            {
                this.EyeOffsetWrtHead = v1;
            }
            this.FirstPersonCameraOffsetWrtHead = new Vec3(0.01f, 0.01f, 0.01f);
            XmlAttribute attribute22 = node.Attributes["first_person_camera_offset_wrt_head"];
            Vec3         v2;

            if (attribute22 != null && !string.IsNullOrEmpty(attribute22.Value) && Monster.ReadVec3(attribute22.Value, out v2))
            {
                this.FirstPersonCameraOffsetWrtHead = v2;
            }
            this.ArmLength = 0.0f;
            XmlAttribute attribute23 = node.Attributes["arm_length"];
            float        result14;

            if (attribute23 != null && !string.IsNullOrEmpty(attribute23.Value) && float.TryParse(attribute23.Value, out result14))
            {
                this.ArmLength = result14;
            }
            this.ArmWeight = 0.0f;
            XmlAttribute attribute24 = node.Attributes["arm_weight"];
            float        result15;

            if (attribute24 != null && !string.IsNullOrEmpty(attribute24.Value) && float.TryParse(attribute24.Value, out result15))
            {
                this.ArmWeight = result15;
            }
            this.JumpSpeedLimit = 0.0f;
            XmlAttribute attribute25 = node.Attributes["jump_speed_limit"];
            float        result16;

            if (attribute25 != null && !string.IsNullOrEmpty(attribute25.Value) && float.TryParse(attribute25.Value, out result16))
            {
                this.JumpSpeedLimit = result16;
            }
            this.RelativeSpeedLimitForCharge = float.MaxValue;
            XmlAttribute attribute26 = node.Attributes["relative_speed_limit_for_charge"];
            float        result17;

            if (attribute26 != null && !string.IsNullOrEmpty(attribute26.Value) && float.TryParse(attribute26.Value, out result17))
            {
                this.RelativeSpeedLimitForCharge = result17;
            }
            this.FamilyType = 0;
            XmlAttribute attribute27 = node.Attributes["family_type"];
            int          result18;

            if (attribute27 != null && !string.IsNullOrEmpty(attribute27.Value) && int.TryParse(attribute27.Value, out result18))
            {
                this.FamilyType = result18;
            }
            XmlAttribute attribute28 = node.Attributes["main_hand_item_bone"];

            this.MainHandItemBoneIndex = Monster.GetBoneIndexWithId == null || attribute28 == null ? (sbyte)-1 : Monster.GetBoneIndexWithId(this.ActionSetCode, attribute28.Value);
            XmlAttribute attribute29 = node.Attributes["off_hand_item_bone"];

            this.OffHandItemBoneIndex = Monster.GetBoneIndexWithId == null || attribute29 == null ? (sbyte)-1 : Monster.GetBoneIndexWithId(this.ActionSetCode, attribute29.Value);
            XmlAttribute attribute30 = node.Attributes["main_hand_item_secondary_bone"];

            this.MainHandItemSecondaryBoneIndex = Monster.GetBoneIndexWithId == null || attribute30 == null ? (sbyte)-1 : Monster.GetBoneIndexWithId(this.ActionSetCode, attribute30.Value);
            XmlAttribute attribute31 = node.Attributes["off_hand_item_secondary_bone"];

            this.OffHandItemSecondaryBoneIndex = Monster.GetBoneIndexWithId == null || attribute31 == null ? (sbyte)-1 : Monster.GetBoneIndexWithId(this.ActionSetCode, attribute31.Value);
            XmlAttribute attribute32 = node.Attributes["rider_sit_bone"];

            this.RiderSitBoneIndex = Monster.GetBoneIndexWithId == null || attribute32 == null ? (sbyte)-1 : Monster.GetBoneIndexWithId(this.ActionSetCode, attribute32.Value);
            XmlAttribute attribute33 = node.Attributes["rein_handle_bone"];

            this.ReinHandleBoneIndex = Monster.GetBoneIndexWithId == null || attribute33 == null ? (sbyte)-1 : Monster.GetBoneIndexWithId(this.ActionSetCode, attribute33.Value);
            XmlAttribute attribute34 = node.Attributes["rein_collision_1_bone"];

            this.ReinCollision1BoneIndex = Monster.GetBoneIndexWithId == null || attribute34 == null ? (sbyte)-1 : Monster.GetBoneIndexWithId(this.ActionSetCode, attribute34.Value);
            XmlAttribute attribute35 = node.Attributes["rein_collision_2_bone"];

            this.ReinCollision2BoneIndex = Monster.GetBoneIndexWithId == null || attribute35 == null ? (sbyte)-1 : Monster.GetBoneIndexWithId(this.ActionSetCode, attribute35.Value);
            XmlAttribute attribute36 = node.Attributes["head_look_direction_bone"];

            this.HeadLookDirectionBoneIndex = Monster.GetBoneIndexWithId == null || attribute36 == null ? (sbyte)-1 : Monster.GetBoneIndexWithId(this.ActionSetCode, attribute36.Value);
            XmlAttribute attribute37 = node.Attributes["thorax_look_direction_bone"];

            this.ThoraxLookDirectionBoneIndex = Monster.GetBoneIndexWithId == null || attribute37 == null ? (sbyte)-1 : Monster.GetBoneIndexWithId(this.ActionSetCode, attribute37.Value);
            XmlNode attribute38 = (XmlNode)node.Attributes["rein_handle_left_local_pos"];

            if (attribute38 != null)
            {
                string[] strArray = attribute38.Value.Split(',');
                if (strArray.Length == 3)
                {
                    Vec3 zero = Vec3.Zero;
                    float.TryParse(strArray[0], out zero.x);
                    float.TryParse(strArray[1], out zero.y);
                    float.TryParse(strArray[2], out zero.z);
                    this.ReinHandleLeftLocalPosition = zero;
                }
            }
            XmlNode attribute39 = (XmlNode)node.Attributes["rein_handle_right_local_pos"];

            if (attribute39 != null)
            {
                string[] strArray = attribute39.Value.Split(',');
                if (strArray.Length == 3)
                {
                    Vec3 zero = Vec3.Zero;
                    float.TryParse(strArray[0], out zero.x);
                    float.TryParse(strArray[1], out zero.y);
                    float.TryParse(strArray[2], out zero.z);
                    this.ReinHandleRightLocalPosition = zero;
                }
            }
            XmlAttribute attribute40 = node.Attributes["main_hand_num_bones_for_ik"];

            this.MainHandNumBonesForIk = attribute40 != null?sbyte.Parse(attribute40.Value) : (sbyte)0;

            XmlAttribute attribute41 = node.Attributes["off_hand_num_bones_for_ik"];

            this.OffHandNumBonesForIk = attribute41 != null?sbyte.Parse(attribute41.Value) : (sbyte)0;

            this.Flags = AgentFlag.None;
            foreach (XmlNode childNode1 in node.ChildNodes)
            {
                if (childNode1.Name == "Flags")
                {
                    foreach (AgentFlag agentFlag in Enum.GetValues(typeof(AgentFlag)))
                    {
                        XmlAttribute attribute42 = childNode1.Attributes[agentFlag.ToString()];
                        if (attribute42 != null && !attribute42.Value.Equals("false", StringComparison.InvariantCultureIgnoreCase))
                        {
                            this.Flags |= agentFlag;
                        }
                    }
                }
                else if (childNode1.Name == "Capsules")
                {
                    foreach (XmlNode childNode2 in childNode1.ChildNodes)
                    {
                        if (childNode2.Attributes != null && (childNode2.Name == "preliminary_collision_capsule" || childNode2.Name == "body_capsule" || childNode2.Name == "crouched_body_capsule"))
                        {
                            bool  flag    = true;
                            Vec3  vec3_1  = new Vec3(z: 0.01f);
                            Vec3  vec3_2  = Vec3.Zero;
                            float result5 = 0.01f;
                            if (childNode2.Attributes["pos1"] != null)
                            {
                                Vec3 v3;
                                flag = Monster.ReadVec3(childNode2.Attributes["pos1"].Value, out v3) & flag;
                                if (flag)
                                {
                                    vec3_1 = v3;
                                }
                            }
                            if (childNode2.Attributes["pos2"] != null)
                            {
                                Vec3 v3;
                                flag = Monster.ReadVec3(childNode2.Attributes["pos2"].Value, out v3) & flag;
                                if (flag)
                                {
                                    vec3_2 = v3;
                                }
                            }
                            if (childNode2.Attributes["radius"] != null)
                            {
                                string s = childNode2.Attributes["radius"].Value.Trim();
                                flag = flag && float.TryParse(s, out result5);
                            }
                            if (flag && !childNode2.Name.StartsWith("p"))
                            {
                                if (childNode2.Name.StartsWith("c"))
                                {
                                    this.CrouchedBodyCapsuleRadius = result5;
                                    this.CrouchedBodyCapsulePoint1 = vec3_1;
                                    this.CrouchedBodyCapsulePoint2 = vec3_2;
                                }
                                else
                                {
                                    this.BodyCapsuleRadius = result5;
                                    this.BodyCapsulePoint1 = vec3_1;
                                    this.BodyCapsulePoint2 = vec3_2;
                                }
                            }
                        }
                    }
                }
            }
        }
 protected override void BeforeRegisterTypes(MBObjectManager objectManager)
 {
 }
 protected override void OnRegisterTypes(MBObjectManager objectManager)
 {
     objectManager.RegisterType <BasicCharacterObject>("NPCCharacter", "NPCCharacters", 43U);
     objectManager.RegisterType <BasicCultureObject>("Culture", "SPCultures", 17U);
 }