Skip to content

Commit

Permalink
Pokemonheatpusher hotfix
Browse files Browse the repository at this point in the history
  • Loading branch information
Gargamiel committed Nov 25, 2021
1 parent cfed7b7 commit 4e35bc7
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 19 deletions.
Binary file modified Assemblies/PokeWorld.dll
Binary file not shown.
1 change: 1 addition & 0 deletions Languages/English/Keyed/PokeWorld_Keys.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
<PW_SettingsAllowPokemonInfestation>Allow Pokémon infestations:</PW_SettingsAllowPokemonInfestation>
<PW_SettingsAllowNPCPokemonPack>Allow NPC trade caravan to have Pokémon as pack:</PW_SettingsAllowNPCPokemonPack>
<PW_SettingsAllowGeneration>Allow Gen. {0} Pokémon:</PW_SettingsAllowGeneration>
<PW_SettingsAllowPokemonInRaid>Allow Pokémon in raids:</PW_SettingsAllowPokemonInRaid>

<PW_PokeballContainsShort>Contains: {0}.</PW_PokeballContainsShort>
<PW_PokeballContainsLongGendered>Contains: {0}, level {1} {2} {3}.</PW_PokeballContainsLongGendered>
Expand Down
Binary file modified Source/PokeWorld/.vs/PokeWorld/v16/.suo
Binary file not shown.
20 changes: 2 additions & 18 deletions Source/PokeWorld/PokeWorld/CompPokemonHeatPusher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,14 @@ namespace PokeWorld
{
class CompPokemonHeatPusher : CompHeatPusher
{
private const int HeatPushInterval = 60;

public override void CompTick()
{
base.CompTick();
if (parent.IsHashIntervalTick(60) && ShouldPushHeatNow)
{
CompPokemon comp = parent.TryGetComp<CompPokemon>();
if (comp != null)
{
GenTemperature.PushHeat(parent.PositionHeld, parent.MapHeld, Props.heatPerSecond * Mathf.Sqrt(comp.levelTracker.level) / 2);
}
}
}

public override void CompTickRare()
{
base.CompTickRare();
if (ShouldPushHeatNow)
if (parent != null && parent is Pawn && parent.Spawned && ShouldPushHeatNow)
{
CompPokemon comp = parent.TryGetComp<CompPokemon>();
if (comp != null)
{
GenTemperature.PushHeat(parent.PositionHeld, parent.MapHeld, Props.heatPerSecond * Mathf.Sqrt(comp.levelTracker.level) / 2);
GenTemperature.PushHeat(parent.PositionHeld, parent.MapHeld, Props.heatPerSecond * 4.16666651f * Mathf.Sqrt(comp.levelTracker.level) / 2);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using RimWorld;
using Verse;
using UnityEngine;
using HarmonyLib;

namespace PokeWorld
{
/*
[HarmonyPatch(typeof(PawnGroupKindWorker_Normal))]
[HarmonyPatch("GeneratePawns")]
class PawnGroupKindWorker_Normal_GeneratePawns_Patch
{
public static void postfix(PawnGroupMakerParms __0, PawnGroupMaker __1, List<Pawn> __2, bool __3)
{
Log.Error("1");
if (PokeWorldSettings.allowPokemonInRaid && __2.Any() && (__0.raidStrategy == null || __0.raidStrategy != DefDatabase<RaidStrategyDef>.GetNamed("Siege")))
{
int maxPokes = (int)Rand.Range(__2.Count / 4f, __2.Count / 2f);
for (int i = 0; i < maxPokes; i++)
{
PawnKindDef kind = DefDatabase<PawnKindDef>.AllDefs.Where((PawnKindDef x) => x.race.HasComp(typeof(CompPokemon)) && PokeWorldSettings.GenerationAllowed(x.race.GetCompProperties<CompProperties_Pokemon>().generation) && !x.race.GetCompProperties<CompProperties_Pokemon>().attributes.Contains(PokemonAttribute.Baby) && !x.race.GetCompProperties<CompProperties_Pokemon>().attributes.Contains(PokemonAttribute.Fossil) && !x.race.GetCompProperties<CompProperties_Pokemon>().attributes.Contains(PokemonAttribute.Legendary) && !x.race.GetCompProperties<CompProperties_Pokemon>().attributes.Contains(PokemonAttribute.Particular)).RandomElementByWeight((PawnKindDef x) => 1 / x.race.GetCompProperties<CompProperties_Pokemon>().rarity);
Pawn pawn = PawnGenerator.GeneratePawn(kind, __0.faction);
__2.Add(pawn);
}
}
}
}
*/
}
3 changes: 3 additions & 0 deletions Source/PokeWorld/PokeWorld/ModSetting/PokeWorldSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public class PokeWorldSettings : ModSettings
public static bool allowGen4 = true;
public static bool allowPokemonInfestation = true;
public static bool allowNPCPokemonPack = true;
//public static bool allowPokemonInRaid = true;

public override void ExposeData()
{
Expand All @@ -33,6 +34,7 @@ public override void ExposeData()
Scribe_Values.Look(ref allowGen4, "allowGen4", true);
Scribe_Values.Look(ref allowPokemonInfestation, "allowPokemonInfestation", true);
Scribe_Values.Look(ref allowNPCPokemonPack, "allowNPCPokemonPack", true);
//Scribe_Values.Look(ref allowPokemonInRaid, "allowPokemonInRaid", true);
base.ExposeData();
}
public static bool OkforPokemon()
Expand Down Expand Up @@ -82,6 +84,7 @@ public override void DoSettingsWindowContents(Rect inRect)
ListingStandardHelper.AddLabelLine(listingStandard, "PW_SettingsWildPokemonFrequencyDesc".Translate());
ListingStandardHelper.AddLabeledCheckbox(listingStandard, "PW_SettingsAllowPokemonInfestation".Translate(), ref PokeWorldSettings.allowPokemonInfestation);
ListingStandardHelper.AddLabeledCheckbox(listingStandard, "PW_SettingsAllowNPCPokemonPack".Translate(), ref PokeWorldSettings.allowNPCPokemonPack);
//ListingStandardHelper.AddLabeledCheckbox(listingStandard, "PW_SettingsAllowPokemonInRaid".Translate(), ref PokeWorldSettings.allowPokemonInRaid);
ListingStandardHelper.AddLabeledCheckbox(listingStandard, "PW_SettingsAllowGeneration".Translate(1), ref PokeWorldSettings.allowGen1);
ListingStandardHelper.AddLabeledCheckbox(listingStandard, "PW_SettingsAllowGeneration".Translate(2), ref PokeWorldSettings.allowGen2);
ListingStandardHelper.AddLabeledCheckbox(listingStandard, "PW_SettingsAllowGeneration".Translate(3), ref PokeWorldSettings.allowGen3);
Expand Down
1 change: 1 addition & 0 deletions Source/PokeWorld/PokeWorld/PokeWorld.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
<ItemGroup>
<Compile Include="CompPokemonPower.cs" />
<Compile Include="CompPokemonHeatPusher.cs" />
<Compile Include="Harmony_Patching\PawnGroupKindWorker_Normal_GeneratePawns_Patch.cs" />
<Compile Include="Harmony_Patching\Pawn_TrainingTracker_Train_Patch.cs" />
<Compile Include="PokemonDamageUtility.cs" />
<Compile Include="Eggs\StockGenerator_PokemonEgg.cs" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8c70cf5f84b32b2c2e41a39f40dc001a360214be
1a86222b168386ef6d165307b9964b6e4592104c
Binary file modified Source/PokeWorld/PokeWorld/obj/Debug/PokeWorld.dll
Binary file not shown.

0 comments on commit 4e35bc7

Please sign in to comment.