Ejemplo n.º 1
0
        public static void ApplyCompat(HarmonyLib.Harmony harm)
        {
            if (ModLister.HasActiveModWithName("RunAndGun") && Base.Features.EnabledAtAll)
            {
                Log.Message("[MVCF] Applying RunAndGun compatibility patch");
                harm.Patch(AccessTools.Method(Type.GetType("RunAndGun.Harmony.Verb_TryCastNextBurstShot, RunAndGun"),
                                              "SetStanceRunAndGun"),
                           transpiler: new HarmonyMethod(typeof(Compat), "RunAndGunSetStance"));
                harm.Patch(AccessTools.Method(Type.GetType("RunAndGun.Harmony.Verb_TryStartCastOn, RunAndGun"),
                                              "Prefix"),
                           new HarmonyMethod(typeof(Compat), "RunAndGunVerbCast"));
                harm.Patch(Type.GetType("RunAndGun.Extensions, RunAndGun")
                           ?.GetMethod("HasRangedWeapon"),
                           postfix: new HarmonyMethod(typeof(Compat), "RunAndGunHasRangedWeapon"));
            }

            if (ModLister.HasActiveModWithName("Dual Wield") && Base.Features.HumanoidVerbs)
            {
                Log.Message("[MVCF] Applying Dual Wield compatibility patch");
                GetStancesOffHand = AccessTools.Method(Type.GetType(
                                                           "DualWield.Ext_Pawn, DualWield"), "GetStancesOffHand")
                                    .CreateDelegate(typeof(Func <Pawn, Pawn_StanceTracker>));
                IsOffHand = AccessTools.Method(Type.GetType(
                                                   "DualWield.Ext_ThingWithComps, DualWield"), "IsOffHand")
                            .CreateDelegate(typeof(Func <ThingWithComps, bool>));
                harm.Patch(
                    Type.GetType("DualWield.Harmony.Pawn_RotationTracker_UpdateRotation, DualWield")
                    ?.GetMethod("Postfix", BindingFlags.NonPublic | BindingFlags.Static),
                    new HarmonyMethod(typeof(Compat), "UpdateRotation"));
                harm.Patch(
                    Type.GetType("DualWield.Harmony.PawnRenderer_RenderPawnAt, DualWield")
                    ?.GetMethod("Postfix", BindingFlags.NonPublic | BindingFlags.Static),
                    new HarmonyMethod(typeof(Compat), "RenderPawnAt"));
            }
        }
Ejemplo n.º 2
0
        private static IEnumerable <InspectTabBase> GetTabsOfAnySelectedThingWeCareAbout(Selector __instance)
        {
            if (__instance.SelectedZone is Zone_Stockpile stockpile)
            {
                return(stockpile.GetInspectTabs());
            }

            if (__instance.SingleSelectedThing is Building_WorkTable workTable)
            {
                return(workTable.GetInspectTabs());
            }

            if (__instance.SingleSelectedThing is Building_Storage storage)
            {
                if (ModLister.HasActiveModWithName("LWM's Deep Storage"))
                {
                    // Deep Storage handles tabs on its own for storage buildings
                    return(null);
                }

                return(storage.GetInspectTabs());
            }

            return(null);
        }
Ejemplo n.º 3
0
        private void LoadOneTemperatureMod(HarmonyInstance harmony)
        {
            foreach (var mod in ModsConfig.ActiveModsInLoadOrder)
            {
                switch (mod.Name)
                {
                case CentralizedClimateControlName:
                    if (!Settings.EnableCentralizedClimateControlSupport)
                    {
                        Log.Message("Frontier Developments Shields :: disabling Centralized Climate Control support");
                        continue;
                    }
                    if (Settings.EnableRedistHeatSupport && ModLister.HasActiveModWithName(RedistHeatName))
                    {
                        Log.Warning("Frontier Developments Shields :: detected both " + CentralizedClimateControlName + " and " + RedistHeatName + " active. Using " + CentralizedClimateControlName + " since it is loaded first");
                    }
                    new ClimateControlIntegration().TryEnable(harmony);
                    return;

                case "RedistHeat":
                    if (!Settings.EnableRedistHeatSupport)
                    {
                        Log.Message("Frontier Developments Shields :: disabling RedistHeat support");
                        continue;
                    }
                    if (Settings.EnableCentralizedClimateControlSupport && ModLister.HasActiveModWithName(CentralizedClimateControlName))
                    {
                        Log.Warning("Frontier Developments Shields :: detected both " + CentralizedClimateControlName + " and " + RedistHeatName + " active. Using " + RedistHeatName + " since it is loaded first");
                    }
                    new RedistHeatIntegration().TryEnable(harmony);
                    return;
                }
            }
        }
        private static void ModCompatibilityInitialized()
        {
            List <ModMetaData> mods = ModLister.AllInstalledMods.ToList();

            foreach (ModMetaData mod in mods)
            {
                if (ModLister.HasActiveModWithName(mod.Name) && mod.Identifier == "1631756268" && !SRTSHelper.CEModLoaded)
                {
                    Log.Message("[SRTS Expanded] Initializing Combat Extended patch for Bombing Runs.");
                    if (!SRTSMod.mod.settings.CEPreviouslyInitialized)
                    {
                        SRTSMod.mod.ResetBombList();
                    }
                    SRTSMod.mod.settings.CEPreviouslyInitialized = true;

                    SRTSHelper.CEModLoaded = true;
                    SRTSHelper.CompProperties_ExplosiveCE = AccessTools.TypeByName("CompProperties_ExplosiveCE");
                    SRTSHelper.CompExplosiveCE            = AccessTools.TypeByName("CompExplosiveCE");
                }
                if (ModLister.HasActiveModWithName(mod.Name) && mod.Identifier == "1909914131" && !SRTSHelper.SOS2ModLoaded)
                {
                    Log.Message("[SRTS Expanded] Initializing SoS2 Compatibility Patch.");
                    SRTSHelper.SpaceSite = DefDatabase <WorldObjectDef> .GetNamed("SiteSpace");

                    SRTSHelper.SpaceSiteType      = AccessTools.TypeByName("SpaceSite");
                    SRTSHelper.SOS2LaunchableType = AccessTools.TypeByName("CompShuttleLaunchable");
                    SRTSHelper.SOS2ModLoaded      = true;
                }
            }
            if (SRTSMod.mod.settings.CEPreviouslyInitialized && !SRTSHelper.CEModLoaded)
            {
                SRTSMod.mod.settings.CEPreviouslyInitialized = false;
                SRTSMod.mod.ResetBombList();
            }
        }
Ejemplo n.º 5
0
        // Token: 0x06000073 RID: 115 RVA: 0x00004EF4 File Offset: 0x000030F4
        public void DoWindowContents(Rect canvas)
        {
            var listing_Standard = new Listing_Standard {
                ColumnWidth = canvas.width
            };

            listing_Standard.Begin(canvas);
            listing_Standard.Gap();
            if (!ModLister.HasActiveModWithName("Medical Supplements"))
            {
                listing_Standard.CheckboxLabeled("AY.RealismBandages".Translate(), ref RealismBandages);
                listing_Standard.Gap();
            }

            listing_Standard.CheckboxLabeled("AY.WashLowersQual".Translate(), ref WashLowersQual);
            listing_Standard.Gap();
            listing_Standard.CheckboxLabeled("AY.AllowCollapseRocks".Translate(), ref AllowCollapseRocks);
            listing_Standard.Gap(36f);
            checked
            {
                listing_Standard.Label("AY.ResPct".Translate() + "  " + (int)ResPct);
                ResPct = (int)listing_Standard.Slider((int)ResPct, 10f, 200f);
                listing_Standard.Gap();
                Text.Font = GameFont.Tiny;
                listing_Standard.Label("          " + "AY.ResWarn".Translate());
                listing_Standard.Gap();
                listing_Standard.Label("          " + "AY.ResTip".Translate());
                Text.Font = GameFont.Small;
                listing_Standard.Gap();
                listing_Standard.End();
            }
        }
Ejemplo n.º 6
0
 public static void DoPawnToxicDamage(Pawn p)
 {
     if (p.Spawned && p.Position.Roofed(p.Map))
     {
         return;
     }
     if (!p.RaceProps.IsFlesh)
     {
         return;
     }
     if (p.def.BaseFlammability == 0)
     {
         return;
     }
     if (ModLister.HasActiveModWithName("Alpha Animals"))
     {
         p.TakeDamage(new DamageInfo(DefDatabase <DamageDef> .GetNamed("AA_AcidRainDamage", true), 1, 0f, -1f, null, null, null, DamageInfo.SourceCategory.ThingOrUnknown));
     }
     else
     {
         float num = 0.028758334f;
         num *= p.GetStatValue(StatDefOf.ToxicSensitivity, true);
         if (num != 0f)
         {
             float num2 = Mathf.Lerp(0.85f, 1.15f, Rand.ValueSeeded(p.thingIDNumber ^ 74374237));
             num *= num2;
             HealthUtility.AdjustSeverity(p, HediffDefOf.ToxicBuildup, num);
         }
     }
 }
Ejemplo n.º 7
0
        protected override bool ApplyWorker(XmlDocument xml)
        {
            bool flag = false;

            for (int i = 0; i < this.mods.Count; i++)
            {
                if (ModLister.HasActiveModWithName(this.mods[i]))
                {
                    flag = true;
                }
                else
                {
                    flag = false;
                    break;
                }
            }

            if (this.enabled && flag)
            {
                if (this.match != null)
                {
                    return(this.match.Apply(xml));
                }
            }
            return(true);
        }
Ejemplo n.º 8
0
        static HarmonyPatches()
        {
            Harmony harmony = new Harmony("LongerCFloor.ProxyHeat");

            CompTemperatureSource.gasCompType = AccessTools.TypeByName("GasNetwork.CompGasTrader");
            if (CompTemperatureSource.gasCompType != null)
            {
                CompTemperatureSource.methodInfoGasOn = AccessTools.PropertyGetter(CompTemperatureSource.gasCompType, "GasOn");
            }
            harmony.PatchAll();
            if (ModLister.HasActiveModWithName("Brrr and Phew (Continued)"))
            {
                var prefix  = AccessTools.Method(typeof(HarmonyPatches), nameof(HarmonyPatches.TryGiveJobPrefix));
                var postfix = AccessTools.Method(typeof(HarmonyPatches), nameof(HarmonyPatches.TryGiveJobPostfix));
                foreach (var type in GenTypes.AllSubclasses(typeof(ThinkNode_JobGiver)))
                {
                    if (type.Namespace == "Brrr")
                    {
                        var method = AccessTools.Method(type, "TryGiveJob");
                        harmony.Patch(method, new HarmonyMethod(prefix), new HarmonyMethod(postfix));
                    }
                }

                var genNewRRJobMethod = AccessTools.Method("Brrr.BrrrGlobals:GenNewRRJob");
                harmony.Patch(genNewRRJobMethod, new HarmonyMethod(typeof(HarmonyPatches), nameof(HarmonyPatches.GenNewRRJobPrefix)));

                var meth_JobGiver_Brrr_TryGiveJob = AccessTools.Method("Brrr.JobGiver_Brrr:TryGiveJob");
                harmony.Patch(meth_JobGiver_Brrr_TryGiveJob, null, null, new HarmonyMethod(typeof(HarmonyPatches), nameof(HarmonyPatches.JobGiver_BrrrTranspiler)));

                var meth_JobGiver_Phew_TryGiveJob = AccessTools.Method("Brrr.JobGiver_Phew:TryGiveJob");
                harmony.Patch(meth_JobGiver_Phew_TryGiveJob, null, null, new HarmonyMethod(typeof(HarmonyPatches), nameof(HarmonyPatches.JobGiver_PhewTranspiler)));
            }
        }
Ejemplo n.º 9
0
        public static bool CanInstall()
        {
            if (!ModLister.HasActiveModWithName("ED-Shields"))
            {
                return(false);
            }
            shieldBuildingType  = Type.GetType("Jaxxa.EnhancedDevelopment.Shields.Shields.Building_Shield, ED-Shields");
            shieldGeneratorType = Type.GetType("Jaxxa.EnhancedDevelopment.Shields.Shields.Comp_ShieldGenerator, ED-Shields");

            if (shieldBuildingType == null || shieldGeneratorType == null)
            {
                return(false);
            }
            IsActive = shieldGeneratorType.GetMethod("IsActive", BindingFlags.Public | BindingFlags.Instance);

            BlockIndirect_Active = shieldGeneratorType.GetMethod("BlockIndirect_Active", BindingFlags.Public | BindingFlags.Instance);
            BlockDirect_Active   = shieldGeneratorType.GetMethod("BlockDirect_Active", BindingFlags.Public | BindingFlags.Instance);

            FieldRadius = shieldGeneratorType.GetMethod("FieldRadius_Active", BindingFlags.Public | BindingFlags.Instance);

            FieldIntegrity_Current = shieldGeneratorType.GetProperty("FieldIntegrity_Current", BindingFlags.Public | BindingFlags.Instance);

            if (IsActive == null || BlockIndirect_Active == null || BlockDirect_Active == null || FieldRadius == null || FieldIntegrity_Current == null)
            {
                return(false);
            }
            GetShieldGenerator = typeof(Building).GetMethod("GetComp", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).MakeGenericMethod(shieldGeneratorType);
            return(true);
        }
Ejemplo n.º 10
0
 public static bool CanInstall()
 {
     if (!ModLister.HasActiveModWithName("ED-Shields"))
     {
         return(false);
     }
     return(true);
 }
        // Token: 0x060000F2 RID: 242 RVA: 0x0000AA98 File Offset: 0x00008C98
        protected override bool ApplyWorker(XmlDocument xml)
        {
            bool flag  = false;
            bool flag2 = GenText.NullOrEmpty(this.defName);
            bool result;

            if (flag2)
            {
                result = false;
            }
            else
            {
                foreach (object obj in xml.SelectNodes("Defs/ThingDef[defName=\"" + this.defName + "\"]"))
                {
                    flag = true;
                    XmlNode      xmlNode      = obj as XmlNode;
                    XmlContainer xmlContainer = this.statBases;
                    bool         flag3        = xmlContainer != null && xmlContainer.node.HasChildNodes;
                    if (flag3)
                    {
                        this.AddOrReplaceStatBases(xml, xmlNode);
                    }
                    XmlContainer xmlContainer2 = this.costList;
                    bool         flag4         = xmlContainer2 != null && xmlContainer2.node.HasChildNodes;
                    if (flag4)
                    {
                        this.AddOrReplaceCostList(xml, xmlNode);
                    }
                    bool flag5 = this.Properties != null && this.Properties.node.HasChildNodes;
                    if (flag5)
                    {
                        this.AddOrReplaceVerbPropertiesCE(xml, xmlNode);
                    }
                    bool flag6 = this.AmmoUser != null || this.FireModes != null;
                    if (flag6)
                    {
                        this.AddOrReplaceCompsCE(xml, xmlNode);
                    }
                    bool flag7 = this.weaponTags != null && this.weaponTags.node.HasChildNodes;
                    if (flag7)
                    {
                        this.AddOrReplaceWeaponTags(xml, xmlNode);
                    }
                    bool flag8 = this.researchPrerequisite != null;
                    if (flag8)
                    {
                        this.AddOrReplaceResearchPrereq(xml, xmlNode);
                    }
                    bool flag9 = ModLister.HasActiveModWithName("RunAndGun") && !this.AllowWithRunAndGun;
                    if (flag9)
                    {
                        this.AddRunAndGunExtension(xml, xmlNode);
                    }
                }
                result = flag;
            }
            return(result);
        }
Ejemplo n.º 12
0
 static Startup()
 {
     if (ModLister.HasActiveModWithName("Combat Extended"))
     {
         helper = new CEhelper();
         CombatExtendedLoaded = true;
         Log.Message("[Yes, Vehicles, Finally!] Combat Extended found. The reload feature is enabled for vehicles.");
     }
 }
Ejemplo n.º 13
0
        public static bool CanInstall()
        {
            if (!ModLister.HasActiveModWithName(VFES_ModName))
            {
                return(false);
            }

            return(true);
        }
        protected override IEnumerable <Toil> MakeNewToils()
        {
            this.FailOnDespawnedNullOrForbidden(TargetIndex.A);
            this.FailOnDowned(TargetIndex.A);
            this.FailOnNotCasualInterruptible(TargetIndex.A);
            yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.Touch));

            Toil wait = new Toil();

            wait.initAction = delegate()
            {
                Pawn actor = wait.actor;
                Pawn pawn  = (Pawn)this.job.GetTarget(TargetIndex.A).Thing;
                actor.pather.StopDead();
                PawnUtility.ForceWait(pawn, 15000, null, true);
            };
            wait.tickAction = delegate()
            {
                Pawn actor = wait.actor;
                actor.skills.Learn(SkillDefOf.Animals, 0.13f, false);
                this.gatherProgress += actor.GetStatValue(StatDefOf.AnimalGatherSpeed, true);
                if (this.gatherProgress >= this.WorkTotal)
                {
                    this.GetSpecificComp((Pawn)((Thing)this.job.GetTarget(TargetIndex.A))).InformGathered(this.pawn);
                    actor.jobs.EndCurrentJob(JobCondition.Succeeded, true, true);
                    if (ModLister.HasActiveModWithName("Alpha Animals"))
                    {
                        actor.health.AddHediff(HediffDef.Named("AA_GatheredResource"));
                    }
                }
            };
            wait.AddFinishAction(delegate
            {
                Pawn pawn = (Pawn)this.job.GetTarget(TargetIndex.A).Thing;
                if (pawn != null && pawn.CurJobDef == JobDefOf.Wait_MaintainPosture)
                {
                    pawn.jobs.EndCurrentJob(JobCondition.InterruptForced, true, true);
                }
            });
            wait.FailOnDespawnedOrNull(TargetIndex.A);
            wait.FailOnCannotTouch(TargetIndex.A, PathEndMode.Touch);
            wait.AddEndCondition(delegate
            {
                if (!this.GetComp((Pawn)((Thing)this.job.GetTarget(TargetIndex.A))).ActiveAndFull)
                {
                    return(JobCondition.Incompletable);
                }
                return(JobCondition.Ongoing);
            });
            wait.defaultCompleteMode = ToilCompleteMode.Never;
            wait.WithProgressBar(TargetIndex.A, () => this.gatherProgress / this.WorkTotal, false, -0.5f);
            wait.activeSkill = (() => SkillDefOf.Animals);

            yield return(wait);

            yield break;
        }
 public static void DefsLoaded(Harmony harmony)
 {
     // AlexTD fixed this same bug
     if (fixFilteredProductStackCounts.Value && !ModLister.HasActiveModWithName("TD Enhancement Pack"))
     {
         harmony.Patch(
             AccessTools.Method(typeof(RecipeWorkerCounter), nameof(RecipeWorkerCounter.CountValidThings)),
             transpiler: new HarmonyMethod(typeof(Patch_BugFixes), nameof(ProductStackCounts)));
     }
 }
Ejemplo n.º 16
0
        public static bool IsSoftBedsActive()
        {
            var modName = "[JPT] Soft Warm Beds";

            if (ModLister.HasActiveModWithName(modName))
            {
                return(true);
            }
            return(false);
        }
Ejemplo n.º 17
0
        public static bool IsCEActive()
        {
            var modName = "Combat Extended";

            if (ModLister.HasActiveModWithName(modName))
            {
                return(true);
            }
            return(false);
        }
Ejemplo n.º 18
0
 public bool ModsFound()
 {
     for (int index = 0; index < this.mods.Count; index++)
     {
         if (!ModLister.HasActiveModWithName(this.mods[index]))
         {
             return(false);
         }
     }
     return(true);
 }
Ejemplo n.º 19
0
 public override string CompInspectStringExtra()
 {
     if (ModLister.HasActiveModWithName("Alpha Animals"))
     {
         return((this.Props.nextSpawnInspectStringKey ?? "AB_SpawningNextBumbledrone").Translate((this.nextPawnSpawnTick - Find.TickManager.TicksGame).ToStringTicksToDays("F1")));
     }
     else
     {
         return("AB_AlphaAnimalsNotInstalled".Translate());
     }
 }
 public override string SettingsCategory()
 {
     if (ModLister.HasActiveModWithName("Vanilla Cooking Expanded"))
     {
         return("Vanilla Cooking Expanded");
     }
     else
     {
         return("");
     }
 }
        protected override bool ApplyWorker(XmlDocument xml)
        {
            bool result = false;

            if (defName.NullOrEmpty())
            {
                return(false);
            }

            foreach (var current in xml.SelectNodes("Defs/ThingDef[defName=\"" + defName + "\"]"))
            {
                result = true;

                var xmlNode = current as XmlNode;

                if (statBases?.node.HasChildNodes ?? false)
                {
                    AddOrReplaceStatBases(xml, xmlNode);
                }
                if (costList?.node.HasChildNodes ?? false)
                {
                    AddOrReplaceCostList(xml, xmlNode);
                }

                if (Properties != null && Properties.node.HasChildNodes)
                {
                    AddOrReplaceVerbPropertiesCE(xml, xmlNode);
                }

                if (AmmoUser != null || FireModes != null)
                {
                    AddOrReplaceCompsCE(xml, xmlNode);
                }

                if (weaponTags != null && weaponTags.node.HasChildNodes)
                {
                    AddOrReplaceWeaponTags(xml, xmlNode);
                }

                if (researchPrerequisite != null)
                {
                    AddOrReplaceResearchPrereq(xml, xmlNode);
                }

                // RunAndGun compatibility
                if (ModLister.HasActiveModWithName("RunAndGun") && !AllowWithRunAndGun)
                {
                    AddRunAndGunExtension(xml, xmlNode);
                }
            }

            return(result);
        }
Ejemplo n.º 22
0
        public override void CompTick()
        {
            if (this.parent.IsHashIntervalTick(Props.checkingRate))
            {
                Pawn pawn = this.parent as Pawn;

                if (pawn.Spawned)
                {
                    if (pawn.Faction != null && pawn.Faction.IsPlayer)
                    {
                        IntVec3 cell;
                        if (Props.inRadius)
                        {
                            cell = CellFinder.RandomClosewalkCellNear(pawn.Position, pawn.Map, Props.radius, null);
                        }
                        else
                        {
                            cell = pawn.Position;
                        }

                        if ((cell.GetTerrain(pawn.Map) == TerrainDef.Named(Props.FirstStageTerrain)))
                        {
                            pawn.Map.terrainGrid.SetTerrain(cell, TerrainDef.Named(Props.SecondStageTerrain));

                            //This is for achievements

                            if (ModLister.HasActiveModWithName("Alpha Animals"))
                            {
                                pawn.health.AddHediff(HediffDef.Named("AA_FertilizedTerrain"));
                            }
                        }
                        if (Props.doThirdStage)
                        {
                            extraFertCounter--;
                            if (extraFertCounter <= 0)
                            {
                                if (pawn.training.HasLearned(TrainableDefOf.Obedience) && ((cell.GetTerrain(pawn.Map) == TerrainDef.Named(Props.SecondStageTerrain))))
                                {
                                    pawn.Map.terrainGrid.SetTerrain(cell, TerrainDef.Named(Props.ThirdStageTerrain));
                                    //This is for achievements

                                    if (ModLister.HasActiveModWithName("Alpha Animals"))
                                    {
                                        pawn.health.AddHediff(HediffDef.Named("AA_FertilizedTerrain"));
                                    }
                                }
                                extraFertCounter = 5;
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 23
0
Archivo: Compat.cs Proyecto: Ecu/MVCF
 public static void ApplyCompat(HarmonyLib.Harmony harm)
 {
     if (ModLister.HasActiveModWithName("RunAndGun"))
     {
         Log.Message("[MVCF] Applying RunAndGun compatibility patch");
         harm.Patch(Type.GetType("RunAndGun.Harmony.Verb_TryCastNextBurstShot, RunAndGun")
                    ?.GetMethod("SetStanceRunAndGun"),
                    transpiler: new HarmonyMethod(typeof(Compat), "RunAndGunSetStance"));
         harm.Patch(Type.GetType("RunAndGun.Extensions, RunAndGun")
                    ?.GetMethod("HasRangedWeapon"),
                    postfix: new HarmonyMethod(typeof(Compat), "RunAndGunHasRangedWeapon"));
     }
 }
Ejemplo n.º 24
0
Archivo: Base.cs Proyecto: Ecu/MVCF
        public Base(ModContentPack content) : base(content)
        {
            var harm = new HarmonyLib.Harmony("legodude17.mvcf");

            harm.PatchAll(Assembly.GetExecutingAssembly());
            SearchLabel = harm.Id + Rand.Value;
            Prepatcher  = ModLister.HasActiveModWithName("Prepatcher");
            if (Prepatcher)
            {
                Log.Message("[MVCF] Prepatcher installed, switching");
            }
            Compat.ApplyCompat(harm);
        }
        static RegisterVanillaMortarsAsRefuelable()
        {
            if (!ModLister.HasActiveModWithName("Project RimFactory Revived") && !ModLister.HasActiveModWithName("Project RimFactory Lite"))
            {
                return;
            }
            // This gets the PRF Building_FuelingMachine from our assembly - it works from any mod's
            //   assembly!
            Type refueler = Type.GetType("ProjectRimFactory.Industry.Building_FuelingMachine, ProjectRimFactory", false);

            // But we still check in case anything went wrong.
            if (refueler == null)
            {
                // -- Feel free to add your own error message if things fail. --
                Log.Warning("PRF failed to load compatibility for PRF; auto loading mortars won't work");
                return;
            }
            // Call PRF's RegisterRefuelable(Type buildingType,
            //                               Func<Building, object> getObjectThatNeedsFueling,
            //                               Func<object, Thing, int> isThisFuelTest,
            //                               Action< object, Thing > refuelAction);
            refueler.GetMethod("RegisterRefuelable", System.Reflection.BindingFlags.Static |
                               System.Reflection.BindingFlags.Public).Invoke(null,
                                                                             new object[] {
                // ----- pass the type of your Building (we only refuel buildings -----
                typeof(Building_TurretGun),
                // ----- pass a method/delegate that returns `null` if nothing needs refueling,
                //       or the object that needs refueling. Note you may pass static methods -----
                (Func <Building, object>) FindCompNeedsShells,
                // ----- pass a method/delegate that checks if the Thing t can refuel your object c
                //       You must return the number of this Thing you want to refuel your object,
                //       (0 if you do not want any of this as fuel)
                (Func <object, Thing, int>) delegate(object c, Thing t)
                {
                    CompChangeableProjectile comp = c as CompChangeableProjectile;
                    if (comp.allowedShellsSettings.filter.Allows(t))
                    {
                        return(1);
                    }
                    return(0);
                },
                // ----- pass a (void) method/action delegate that consumes the Thing t -
                //       you probably want to Destroy() it? But whatever you need - the
                //       Thing t is completely yours here. It may or may not be spawned -----
                (Action <object, Thing>) delegate(object c, Thing t)
                {
                    (c as CompChangeableProjectile).LoadShell(t.def, 1);
                    t.Destroy();
                }
            });
        }
        public override bool ForceAllowPlaceOver(BuildableDef other)
        {
            if (other.blueprintDef != null && other.blueprintDef.IsSmoothed)
            {
                return(true);
            }
            var def = other as ThingDef;

            if (def != null && def.IsNonResourceNaturalRock && !ModLister.HasActiveModWithName("Replace Stuff"))
            {
                return(true);
            }

            return(base.ForceAllowPlaceOver(other));
        }
Ejemplo n.º 27
0
 public override void MapComponentTick()
 {
     base.MapComponentTick();
     if (!Current.Game.GetComponent <UpdateNoticeGlobal>().sentUpdateLetterGlobal)
     {
         if (!ModLister.HasActiveModWithName("Vanilla Textures Expanded - Genetic Rim"))
         {
             if (!LoadedModManager.GetMod <GeneticRim_Mod>().GetSettings <GeneticRim_Settings>().removeUpdateNotice)
             {
                 Find.LetterStack.ReceiveLetter("GR_UpdateLetterLabel".Translate(), "GR_UpdateLetterText".Translate(), DefDatabase <LetterDef> .GetNamed("GR_UpdateLetter"));
             }
         }
         Current.Game.GetComponent <UpdateNoticeGlobal>().sentUpdateLetterGlobal = true;
     }
 }
Ejemplo n.º 28
0
        static FishingCompatibility()
        {
            List <ModMetaData> mods = ModLister.AllInstalledMods.ToList();

            fishingActivated = false;
            for (int i = 0; i < mods.Count; i++)
            {
                ModMetaData mod = mods[i];
                if (ModLister.HasActiveModWithName(mod.Name) && AddFishesFromMod(mod))
                {
                    Log.Message("[Boats] Adding Fishing Compatibility for: " + mod.Name);
                    fishingActivated = true;
                    break;
                }
            }
        }
Ejemplo n.º 29
0
        public static void Postfix(Pawn healer, Pawn patient, ref Thing __result)
        {
            if (ModLister.HasActiveModWithName("Medical Supplements") || !Controller.Settings.RealismBandages ||
                __result == null || !IsBandage(__result.def) || BandagesValid(patient))
            {
                return;
            }

            var medPot = __result.def.GetStatValueAbstract(StatDefOf.MedicalPotency);

            __result = GenClosest.ClosestThing_Global_Reachable(patient.Position, patient.Map,
                                                                patient.Map.listerThings.ThingsInGroup(ThingRequestGroup.Medicine), PathEndMode.ClosestTouch,
                                                                TraverseParms.For(healer), 9999f,
                                                                m => !m.IsForbidden(healer) && healer.CanReserve(m) && !IsBandage(m.def) &&
                                                                m.def.GetStatValueAbstract(StatDefOf.MedicalPotency) <= medPot,
                                                                m => m.def.GetStatValueAbstract(StatDefOf.MedicalPotency));
        }
        public static void ApplyCompat(HarmonyLib.Harmony harm)
        {
            if (ModLister.HasActiveModWithName("RunAndGun") && Base.Features.EnabledAtAll)
            {
                Verse.Log.Message("[MVCF] Applying RunAndGun compatibility patch");
                harm.Patch(AccessTools.Method(Type.GetType("RunAndGun.Harmony.Verb_TryCastNextBurstShot, RunAndGun"),
                                              "SetStanceRunAndGun"),
                           transpiler: new HarmonyMethod(typeof(Compat), "RunAndGunSetStance"));
                harm.Patch(AccessTools.Method(Type.GetType("RunAndGun.Harmony.Verb_TryStartCastOn, RunAndGun"),
                                              "Prefix"),
                           new HarmonyMethod(typeof(Compat), "RunAndGunVerbCast"));
                harm.Patch(Type.GetType("RunAndGun.Extensions, RunAndGun")
                           ?.GetMethod("HasRangedWeapon"),
                           postfix: new HarmonyMethod(typeof(Compat), "RunAndGunHasRangedWeapon"));
            }

            if (ModLister.HasActiveModWithName("Dual Wield") && Base.Features.HumanoidVerbs)
            {
                Verse.Log.Message("[MVCF] Applying Dual Wield compatibility patch");
                RotationTrackerPawn = AccessTools
                                      .FieldRefAccess <Pawn_RotationTracker, Pawn>("pawn");
                RendererPawn          = AccessTools.FieldRefAccess <PawnRenderer, Pawn>("pawn");
                GetStancesOffHandInfo = AccessTools.Method(Type.GetType(
                                                               "DualWield.Ext_Pawn, DualWield"), "GetStancesOffHand");
                IsOffHand = AccessTools.Method(Type.GetType(
                                                   "DualWield.Ext_ThingWithComps, DualWield"), "IsOffHand")
                            .CreateDelegate(typeof(Func <ThingWithComps, bool>));

                harm.Patch(
                    Type.GetType("DualWield.Harmony.Pawn_RotationTracker_UpdateRotation, DualWield")
                    ?.GetMethod("Postfix", BindingFlags.NonPublic | BindingFlags.Static),
                    transpiler: new HarmonyMethod(typeof(Compat), "UpdateRotationTranspile"));
                harm.Patch(
                    Type.GetType("DualWield.Harmony.PawnRenderer_RenderPawnAt, DualWield")
                    ?.GetMethod("Postfix", BindingFlags.NonPublic | BindingFlags.Static),
                    transpiler: new HarmonyMethod(typeof(Compat), "RenderPawnAtTranspile"));
            }

            var type = AccessTools.TypeByName("CompToggleFireMode.CompToggleFireMode");

            if (type != null)
            {
                GetToggleComp = AccessTools.Method(typeof(ThingCompUtility), "TryGetComp")
                                .MakeGenericMethod(type);
            }
        }