Exemplo n.º 1
0
        protected override void OnSubModuleLoad()
        {
            base.OnSubModuleLoad();
            _instance = this;

            try
            {
                new Harmony("org.aragas.bannerlord.mercenarycontract").PatchAll(typeof(MercenaryContractSubModule).Assembly);
            }
            catch (Exception ex)
            {
                CommunityPatchSubModule.Error(ex, "[Aragas.MercenaryContract]: Error while trying to initialize Harmony!");
            }

            var mercenarycontractSpriteData = SpriteDataFactory.CreateNewFromModule(
                "mercenarycontractSpriteData",
                UIResourceManager.UIResourceDepot);

            UIResourceManager.SpriteData.AppendFrom(mercenarycontractSpriteData);

            UIResourceManager.BrushFactory.ImportAndAppend(
                "Map.Notification.Type.Circle.Image",
                "MercenaryContractMapNotification",
                "Aragas.MercenaryContract.Map.Notification.Type.Circle.Image");
        }
 private static int ExtractFirstPhaseTimeLimitInYears()
 {
     try {
         FieldInfo field = typeof(FirstPhaseCampaignBehavior).GetField("FirstPhaseTimeLimitInYears", BindingFlags.NonPublic | BindingFlags.Static);
         return((int)field.GetRawConstantValue());
     }
     catch (NullReferenceException ex) {
         // couldn't locate the field in vanilla. Maybe the name has changed, or it's access modifiers.
         CommunityPatchSubModule.Error(ex, $"{typeof(EarlyStoryVisibleTimeoutPatch).Name}: Couldn't locate vanilla's timeout value." + Environment.NewLine);
     }
     return(DefaultFirstPhaseTimeLimitInYears);
 }
Exemplo n.º 3
0
        public static SpriteData CreateNewFromModule(string name, ResourceDepot resourceDepot)
        {
            var spriteData = new SpriteData(name);

            try
            {
                spriteData.Load(resourceDepot);
                foreach (var spriteCategory in spriteData.SpriteCategories)
                {
                    spriteCategory.Value.LoadFromModules(resourceDepot);
                }
            }
            catch (Exception ex)
            {
                CommunityPatchSubModule.Error(ex, "[Aragas.MercenaryContract]: Error while trying to initialize custom textures!");
            }

            return(spriteData);
        }
Exemplo n.º 4
0
        public static void LoadFromModules(this SpriteCategory spriteCategory, ResourceDepot resourceDepot)
        {
            if (!spriteCategory.IsLoaded)
            {
                IsLoadedProperty.SetValue(spriteCategory, true);

                for (var i = 1; i <= spriteCategory.SpriteSheetCount; i++)
                {
                    try
                    {
                        var filePath = resourceDepot.GetFilePath($"SpriteSheets\\{spriteCategory.Name}\\{spriteCategory.Name}_{i}.png");
                        var fileInfo = new FileInfo(filePath);
                        spriteCategory.SpriteSheets.Add(
                            new Texture(
                                new EngineTexture(
                                    TaleWorlds.Engine.Texture.CreateTextureFromPath(fileInfo.Directory.FullName, fileInfo.Name))));
                    }
                    catch (Exception ex)
                    {
                        CommunityPatchSubModule.Error(ex, "[Aragas.MercenaryContract]: Error while trying to load custom textures!");
                    }
                }
            }
        }