Skip to content

Commit

Permalink
Merge branch 'Develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Epicguru committed Sep 24, 2020
2 parents 887d8ef + 8457556 commit 395f3ae
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 24 deletions.
4 changes: 4 additions & 0 deletions Languages/English/Keyed/Keys.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@
<AA.FuelConsumeRate>Fuel consumption multiplier: {0}%</AA.FuelConsumeRate>
<AA.InjectorVolume>Injector hum volume: {0}%</AA.InjectorVolume>
<AA.EnableEasterEggs>Enable easter eggs:</AA.EnableEasterEggs>
<AA.EnableCustomPathfinding>Enable custom pathfinding:</AA.EnableCustomPathfinding>
<AA.BeamsDoDamage>Beams do damage:</AA.BeamsDoDamage>
<AA.SettingsPerformance>Performance</AA.SettingsPerformance>
<AA.BeamWarning>It is highly recommended to disable beam damage if you disable custom pathfinding. Otherwise pawns will walk through deadly laser beams!</AA.BeamWarning>

<!-- PowerNet Console -->
<AA.OpenConsole>Open console</AA.OpenConsole>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,17 +272,20 @@ public float UpdateOutputBeam(float maxDst)
avoidance.Add((posUpper, AI_AvoidGrid.WEIGHT_ENERGY_BEAM));

bool done = false;
var pawn = Map.thingGrid.ThingAt(posLower, ThingCategory.Pawn);
if (pawn != null && !(pawn as Pawn).Downed) // Don't damage downed pawns, because it's too punishing.
if (Settings.DoBeamDamage)
{
done = true;
tempThings.Add(pawn);
}
var pawn2 = Map.thingGrid.ThingAt(posUpper, ThingCategory.Pawn);
if (pawn2 != null && !(pawn2 as Pawn).Downed)
{
done = true;
tempThings.Add(pawn2);
var pawn = Map.thingGrid.ThingAt(posLower, ThingCategory.Pawn);
if (pawn != null && !(pawn as Pawn).Downed) // Don't damage downed pawns, because it's too punishing.
{
done = true;
tempThings.Add(pawn);
}
var pawn2 = Map.thingGrid.ThingAt(posUpper, ThingCategory.Pawn);
if (pawn2 != null && !(pawn2 as Pawn).Downed)
{
done = true;
tempThings.Add(pawn2);
}
}

if (done)
Expand Down Expand Up @@ -315,6 +318,9 @@ public float UpdateOutputBeam(float maxDst)
break;
}

if (!Settings.DoBeamDamage)
return i;

foreach (var thing in tempThings)
{
if (thing.def.defName == "AntimatterReactorPowerConverter_AA")
Expand Down
3 changes: 1 addition & 2 deletions Source/AntimatterAnnihilation/Buildings/Building_Megumin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
using AntimatterAnnihilation.ThingComps;
using AntimatterAnnihilation.Utils;
using RimWorld;
using RimWorld.Planet;
using System;
using System.Collections.Generic;
using System.Linq;
using RimWorld.Planet;
using UnityEngine;
using Verse;
using Verse.Sound;
Expand Down
26 changes: 15 additions & 11 deletions Source/AntimatterAnnihilation/Buildings/Building_ReactorInjector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -339,17 +339,20 @@ public float UpdateDamageAndInjection(float maxDst)
avoidance.Add((posUpper, AI_AvoidGrid.WEIGHT_INJECTOR_BEAM));

bool done = false;
var pawn = Map.thingGrid.ThingAt(posLower, ThingCategory.Pawn);
if (pawn != null && !(pawn as Pawn).Downed) // Don't damage downed pawns, because it's too punishing.
if (Settings.DoBeamDamage)
{
done = true;
tempThings.Add(pawn);
}
var pawn2 = Map.thingGrid.ThingAt(posUpper, ThingCategory.Pawn);
if (pawn2 != null && !(pawn2 as Pawn).Downed)
{
done = true;
tempThings.Add(pawn2);
var pawn = Map.thingGrid.ThingAt(posLower, ThingCategory.Pawn);
if (pawn != null && !(pawn as Pawn).Downed) // Don't damage downed pawns, because it's too punishing.
{
done = true;
tempThings.Add(pawn);
}
var pawn2 = Map.thingGrid.ThingAt(posUpper, ThingCategory.Pawn);
if (pawn2 != null && !(pawn2 as Pawn).Downed)
{
done = true;
tempThings.Add(pawn2);
}
}

if (done)
Expand Down Expand Up @@ -427,7 +430,8 @@ public float UpdateDamageAndInjection(float maxDst)
if (thingIsReactor && isInLine)
damage *= 0.05f; // Do much less damage to reactor if lined up with input/output, for situations where the power is cut to the reactor and AT field cannot be formed.

thing.TakeDamage(new DamageInfo(AADefOf.Annihilate_AA, damage, 15, instigator: this));
if(Settings.DoBeamDamage)
thing.TakeDamage(new DamageInfo(AADefOf.Annihilate_AA, damage, 15, instigator: this));
}

return i;
Expand Down
3 changes: 2 additions & 1 deletion Source/AntimatterAnnihilation/Patches/Patch_AvoidGrid.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ static class Patch_AvoidGrid
[HarmonyPriority(Priority.Last)]
static void Postfix(Pawn p, ref ByteGrid __result)
{
AI_AvoidGrid.DoAvoidGrid(p, ref __result);
if(Settings.EnableCustomPathfinding)
AI_AvoidGrid.DoAvoidGrid(p, ref __result);
}
}
}
12 changes: 12 additions & 0 deletions Source/AntimatterAnnihilation/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ public class Settings : ModSettings
public static float FuelConsumeRate = 1f;
public static float InjectorHumVolume = 1f;
public static bool EnableEasterEggs = true;
public static bool EnableCustomPathfinding = true;
public static bool DoBeamDamage = true;

public override void ExposeData()
{
Expand All @@ -35,6 +37,16 @@ public static void DoWindow(Rect window)
Widgets.CheckboxLabeled(new Rect(window.x, window.y, 350, 32), "AA.EnableEasterEggs".Translate(), ref EnableEasterEggs, placeCheckboxNearText: true);
MoveDown(32 + 5f);

Widgets.CheckboxLabeled(new Rect(window.x, window.y, 350, 32), "AA.BeamsDoDamage".Translate(), ref DoBeamDamage, placeCheckboxNearText: true);
MoveDown(32 + 5f);

Widgets.CheckboxLabeled(new Rect(window.x, window.y, 350, 32), "AA.EnableCustomPathfinding".Translate(), ref EnableCustomPathfinding, placeCheckboxNearText: true);
MoveDown(32 + 5f);
if (DoBeamDamage && !EnableCustomPathfinding)
{
DoLabel("<color=red>" + "AA.BeamWarning".Translate() + "</color>");
}

void DoLabel(string label)
{
const float HEIGHT = 32;
Expand Down

0 comments on commit 395f3ae

Please sign in to comment.