public override void Entry(IModHelper helper)
        {
            Logger.Init(this.Monitor);
            EffectHelper.Init(helper, helper.ReadConfig <SkillfulClothesConfig>());

            if (EffectHelper.Config.LoadCustomEffectDefinitions)
            {
                CustomEffectDefinitions.LoadCustomEffectDefinitions();
            }

            HarmonyPatches.Apply(this.ModManifest.UniqueID);
            ShopPatches.Apply(helper);
            TailoringPatches.Apply(helper);

            clothingObserver = EffectHelper.ClothingObserver;

            helper.Events.GameLoop.GameLaunched += GameLoop_GameLaunched;

            helper.Events.GameLoop.UpdateTicked += GameLoop_UpdateTicked;

            helper.Events.GameLoop.DayStarted += GameLoop_DayStarted;
            helper.Events.GameLoop.DayEnding  += GameLoop_DayEnding;

            helper.Events.GameLoop.ReturnedToTitle += GameLoop_ReturnedToTitle;
        }
Пример #2
0
 public override void Entry(IModHelper helper)
 {
     helper.Events.GameLoop.DayStarted   += this.OnDayStarted;
     helper.Events.Display.MenuChanged   += this.OnMenuChanged;
     helper.Events.GameLoop.GameLaunched += this.OnGameLaunched;
     harmony = new Harmony(this.ModManifest.UniqueID);
     HarmonyPatches.ApplyPatches(harmony);
 }
Пример #3
0
        public override void BaseHeadOffsetAt(ref Vector3 offset, bool portrait, Pawn pawn)
        {
            base.BaseHeadOffsetAt(ref offset, portrait, pawn);
            Vector2 newOffset = HarmonyPatches.BaseHeadOffsetAtHelper(new Vector2(offset.x, offset.z), pawn);

            offset.x += newOffset.x;
            offset.z += newOffset.y;

            // HarmonyPatches.BaseHeadOffsetAtPostfix(this.Pawn.Drawer.renderer, ref offset );
        }
        public static Task <ILanguageServer> From(Action <LanguageServerOptions, PapyrusLanguageServerOptions> optionsAction)
        {
            var papyrusOptions = new PapyrusLanguageServerOptions();

            return(LanguageServer.From((options) =>
            {
                optionsAction(options, papyrusOptions);

                options.WithServices((collection) => collection
                                     .AddSingleton <IFileSystem, LocalFileSystem>()
                                     .AddSingleton <IXmlProjectLocator, FileSystemXmlProjectLocator>()
                                     .AddSingleton <IXmlProjectDeserializer, XmlProjectDeserializer>()
                                     .AddSingleton <IXmlProjectLoader, FileSystemXmlProjectLoader>()
                                     .AddSingleton <IScriptTextProvider, TextDocumentScriptTextProvider>((provider) =>
                {
                    var textProvider = provider.CreateInstance <TextDocumentScriptTextProvider>(
                        provider.CreateInstance <FileSystemScriptTextProvider>());

                    AntlrPatch.SetTextProvider(textProvider);

                    return textProvider;
                })
                                     .AddSingleton <ICreationKitInisLocator>(new CreationKitInisLocator(papyrusOptions.IniLocations))
                                     .AddSingleton <ICreationKitConfigLoader, CreationKitInisConfigLoader>()
                                     .AddSingleton((provider) =>
                                                   provider.CreateInstance <CreationKitProgramOptionsProvider>(
                                                       papyrusOptions.AmbientProjectName,
                                                       papyrusOptions.FlagsFileName,
                                                       papyrusOptions.DefaultCreationKitConfig))
                                     .AddSingleton <IProgramOptionsProvider>((provider) =>
                                                                             provider.CreateInstance <ProjectProgramOptionsProvider>(papyrusOptions.FlagsFileName))
                                     .AddSingleton <ProjectManager>())
                .WithHandler <WorkspaceManager>()
                .WithHandler <DefinitionHandler>()
                .WithHandler <DocumentSymbolHandler>()
                .WithHandler <DocumentSyntaxTreeHandler>()
                .WithHandler <HoverHandler>()
                .WithHandler <CompletionHandler>()
                .WithHandler <SignatureHelpHandler>()
                .WithHandler <ReferencesHandler>()
                .WithHandler <RenameHandler>()
                .WithHandler <DocumentScriptInfoHandler>()
                .WithHandler <DocumentAssemblyHandler>()
                .WithHandler <ProjectInfosHandler>();

                HarmonyPatches.Apply();
            }));
        }
Пример #5
0
        public static void Reinit(bool reloadSettings = true, bool reloadIconSet = true, bool recalcIconPos = true)
        {
            PawnCapacities = new[]
            {
                PawnCapacityDefOf.BloodFiltration, PawnCapacityDefOf.BloodPumping,
                PawnCapacityDefOf.Breathing, PawnCapacityDefOf.Consciousness,
                PawnCapacityDefOf.Eating, PawnCapacityDefOf.Hearing,
                PawnCapacityDefOf.Manipulation, PawnCapacityDefOf.Metabolism,
                PawnCapacityDefOf.Moving, PawnCapacityDefOf.Sight, PawnCapacityDefOf.Talking
            };

            if (reloadSettings)
            {
                Settings.BarSettings = Settings.LoadBarSettings();
                Settings.PSISettings = Settings.LoadPSISettings();
                HarmonyPatches.MarkColonistsDirty_Postfix();
            }

            if (recalcIconPos)
            {
                BarIconDrawer.RecalcBarPositionAndSize();
                PSIDrawer.RecalcIconPositionsPSI();
            }

            if (reloadIconSet)
            {
                LongEventHandler.ExecuteWhenFinished(
                    () =>
                {
                    PSIMaterials = new Materials(Settings.PSISettings.IconSet);

                    // PSISettings SettingsPSI =
                    // XmlLoader.ItemFromXmlFile<PSISettings>(GenFilePaths.CoreModsFolderPath + "/RW_PawnStateIcons/Textures/UI/Overlays/PawnStateIcons/" + PSI.SettingsPSI.IconSet + "/iconset.cfg");
                    // PSI.PSISettings.IconSizeMult = SettingsPSI.IconSizeMult;
                    PSIMaterials.ReloadTextures(true);

                    SkinMat   = PSIMaterials[Icon.TargetSkin];
                    HairMat   = PSIMaterials[Icon.TargetHair];
                    TargetMat = PSIMaterials[Icon.Target];

                    // Log.Message(GenFilePaths.CoreModsFolderPath + "/RW_PawnStateIcons/Textures/UI/Overlays/PawnStateIcons/" + ColBarSettings.IconSet + "/iconset.cfg");
                });
            }
        }
Пример #6
0
        private void Awake()
        {
            TypeConverterSupporter.Init();
            DontDestroyOnLoad(this);
            Logger = base.Logger;
            Settings.Init(Config);
            RuntimeConfig.Init();
            HarmonyPatches.Init();

            var Lib = new ModHelper.ModHelper(GUID, "YanLib");

            Lib.SettingUI = new Container()
            {
                Group =
                {
                    Direction = Direction.Horizontal,
                    Spacing   = 3
                },
                Element  = { PreferredSize = { 0, 50 } },
                Children =
                {
                    new TaiwuLabel()
                    {
                        Text = "事件的选项快捷键"
                    },
                    new TaiwuToggle()
                    {
                        Text           = Settings.ChoiceHotkey.Value ? "开" : "关",
                        isOn           = Settings.ChoiceHotkey.Value,
                        onValueChanged = (bool value, Toggle tg) =>
                        {
                            tg.Text = value ? "开" : "关";
                            Settings.ChoiceHotkey.Value = value;
                        },
                        Element    = { PreferredSize = { 50 } },
                        TipTitle   = "事件的选项快捷键",
                        TipContant = "开启后,选项前九个将会允许用快捷键选择",
                    }
                }
            };
        }
Пример #7
0
        // Taken from RenderingTool.RenderPawnInternal in CharacterEditor
        private void RenderPawn()
        {
            PawnGraphicSet graphics   = pawn.Drawer.renderer.graphics;
            Quaternion     quaternion = Quaternion.AngleAxis(0f, Vector3.up);

            Mesh    bodyMesh   = pawn.RaceProps.Humanlike ? MeshPool.humanlikeBodySet.MeshAt(previewRot) : graphics.nakedGraphic.MeshAt(previewRot);
            Vector3 bodyOffset = new Vector3(0f, pawn.Position.y + 0.007575758f, 0f);

            foreach (Material mat in graphics.MatsBodyBaseAt(previewRot))
            {
                Material damagedMat = graphics.flasher.GetDamagedMat(mat);
                GenDraw.DrawMeshNowOrLater(bodyMesh, bodyOffset, quaternion, damagedMat, false);
                bodyOffset.y += 0.00390625f;
                if (!toggleClothesEnabled)
                {
                    break;
                }
            }
            Vector3 vector3 = new Vector3(0f, pawn.Position.y + (previewRot == Rot4.North ? 0.026515152f : 0.022727273f), 0f);
            Vector3 vector4 = new Vector3(0f, pawn.Position.y + (previewRot == Rot4.North ? 0.022727273f : 0.026515152f), 0f);

            if (graphics.headGraphic != null)
            {
                Mesh     mesh2      = MeshPool.humanlikeHeadSet.MeshAt(previewRot);
                Vector3  headOffset = quaternion * pawn.Drawer.renderer.BaseHeadOffsetAt(previewRot);
                Material material   = graphics.HeadMatAt_NewTemp(previewRot);
                GenDraw.DrawMeshNowOrLater(mesh2, vector4 + headOffset, quaternion, material, false);

                Mesh    hairMesh     = graphics.HairMeshSet.MeshAt(previewRot);
                Vector3 hairOffset   = new Vector3(headOffset.x, pawn.Position.y + 0.030303031f, headOffset.z);
                bool    isWearingHat = false;
                if (toggleClothesEnabled)
                {
                    foreach (ApparelGraphicRecord apparel in graphics.apparelGraphics)
                    {
                        if (apparel.sourceApparel.def.apparel.LastLayer == ApparelLayerDefOf.Overhead)
                        {
                            Material hatMat = graphics.flasher.GetDamagedMat(apparel.graphic.MatAt(previewRot));
                            if (apparel.sourceApparel.def.apparel.hatRenderedFrontOfFace)
                            {
                                isWearingHat  = true;
                                hairOffset.y += 0.03f;
                                GenDraw.DrawMeshNowOrLater(hairMesh, hairOffset, quaternion, hatMat, false);
                            }
                            else
                            {
                                Vector3 hatOffset = new Vector3(headOffset.x, pawn.Position.y + (previewRot == Rot4.North ? 0.003787879f : 0.03409091f), headOffset.z);
                                GenDraw.DrawMeshNowOrLater(hairMesh, hatOffset, quaternion, hatMat, false);
                            }
                        }
                    }
                }
                if (!isWearingHat)
                {
                    Material hairMat = graphics.HairMatAt_NewTemp(previewRot);
                    GenDraw.DrawMeshNowOrLater(hairMesh, hairOffset, quaternion, hairMat, false);
                }
            }
            if (toggleClothesEnabled)
            {
                foreach (ApparelGraphicRecord graphicsSet in graphics.apparelGraphics)
                {
                    if (graphicsSet.sourceApparel.def.apparel.LastLayer == ApparelLayerDefOf.Shell)
                    {
                        Material clothingMat = graphics.flasher.GetDamagedMat(graphicsSet.graphic.MatAt(previewRot));
                        GenDraw.DrawMeshNowOrLater(bodyMesh, vector3, quaternion, clothingMat, false);
                    }
                }
            }
            HarmonyPatches.DrawAddons(false, vector3, pawn, quaternion, previewRot, false);
            if (toggleClothesEnabled)
            {
                if (pawn.apparel != null)
                {
                    foreach (Apparel apparel in pawn.apparel.WornApparel)
                    {
                        apparel.DrawWornExtras();
                    }
                }
            }
        }
Пример #8
0
        public AMAMod(ModContentPack content) : base(content)
        {
            Instance = this;
            settings = GetSettings <AMSettings>();
            harmony.PatchAll(Assembly.GetExecutingAssembly());
            HarmonyPatches.PatchPawnsArrivalModeWorker(harmony);
            if (AdeptusIntergrationUtility.enabled_ResearchPal)
            {
                //    harmony.Patch(AccessTools.Method(GenTypes.GetTypeInAnyAssembly("ResearchPal.Tree", "ResearchPal"), "DrawEquipmentAimingPostFix", null, null), new HarmonyMethod(typeof(AM_ResearchProjectDef_get_PrerequisitesCompleted_CommonTech_ResearchPal_Patch), "Postfix", null));
            }
            showArmouryIntergrationMenu = !Patches.NullOrEmpty() || (AdeptusIntergrationUtility.enabled_AlienRaces && Dev);
            if (!Patches.NullOrEmpty())
            {
                IntergrationOptions = (int)Mathf.Round((Patches.Count / 2) + 0.25f);
                var allPatches = content.Patches as List <PatchOperation>;
                foreach (var patch in Patches)
                {
                    if (patch.optional)
                    {
                        if (settings.PatchDisabled[patch] == false)
                        {
                            if (Prefs.DevMode)
                            {
                                Log.Message("RemoveAll XML Patch: " + patch.label);
                            }
                            allPatches.RemoveAll(p => p.sourceFile.EndsWith(patch.file));
                        }
                        else
                        {
                            if (Prefs.DevMode)
                            {
                                Log.Message("Running XML Patch: " + patch.label);
                            }
                        }
                    }
                }
            }

            if (AdeptusIntergrationUtility.enabled_rooloDualWield)
            {
                string     tname  = "DualWield.Ext_Pawn";
                string     nspace = "DualWield";
                string     mname  = "TryStartOffHandAttack";
                MethodInfo target = AccessTools.Method(GenTypes.GetTypeInAnyAssembly(tname, nspace), mname, null, null);
                if (target == null)
                {
                    Log.Warning("Target: " + tname + "." + mname + " Not found");
                }
                else
                {
                    Type       t      = typeof(Ext_Pawn_TryStartOffHandAttack_DualWield_Patch);
                    string     pmname = "Prefix";
                    MethodInfo patch  = t.GetMethod(pmname);
                    if (patch == null)
                    {
                        Log.Warning("Patch is null " + t.Name.ToString() + "." + pmname);
                    }
                    else
                    {
                        // JobDriver_AttackStatic
                        if (harmony.Patch(target, new HarmonyMethod(patch)) == null)
                        {
                            Log.Warning("AdeptusMechanicus.ModName".Translate() + ": " + tname + " Patch Failed to apply");
                        }
                    }
                }
            }

            listing_Main = new Listing_StandardExpanding();
            if (Prefs.DevMode)
            {
                Log.Message(string.Format("Adeptus Mecanicus: Armoury: successfully completed {0} harmony patches.", harmony.GetPatchedMethods().Select(new Func <MethodBase, Patches>(Harmony.GetPatchInfo)).SelectMany((Patches p) => p.Prefixes.Concat(p.Postfixes).Concat(p.Transpilers)).Count((Patch p) => p.owner.Contains(harmony.Id))));
            }
        }
Пример #9
0
 public override Mesh GetPawnHairMesh(bool portrait)
 {
     return(HarmonyPatches.GetPawnHairMesh(portrait, this.Pawn, this.HeadFacing, this.Graphics));
 }
Пример #10
0
 protected override Mesh GetPawnMesh(bool wantsBody, bool portrait)
 {
     return(HarmonyPatches.GetPawnMesh(portrait, this.Pawn, wantsBody ? this.BodyFacing : this.HeadFacing,
                                       wantsBody));
 }
Пример #11
0
 public override void BaseHeadOffsetAt(ref Vector3 offset, bool portrait)
 {
     base.BaseHeadOffsetAt(ref offset, portrait);
     HarmonyPatches.BaseHeadOffsetAtPostfix(this.Pawn.Drawer.renderer, ref offset);
 }
Пример #12
0
 public override void DrawAlienBodyAddons(bool portrait, Vector3 rootLoc, Quaternion quat, bool renderBody, Rot4 rotation)
 {
     HarmonyPatches.DrawAddons(portrait, this.Pawn, rootLoc, quat, rotation);
 }