Skip to content

Commit

Permalink
Merge pull request #21 from JonnyNova/ce-lag-fix
Browse files Browse the repository at this point in the history
CE explosion lag fix
  • Loading branch information
jecrell authored Jun 3, 2019
2 parents 7f7162a + 83375a1 commit 65b381b
Showing 1 changed file with 11 additions and 20 deletions.
31 changes: 11 additions & 20 deletions Source/HarmonyPatches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -693,17 +693,9 @@ public static void ShouldNotEnterCellInvisDoors(Pawn pawn, Map map, IntVec3 dest
public static bool WipeExistingThings(IntVec3 thingPos, Rot4 thingRot, BuildableDef thingDef, Map map,
DestroyMode mode)
{
//Log.Message("1");
var trueDef = DefDatabase<ThingDef>.AllDefs.FirstOrDefault(predicate: x => x.defName == thingDef.defName);
//if (trueDef != null && trueDef.thingClass == typeof(Building_DoorExpanded) && !thingPos.GetThingList(map).Any(x => x is Building_DoorExpanded))
// return false;
if (thingDef == HeronDefOf.HeronInvisibleDoor ||
thingDef.defName == HeronDefOf.HeronInvisibleDoor.defName)
{
return false;
}

return true;
// allow vanilla to run if this is not an invisible door
return thingDef.defName != HeronDefOf.HeronInvisibleDoor.defName
&& thingDef != HeronDefOf.HeronInvisibleDoor;
}

//GenSpawn
Expand All @@ -715,24 +707,23 @@ public static void InvisDoorsDontWipe(BuildableDef newEntDef, BuildableDef oldEn
return;
}

var oldTrueDef =
DefDatabase<ThingDef>.AllDefs.FirstOrDefault(predicate: x => x.defName == oldEntDef.defName);
var newTrueDef =
DefDatabase<ThingDef>.AllDefs.FirstOrDefault(predicate: x => x.defName == newEntDef.defName);
if (newEntDef.defName == HeronDefOf.HeronInvisibleDoor.defName &&
if (newEntDef.defName == HeronDefOf.HeronInvisibleDoor.defName ||
oldEntDef.defName == HeronDefOf.HeronInvisibleDoor.defName)
{
__result = true; //false, meaning, don't wipe the old thing when you spawn
__result = false; //false, meaning, don't wipe the old thing when you spawn
return;
}

if (newEntDef.defName == HeronDefOf.HeronInvisibleDoor.defName ||
if (newEntDef.defName == HeronDefOf.HeronInvisibleDoor.defName &&
oldEntDef.defName == HeronDefOf.HeronInvisibleDoor.defName)
{
__result = false; //false, meaning, don't wipe the old thing when you spawn
__result = true;
return;
}

var oldTrueDef = DefDatabase<ThingDef>.GetNamed(oldEntDef.defName);
var newTrueDef = DefDatabase<ThingDef>.GetNamed(newEntDef.defName);

if (newTrueDef != null && newTrueDef.thingClass == typeof(Building_DoorExpanded) &&
oldTrueDef != null && oldTrueDef.thingClass == typeof(Building_DoorExpanded))
{
Expand Down

0 comments on commit 65b381b

Please sign in to comment.