Skip to content
This repository has been archived by the owner on Nov 3, 2022. It is now read-only.

Commit

Permalink
Added CompNoTamingDecay
Browse files Browse the repository at this point in the history
  • Loading branch information
juanosarg committed Mar 8, 2022
1 parent 1db7fac commit 00c42c5
Show file tree
Hide file tree
Showing 6 changed files with 115 additions and 0 deletions.
Binary file modified 1.3/Assemblies/VFECore.dll
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ public static class AnimalCollectionClass
// A list of animals that eat weird things to cache them for CompProperties_EatWeirdFood and its Harmony patch
public static HashSet<Thing> weirdeEaters_animals = new HashSet<Thing>();

// A list of animals that don't have taming decay
public static HashSet<ThingDef> notamingdecay_animals = new HashSet<ThingDef>();

// A list of animals for ComLastStand
public static IDictionary<Thing, float> lastStand_animals = new Dictionary<Thing, float>();

Expand Down Expand Up @@ -159,6 +162,29 @@ public static void RemoveFloatingAnimalFromList(Thing thing)

}

public static void AddNoTamingDecayAnimalToList(ThingDef thing)
{

if (!notamingdecay_animals.Contains(thing))
{
notamingdecay_animals.Add(thing);
}
}

public static void RemoveNoTamingDecayAnimalFromList(ThingDef thing)
{
if (notamingdecay_animals.Contains(thing))
{
notamingdecay_animals.Remove(thing);
}

}

public static bool IsNoTamingDecayAnimal(this ThingDef pawn)
{
return notamingdecay_animals.Contains(pawn);
}

public static void AddNoFilthAnimalToList(Thing thing)
{

Expand Down
31 changes: 31 additions & 0 deletions Source/VFECore/AnimalBehaviours/Comps/CompNoTamingDecay.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using Verse;
using System.Linq;
using RimWorld;

namespace AnimalBehaviours
{
public class CompNoTamingDecay : ThingComp
{


public CompProperties_NoTamingDecay Props
{
get
{
return (CompProperties_NoTamingDecay)this.props;
}
}


public override void PostSpawnSetup(bool respawningAfterLoad)
{

AnimalCollectionClass.AddNoTamingDecayAnimalToList(this.parent.def);


}


}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

using Verse;

namespace AnimalBehaviours
{
public class CompProperties_NoTamingDecay : CompProperties
{


public CompProperties_NoTamingDecay()
{
this.compClass = typeof(CompNoTamingDecay);
}


}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using HarmonyLib;
using RimWorld;
using System.Reflection;
using Verse;
using System.Reflection.Emit;
using System.Collections.Generic;
using UnityEngine;
using System.Linq;
using System;
using Verse.AI;
using RimWorld.Planet;



namespace AnimalBehaviours
{


[HarmonyPatch(typeof(TrainableUtility))]
[HarmonyPatch("TamenessCanDecay")]

public static class VanillaExpandedFramework_TrainableUtility_TamenessCanDecay_Patch
{
[HarmonyPrefix]
public static bool RemoveTamenessDecayCheck(ThingDef def)

{
if (AnimalCollectionClass.IsNoTamingDecayAnimal(def))
{
return false;

}
else return true;
}
}


}
3 changes: 3 additions & 0 deletions Source/VFECore/VFECore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -454,8 +454,10 @@
<Compile Include="AnimalBehaviours\Comps\CompMindEffecter.cs" />
<Compile Include="AnimalBehaviours\Comps\CompNearbyEffecter.cs" />
<Compile Include="AnimalBehaviours\Comps\CompNoFilth.cs" />
<Compile Include="AnimalBehaviours\Comps\CompNoTamingDecay.cs" />
<Compile Include="AnimalBehaviours\Comps\CompPassiveRegenerator.cs" />
<Compile Include="AnimalBehaviours\Comps\CompPawnOverlay.cs" />
<Compile Include="AnimalBehaviours\Comps\CompProperties\CompProperties_NoTamingDecay.cs" />
<Compile Include="AnimalBehaviours\Comps\CompProperties\CompProperties_InitialAbility.cs" />
<Compile Include="AnimalBehaviours\Comps\CompProperties\CompProperties_DieAndChangeIntoOtherDef.cs" />
<Compile Include="AnimalBehaviours\Comps\CompProperties\CompProperties_ApplyHediffWhenBound.cs" />
Expand Down Expand Up @@ -553,6 +555,7 @@
<Compile Include="AnimalBehaviours\Harmony\Pawn_PathFollower_CostToMoveIntoCell_Patch.cs" />
<Compile Include="AnimalBehaviours\Harmony\IncidentWorker_SelfTame_Candidates_Patch.cs" />
<Compile Include="AnimalBehaviours\Harmony\Infocard\ThingDef_SpecialDisplayStats_Patch.cs" />
<Compile Include="AnimalBehaviours\Harmony\TrainableUtility_TamenessCanDecay_Patch.cs" />
<Compile Include="AnimalBehaviours\Harmony\VerbProperties_AdjustedCooldown_Patch.cs" />
<Compile Include="AnimalBehaviours\Harmony\WildAnimalSpawner_SpawnRandomWildAnimalAt.cs" />
<Compile Include="AnimalBehaviours\Hediffs\HediffComp_AutoPermanentInjury.cs" />
Expand Down

0 comments on commit 00c42c5

Please sign in to comment.