diff --git a/Defs/Buildings/Production/AlloyFusionMachine.xml b/Defs/Buildings/Production/AlloyFusionMachine.xml
index a358f51..ebcead2 100644
--- a/Defs/Buildings/Production/AlloyFusionMachine.xml
+++ b/Defs/Buildings/Production/AlloyFusionMachine.xml
@@ -34,6 +34,10 @@ See the in-game wiki for more information and how to use.
300
false
+
+ 6
+ (255,248,214,255)
+
10
diff --git a/Defs/Buildings/Production/CompositeRefiner.xml b/Defs/Buildings/Production/CompositeRefiner.xml
index cc4d9f6..f52791a 100644
--- a/Defs/Buildings/Production/CompositeRefiner.xml
+++ b/Defs/Buildings/Production/CompositeRefiner.xml
@@ -35,6 +35,10 @@ See the in-game wiki for more information and how to use.
1500
false
+
+ 5
+ (245,198,255,255)
+
7
diff --git a/Defs/Buildings/Special/M3G_UMIN.xml b/Defs/Buildings/Special/M3G_UMIN.xml
index 61e8f33..c83a79d 100644
--- a/Defs/Buildings/Special/M3G_UMIN.xml
+++ b/Defs/Buildings/Special/M3G_UMIN.xml
@@ -54,6 +54,10 @@ Firing the beam of energy creates a huge electromagnetic pulse in both the area
false
false
+
+ 9
+ (255,232,142,255)
+
R_Megumin_AA
diff --git a/Languages/English/Keyed/Keys.xml b/Languages/English/Keyed/Keys.xml
index aff76fb..9161c93 100644
--- a/Languages/English/Keyed/Keys.xml
+++ b/Languages/English/Keyed/Keys.xml
@@ -5,6 +5,8 @@
on
off
enabled
+active
+not active
turn
name
power
@@ -86,4 +88,8 @@
Change power level
Current power level: {0}% speed, uses {1} watts.\nChange in power level only takes effect once the current alloy is completed.
+
+Change power level
+Current power level: {0}%, consumes {1} canisters per day.
+
\ No newline at end of file
diff --git a/Source/AntimatterAnnihilation/AntimatterAnnihilation.csproj b/Source/AntimatterAnnihilation/AntimatterAnnihilation.csproj
index d043253..2eb271c 100644
--- a/Source/AntimatterAnnihilation/AntimatterAnnihilation.csproj
+++ b/Source/AntimatterAnnihilation/AntimatterAnnihilation.csproj
@@ -121,6 +121,7 @@
+
@@ -144,6 +145,7 @@
+
diff --git a/Source/AntimatterAnnihilation/Buildings/Building_AlloyFusionMachine.cs b/Source/AntimatterAnnihilation/Buildings/Building_AlloyFusionMachine.cs
index b14b9aa..00e0cdd 100644
--- a/Source/AntimatterAnnihilation/Buildings/Building_AlloyFusionMachine.cs
+++ b/Source/AntimatterAnnihilation/Buildings/Building_AlloyFusionMachine.cs
@@ -7,7 +7,7 @@
namespace AntimatterAnnihilation.Buildings
{
- public class Building_AlloyFusionMachine : Building_TrayPuller
+ public class Building_AlloyFusionMachine : Building_TrayPuller, IConditionalGlower
{
public const int TICKS_PER_FRAME = 3;
public const int FRAME_COUNT = 20;
@@ -43,6 +43,17 @@ private static void LoadGraphics(Building thing)
}
}
+ public CompGlower CompGlower
+ {
+ get
+ {
+ if (_compGlower == null)
+ _compGlower = this.TryGetComp();
+
+ return _compGlower;
+ }
+ }
+ private CompGlower _compGlower;
public CompPowerTrader PowerTraderComp
{
get
@@ -92,6 +103,13 @@ public int UraniumToFill
return MAX_URANIUM_STORED - storedUranium;
}
}
+ public bool ShouldBeGlowingNow
+ {
+ get
+ {
+ return IsActive;
+ }
+ }
private Graphic activeGraphic;
private bool isActiveInt = true;
@@ -146,7 +164,12 @@ public override void Tick()
UpdatePowerDraw();
// Update active/running state.
+ bool oldActive = this.IsActive;
UpdateActiveState();
+ if (oldActive != this.IsActive)
+ {
+ CompGlower?.ReceiveCompSignal("PowerTurnedOn"); // Obviously the power hasn't actually just been turned on, but it's just a way to trigger UpdateLit to be called.
+ }
// Pull resources as long as there is power.
UpdatePullResources();
diff --git a/Source/AntimatterAnnihilation/Buildings/Building_AntimatterReactor.cs b/Source/AntimatterAnnihilation/Buildings/Building_AntimatterReactor.cs
index 82651fc..7f953ff 100644
--- a/Source/AntimatterAnnihilation/Buildings/Building_AntimatterReactor.cs
+++ b/Source/AntimatterAnnihilation/Buildings/Building_AntimatterReactor.cs
@@ -68,9 +68,9 @@ public bool IsHorizontal
public float BuildingDamage = 25;
public float PawnDamage = 6.5f;
public int UpdateInterval = 20; // Every 20 ticks, so 3 times a second.
+ public Building_ReactorInjector CurrentInjector { get; private set; }
private List<(IntVec3 cell, byte weight)> avoidance = new List<(IntVec3 cell, byte weight)>();
- private Building_ReactorInjector currentInjector;
private int injectorRot;
private int tickCounter;
private long updateTick;
@@ -155,13 +155,13 @@ public void RegisterInput(Building_ReactorInjector injector, int injRot)
// Assumes that the injector is valid (correct side, aligned properly).
tickCounter = 0;
- if (currentInjector != null && currentInjector != injector)
+ if (CurrentInjector != null && CurrentInjector != injector)
{
// Two injectors?!
// TODO handle (explode?)
}
- currentInjector = injector;
+ CurrentInjector = injector;
this.injectorRot = injRot;
tickCounter = 0;
if (!IsRunning)
@@ -173,10 +173,10 @@ public void RegisterInput(Building_ReactorInjector injector, int injRot)
public void RemoveInput(Building_ReactorInjector injector)
{
- if (currentInjector != injector)
+ if (CurrentInjector != injector)
return;
- currentInjector = null;
+ CurrentInjector = null;
if (IsRunning)
{
@@ -189,14 +189,14 @@ public override void Tick()
{
base.Tick();
- if(tickCounter < TicksToShutdownWithNoInput && currentInjector != null)
+ if(tickCounter < TicksToShutdownWithNoInput && CurrentInjector != null)
tickCounter++;
- if (tickCounter == TicksToShutdownWithNoInput)
+ if (tickCounter >= TicksToShutdownWithNoInput)
{
if (IsRunning)
{
IsRunning = false;
- currentInjector = null;
+ CurrentInjector = null;
CauseRedraw();
}
}
diff --git a/Source/AntimatterAnnihilation/Buildings/Building_CompositeRefiner.cs b/Source/AntimatterAnnihilation/Buildings/Building_CompositeRefiner.cs
index f6e3c5a..241baa3 100644
--- a/Source/AntimatterAnnihilation/Buildings/Building_CompositeRefiner.cs
+++ b/Source/AntimatterAnnihilation/Buildings/Building_CompositeRefiner.cs
@@ -4,8 +4,16 @@
namespace AntimatterAnnihilation.Buildings
{
- public class Building_CompositeRefiner : Building_TrayPuller
+ public class Building_CompositeRefiner : Building_TrayPuller, IConditionalGlower
{
+ public bool ShouldBeGlowingNow
+ {
+ get
+ {
+ return GetShouldBeRunning();
+ }
+ }
+
public CompPowerTrader PowerTraderComp
{
get
@@ -16,6 +24,16 @@ public CompPowerTrader PowerTraderComp
}
}
private CompPowerTrader _powerTraderComp;
+ public CompGlower CompGlower
+ {
+ get
+ {
+ if (_compGlower == null)
+ this._compGlower = base.GetComp();
+ return _compGlower;
+ }
+ }
+ private CompGlower _compGlower;
public IntVec3 OutputPos
{
get
@@ -50,6 +68,7 @@ public int MissingAntimatter
public int ProductionTicks;
private ulong tickCount;
+ private bool lastFrameRunning;
public override void SpawnSetup(Map map, bool respawningAfterLoad)
{
@@ -91,6 +110,12 @@ public override void Tick()
}
}
+ if (lastFrameRunning != isRunning)
+ {
+ CompGlower?.ReceiveCompSignal("PowerTurnedOn"); // Obviously the power hasn't actually just been turned on, but it's just a way to trigger UpdateLit to be called.
+ }
+ lastFrameRunning = isRunning;
+
if (tickCount % 120 == 0 && PowerTraderComp.PowerOn)
{
Building_InputTray lt = null;
diff --git a/Source/AntimatterAnnihilation/Buildings/Building_Megumin.cs b/Source/AntimatterAnnihilation/Buildings/Building_Megumin.cs
index 903ba82..c03a831 100644
--- a/Source/AntimatterAnnihilation/Buildings/Building_Megumin.cs
+++ b/Source/AntimatterAnnihilation/Buildings/Building_Megumin.cs
@@ -13,7 +13,7 @@
namespace AntimatterAnnihilation.Buildings
{
- public class Building_Megumin : Building
+ public class Building_Megumin : Building, IConditionalGlower
{
[TweakValue("AntimatterAnnihilation")]
public static bool DoSolarFlare = true;
@@ -29,6 +29,13 @@ public class Building_Megumin : Building
public static float EXPLOSION_PEN = 0.7f;
public static float CHARGE_WATT_DAYS = 600 * 5; // Requires 5 fully-powered batteries to charge (semi-instantly). Otherwise it will take longer depending on power production.
+ public bool ShouldBeGlowingNow
+ {
+ get
+ {
+ return IsPoweringUp;
+ }
+ }
public CompEquippable GunComp
{
get
@@ -59,6 +66,16 @@ public CompRefuelableConditional FuelComp
}
}
private CompRefuelableConditional _compRefuelable;
+ public CompGlower CompGlower
+ {
+ get
+ {
+ if (_compGlower == null)
+ this._compGlower = base.GetComp();
+ return _compGlower;
+ }
+ }
+ private CompGlower _compGlower;
public Verb AttackVerb
{
get
@@ -232,6 +249,9 @@ private void StartPowerUpSequence()
// Do particle effects.
chargeEffect?.Play(true);
+
+ // Enable glow start.
+ CompGlower?.ReceiveCompSignal("PowerTurnedOn");
}
private void StartRealAttack()
@@ -280,6 +300,9 @@ private void StopFireLaser()
{
beam.IsActive = false;
soundSustainer?.End();
+
+ // Turn off glow.
+ CompGlower?.ReceiveCompSignal("PowerTurnedOn");
}
private void DoEasterEgg()
diff --git a/Source/AntimatterAnnihilation/Buildings/Building_PowerConverter.cs b/Source/AntimatterAnnihilation/Buildings/Building_PowerConverter.cs
index 7dadc1f..3719bce 100644
--- a/Source/AntimatterAnnihilation/Buildings/Building_PowerConverter.cs
+++ b/Source/AntimatterAnnihilation/Buildings/Building_PowerConverter.cs
@@ -6,6 +6,19 @@ namespace AntimatterAnnihilation.Buildings
[StaticConstructorOnStartup]
public class Building_PowerConverter : Building
{
+ public static float BasePowerOutput = 30000;
+ public static float PowerOutputMulti { get; set; } = 1f;
+
+ private float PowerOutput
+ {
+ get
+ {
+ float reactorMulti = this.CurrentReactor?.CurrentInjector?.PowerOutputMultiplier ?? 1f;
+
+ return BasePowerOutput * PowerOutputMulti * reactorMulti;
+ }
+ }
+
private static Graphic normal, running;
private const int MAX_TICKS_SINCE_INPUT = 30;
@@ -38,34 +51,43 @@ public bool HasInput
return ticksSinceHasInput < MAX_TICKS_SINCE_INPUT;
}
}
+ public Building_AntimatterReactor CurrentReactor { get; private set; }
private int ticksSinceHasInput;
public override void Tick()
{
+ if (CurrentReactor != null && CurrentReactor.Destroyed)
+ CurrentReactor = null;
+
if (ticksSinceHasInput < MAX_TICKS_SINCE_INPUT)
{
ticksSinceHasInput++;
}
- else if (ticksSinceHasInput != 69420)
+ else
{
- ticksSinceHasInput = 69420;
- CauseRedraw();
+ CurrentReactor = null;
+ if (ticksSinceHasInput != 69420)
+ {
+ ticksSinceHasInput = 69420;
+ CauseRedraw();
+ }
}
var trader = PowerComp as CompPowerTrader;
- trader.PowerOutput = HasInput ? 30000 : 0;
+ trader.PowerOutput = HasInput ? (PowerOutput) : 0;
base.Tick();
}
public void GiveInput(Building_AntimatterReactor r)
{
+ ticksSinceHasInput = 0;
+ CurrentReactor = r;
if (!HasInput)
{
CauseRedraw();
}
- ticksSinceHasInput = 0;
}
public void CauseRedraw(Map map = null)
diff --git a/Source/AntimatterAnnihilation/Buildings/Building_ReactorInjector.cs b/Source/AntimatterAnnihilation/Buildings/Building_ReactorInjector.cs
index 7f12430..2668c7f 100644
--- a/Source/AntimatterAnnihilation/Buildings/Building_ReactorInjector.cs
+++ b/Source/AntimatterAnnihilation/Buildings/Building_ReactorInjector.cs
@@ -6,6 +6,7 @@
using System.Collections.Generic;
using UnityEngine;
using Verse;
+using Verse.Noise;
namespace AntimatterAnnihilation.Buildings
{
@@ -76,6 +77,43 @@ public override Graphic Graphic
}
public EnergyBeam Beam { get; private set; }
public IntVec3 BeamExploreDirection { get; private set; }
+ public byte PowerMode;
+
+ public float FuelBurnRate
+ {
+ get
+ {
+ switch (PowerMode)
+ {
+ case 0:
+ return 1.5f;
+ case 1:
+ return 2f;
+ case 2:
+ return 4f;
+ default:
+ return 1.5f;
+ }
+ }
+ }
+
+ public float PowerOutputMultiplier
+ {
+ get
+ {
+ switch (PowerMode)
+ {
+ case 0:
+ return 1f; // 30 KW, 1.5 fuel per day.
+ case 1:
+ return 1.5f; // 45 KW, 2 fuel per day (more efficient, but uses all the fuel 1 accelerator produces so no extra).
+ case 2:
+ return 4f; // 120 KW, 4 fuel per day (the most efficient, but requires at least 2 accelerators).
+ default:
+ return 1f;
+ }
+ }
+ }
public int MaxBeamLength = 10;
@@ -149,6 +187,7 @@ public override void Tick()
if (Beam == null)
return;
+ FuelComp.CustomFuelBurnRate = FuelBurnRate;
Beam.BeamVisible = IsRunning;
//CauseRedraw();
@@ -164,6 +203,39 @@ public override void Tick()
}
}
+ public override void ExposeData()
+ {
+ base.ExposeData();
+
+ Scribe_Values.Look(ref PowerMode, "injectorPowerMode");
+ }
+
+ public override IEnumerable GetGizmos()
+ {
+ foreach (var g in base.GetGizmos())
+ {
+ yield return g;
+ }
+
+ var cmd2 = new Command_Action();
+ cmd2.defaultLabel = "AA.RIPowerLevel".Translate();
+ cmd2.defaultDesc = "AA.RIPowerLevelDesc".Translate($"{PowerOutputMultiplier*100:F0}", $"{FuelBurnRate:F1}");
+ cmd2.icon = PowerMode == 2 ? Content.PowerLevelHigh : PowerMode == 1 ? Content.PowerLevelMedium : Content.PowerLevelLow;
+ cmd2.action = () =>
+ {
+ PowerMode++;
+ if (PowerMode >= 3)
+ PowerMode = 0;
+ };
+
+ yield return cmd2;
+ }
+
+ public override string GetInspectString()
+ {
+ return base.GetInspectString() + $"\n{"AA.RIPowerLevelDesc".Translate($"{PowerOutputMultiplier * 100:F0}", $"{FuelBurnRate:F1}")}";
+ }
+
private Vector3 GetOffset(out float angle)
{
var rot = base.Rotation;
@@ -197,7 +269,7 @@ private Vector3 GetOffset(out float angle)
}
private List tempThings = new List();
- public float UpdateDamageAndInjection(float maxDst) // The action is a hacky workaround to not being able to do 'out int realDst'
+ public float UpdateDamageAndInjection(float maxDst)
{
avoidance.Clear();
diff --git a/Source/AntimatterAnnihilation/Patches/Patch_CompGlower.cs b/Source/AntimatterAnnihilation/Patches/Patch_CompGlower.cs
new file mode 100644
index 0000000..6b02d68
--- /dev/null
+++ b/Source/AntimatterAnnihilation/Patches/Patch_CompGlower.cs
@@ -0,0 +1,23 @@
+using AntimatterAnnihilation.Utils;
+using HarmonyLib;
+using Verse;
+
+namespace AntimatterAnnihilation.Patches
+{
+
+ [HarmonyPatch(typeof(CompGlower), "get_ShouldBeLitNow")]
+ static class Patch_CompGlower
+ {
+ static bool Prefix(CompGlower __instance, ref bool __result)
+ {
+ var ins = __instance;
+ if (ins.parent is IConditionalGlower c)
+ {
+ __result = c.ShouldBeGlowingNow;
+ return false;
+ }
+
+ return true;
+ }
+ }
+}
diff --git a/Source/AntimatterAnnihilation/ThingComps/CompRefuelableConditional.cs b/Source/AntimatterAnnihilation/ThingComps/CompRefuelableConditional.cs
index ae9a216..a9ea4a9 100644
--- a/Source/AntimatterAnnihilation/ThingComps/CompRefuelableConditional.cs
+++ b/Source/AntimatterAnnihilation/ThingComps/CompRefuelableConditional.cs
@@ -18,6 +18,15 @@ public class CompRefuelableConditional : CompRefuelable
public event Action OnRunOutOfFuel;
public bool IsConditionPassed { get; private set; }
+ public float CustomFuelBurnRate { get; set; } = 0f;
+
+ public float RealFuelConsumeRate
+ {
+ get
+ {
+ return CustomFuelBurnRate > 0f ? CustomFuelBurnRate : Props.fuelConsumptionRate;
+ }
+ }
public override void CompTick()
{
@@ -27,7 +36,14 @@ public override void CompTick()
if (consume)
{
// Base tick consumes fuel using default conditions (must be switched on).
- base.CompTick();
+ if (CustomFuelBurnRate <= 0f)
+ {
+ base.CompTick();
+ }
+ else
+ {
+ base.ConsumeFuel(CustomFuelBurnRate / 60000f);
+ }
}
}
@@ -54,5 +70,21 @@ public void SetFuelLevel(float fuelLevel)
fInfo.SetValue(this, fuelLevel);
}
+
+ public override string CompInspectStringExtra()
+ {
+ string str = Props.FuelLabel + ": " + Fuel.ToStringDecimalIfSmall() + " / " + Props.fuelCapacity.ToStringDecimalIfSmall();
+ if (!Props.consumeFuelOnlyWhenUsed && HasFuel)
+ {
+ float daysRemaining = Fuel / RealFuelConsumeRate;
+ int ticksRemaining = (int)(daysRemaining * 60000);
+ str = str + " (" + ticksRemaining.ToStringTicksToPeriod() + ")";
+ }
+ if (!HasFuel && !Props.outOfFuelMessage.NullOrEmpty())
+ str += $"\n{Props.outOfFuelMessage} ({GetFuelCountToFullyRefuel()}x {Props.fuelFilter.AnyAllowedDef.label})";
+ if (Props.targetFuelLevelConfigurable)
+ str = str + ("\n" + "ConfiguredTargetFuelLevel".Translate(TargetFuelLevel.ToStringDecimalIfSmall()));
+ return str;
+ }
}
}
\ No newline at end of file
diff --git a/Source/AntimatterAnnihilation/Utils/IConditionalGlower.cs b/Source/AntimatterAnnihilation/Utils/IConditionalGlower.cs
new file mode 100644
index 0000000..ffc0024
--- /dev/null
+++ b/Source/AntimatterAnnihilation/Utils/IConditionalGlower.cs
@@ -0,0 +1,7 @@
+namespace AntimatterAnnihilation.Utils
+{
+ public interface IConditionalGlower
+ {
+ bool ShouldBeGlowingNow { get; }
+ }
+}
diff --git a/Source/Content/Models/Reactor.blend b/Source/Content/Models/Reactor.blend
index da41816..36ebd1d 100644
Binary files a/Source/Content/Models/Reactor.blend and b/Source/Content/Models/Reactor.blend differ
diff --git a/Source/Content/Pdn/DSR.pdn b/Source/Content/Pdn/DSR.pdn
index e8cb191..6e2d5d7 100644
Binary files a/Source/Content/Pdn/DSR.pdn and b/Source/Content/Pdn/DSR.pdn differ
diff --git a/Source/Content/Pdn/Reactor East.pdn b/Source/Content/Pdn/Reactor East.pdn
index a78c4a1..3910ed4 100644
--- a/Source/Content/Pdn/Reactor East.pdn
+++ b/Source/Content/Pdn/Reactor East.pdn
@@ -1,2043 +1,2152 @@
-PDN3>