Skip to content

Commit

Permalink
Added option to disable gas path calculations
Browse files Browse the repository at this point in the history
  • Loading branch information
juanosarg committed Sep 16, 2021
1 parent 614e6cb commit 571a5d5
Show file tree
Hide file tree
Showing 12 changed files with 150 additions and 45 deletions.
Binary file modified 1.3/Assemblies/VanillaPowerExpanded.dll
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -16,52 +16,60 @@ public static void Postfix(IntVec3 c, bool perceivedStatic, ref int __result, Ma
{
// add extra pathing cost for tiles on or close to toxic or flammable gas.
// this is analogous to the vanilla code for fire.
if (perceivedStatic && Gas_Spreading.AnyGases)
{
//var before = __result;
//
var comp = MapComponent_GasDanger.GetCachedComp(___map);
var gases = comp.GasesAt(c);

foreach (var gas in gases)
if (VanillaPowerExpanded.VanillaPowerExpanded_Mod.settings.disableGasPathCalculations)
{
if (perceivedStatic && Gas_Spreading.AnyGases)
{
if (gas.Flammable)
{
__result += (int)Mathf.Clamp01(gas.Density) * (gas.Position == c ? 1000 : 150);
}
//var before = __result;
//
var comp = MapComponent_GasDanger.GetCachedComp(___map);
var gases = comp.GasesAt(c);

if (gas.Toxic)
foreach (var gas in gases)
{
__result += (int)Mathf.Clamp01(gas.Density) * (gas.Position == c ? 500 : 75);
if (gas.Flammable)
{
__result += (int)Mathf.Clamp01(gas.Density) * (gas.Position == c ? 1000 : 150);
}

if (gas.Toxic)
{
__result += (int)Mathf.Clamp01(gas.Density) * (gas.Position == c ? 500 : 75);
}
}

//
//foreach (var offset in GenAdj.AdjacentCellsAndInside)
//{
// var cell = c + offset;
// var center = cell.Equals(c);
// if (!cell.InBounds(___map))
// {
// continue;
// }
//
// var gases = comp.GasesAt(c + offset);
// // var gases = ___map.thingGrid.ThingsListAtFast(c + offset).OfType<Gas_Spreading>();
// foreach (var gas in gases)
// {
// if (gas.Flammable)
// {
// __result += Mathf.CeilToInt(Mathf.Clamp01(gas.Density) * (center ? 1000 : 150));
// }
//
// if (gas.Toxic)
// {
// __result += Mathf.CeilToInt(Mathf.Clamp01(gas.Density) * (center ? 500 : 75));
// }
// }
//}
}

//
//foreach (var offset in GenAdj.AdjacentCellsAndInside)
//{
// var cell = c + offset;
// var center = cell.Equals(c);
// if (!cell.InBounds(___map))
// {
// continue;
// }
//
// var gases = comp.GasesAt(c + offset);
// // var gases = ___map.thingGrid.ThingsListAtFast(c + offset).OfType<Gas_Spreading>();
// foreach (var gas in gases)
// {
// if (gas.Flammable)
// {
// __result += Mathf.CeilToInt(Mathf.Clamp01(gas.Density) * (center ? 1000 : 150));
// }
//
// if (gas.Toxic)
// {
// __result += Mathf.CeilToInt(Mathf.Clamp01(gas.Density) * (center ? 500 : 75));
// }
// }
//}

}


}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,16 @@ public static class Region
{
public static void Postfix(ref Danger __result, Verse.Region __instance)
{
if (Gas_Spreading.AnyGases)
{
var danger = MapComponent_GasDanger.GetCachedComp(__instance.Map)?.DangerIn(__instance) ?? Danger.None;
// result is highest level of danger.
__result = danger > __result ? danger : __result;
if (VanillaPowerExpanded.VanillaPowerExpanded_Mod.settings.disableGasPathCalculations) {
if (Gas_Spreading.AnyGases)
{
var danger = MapComponent_GasDanger.GetCachedComp(__instance.Map)?.DangerIn(__instance) ?? Danger.None;
// result is highest level of danger.
__result = danger > __result ? danger : __result;
}

}

}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
using RimWorld;
using UnityEngine;
using Verse;
using System.Collections.Generic;
using System.Linq;
using System;


namespace VanillaPowerExpanded
{


public class VanillaPowerExpanded_Settings : ModSettings

{


public bool disableGasPathCalculations = false;




public override void ExposeData()
{
base.ExposeData();

Scribe_Values.Look(ref disableGasPathCalculations, "disableGasPathCalculations", false, true);


}

public void DoWindowContents(Rect inRect)
{
Listing_Standard ls = new Listing_Standard();


ls.Begin(inRect);
ls.Gap(10f);


ls.CheckboxLabeled("VPE_DisableGasPathCalculations".Translate(), ref disableGasPathCalculations, null);



ls.End();
}



}










}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using RimWorld;
using UnityEngine;
using Verse;
using System.Collections.Generic;
using System.Linq;

namespace VanillaPowerExpanded
{



public class VanillaPowerExpanded_Mod : Mod
{
public static VanillaPowerExpanded_Settings settings;

public VanillaPowerExpanded_Mod(ModContentPack content) : base(content)
{
settings = GetSettings<VanillaPowerExpanded_Settings>();
}
public override string SettingsCategory() => "Vanilla Furniture Expanded - Power";

public override void DoSettingsWindowContents(Rect inRect)
{
settings.DoWindowContents(inRect);
}
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,8 @@
<Compile Include="GasNet\Patches\OverlayDrawer.cs" />
<Compile Include="Lightning\CompLightningPowerPlant.cs" />
<Compile Include="Lightning\WeatherEvent_CustomLightningStrike.cs" />
<Compile Include="Options\VanillaPowerExpanded_Settings.cs" />
<Compile Include="Options\VanillaPowerExpanded_SettingsController.cs" />
<Compile Include="SpecialSpawns\MapComponentExtender.cs" />
<Compile Include="BillInheritance\NonPublicFields.cs" />
<Compile Include="Nuclear\CompPlantHarmRadiusIfBroken.cs" />
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2a5c4ad19f68fd7598a6ff5444d201a9d2957603
5c8f6730d80a1ff3ea5a2b715c461efadc47cf4b
Binary file not shown.
Binary file not shown.
3 changes: 2 additions & 1 deletion Languages/English/Keyed/Misc_Gameplay.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<VPE_MustPlaceAdjacentToPipe>Gas powered buildings must be placed adjacent to gas pipes, not on top</VPE_MustPlaceAdjacentToPipe>
<VPE_DeconstructGasPipes>Deconstruct Gas Network</VPE_DeconstructGasPipes>
<VPE_DeconstructGasPipesDesc>Deconstruct only gas pipes and subterranean gas pipes</VPE_DeconstructGasPipesDesc>
<VPE_DisableGasPathCalculations>Disable Helixien gas path calculations (use to reduce lag)</VPE_DisableGasPathCalculations>


<Fluffy.GasNetwork.GasNetworkInspectString>Gas excess (stored) in network: {0} ({1})</Fluffy.GasNetwork.GasNetworkInspectString>
Expand Down Expand Up @@ -58,7 +59,7 @@

<!-- Lightning Generator -->
<VPE_LightningTime>Lightning energy stored for: </VPE_LightningTime>
<VPE_Producing>Producing {0} W of electricity</VPE_Producing>

<VPE_NotLightningProducing>Lightning electricity depleted. Looks like you'll have to wait for the next thunderstorm.</VPE_NotLightningProducing>

<!-- Gas pipe kaboom -->
Expand Down

0 comments on commit 571a5d5

Please sign in to comment.