Skip to content

Commit

Permalink
v2.9.3 prevents zombie raids in space
Browse files Browse the repository at this point in the history
  • Loading branch information
pardeike committed Feb 16, 2022
1 parent 6550d9f commit f11d522
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 10 deletions.
Binary file modified 1.3/Assemblies/ZombieLand.dll
Binary file not shown.
2 changes: 1 addition & 1 deletion About/Manifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Manifest>
<identifier>net.pardeike.rimworld.mod.zombieland</identifier>
<version>2.9.2.0</version>
<version>2.9.3.0</version>
<targetVersions>
<li>1.0.0</li>
<li>1.1.0</li>
Expand Down
12 changes: 7 additions & 5 deletions Source/SoSTools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ public class SoSTools
{
public class Floater
{
public static readonly int totalCount = 50;
public const int totalCount = 50;
const float minSize = 0.25f;
const float maxSize = 3f;

public IntVec3 mapSize;
public Material material;
Expand All @@ -40,11 +42,11 @@ public void Update(int i, int count)
if (scale == 0 || position.x < -4 || position.z < -4 || position.x > mapSize.x + 4 || position.z > mapSize.z + 4)
{
var f = GenMath.LerpDoubleClamped(0, count - 1, 0, 1, i);
scale = (1 + Mathf.Pow(f, Mathf.Pow(f + 1.4f, 4)) * 3) / 4;
speed = GenMath.LerpDoubleClamped(0.25f, 1, 0.1f, 1, scale);
var yAltitute = (f >= 0.985f ? 20f : -0.5f) + i / 1000f;
scale = minSize + Mathf.Pow(f, Mathf.Pow(f + 1.4f, 4)) * (maxSize - minSize);
speed = 2 * Mathf.Pow(GenMath.LerpDoubleClamped(minSize, maxSize, 0.2f, 1, scale), 2);
var yAltitute = (f >= 0.8f ? 20f : -0.5f) + i / 1000f;
angle = Rand.Range(0f, 359f);
rotation = Rand.Range(-0.4f, 0.4f);
rotation = (Rand.Chance(0.2f) ? 3f : 1f) * Rand.Range(-0.4f, 0.4f);
switch (Rand.Int % 4)
{
case 0: // bottom
Expand Down
7 changes: 7 additions & 0 deletions Source/Tools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,13 @@ public static bool IsValidSpawnLocation(IntVec3 cell, Map map)
{
if (cell.Standable(map) == false || cell.Fogged(map)) return false;

if (map.IsSpace())
{
var room = cell.GetRoom(map);
if (room == null || room.OpenRoofCount > 0 || room.TouchesMapEdge)
return false;
}

var edifice = cell.GetEdifice(map);
if (edifice != null && edifice is Building_Door door)
if (door.Open == false)
Expand Down
12 changes: 9 additions & 3 deletions Source/ZombieIncidents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ public static bool ZombiesForNewIncident(TickManager tickManager)
tickManager.incidentInfo.parameters = new IncidentParameters();
var parameters = tickManager.incidentInfo.parameters;

if (tickManager.map.IsSpace())
{
parameters.skipReason = "no zombie events in space";
return false;
}

var currentMax = Mathf.FloorToInt(tickManager.GetMaxZombieCount() * ZombieWeather.GetThreatLevel(tickManager.map));

parameters.capableColonists = Tools.CapableColonists(tickManager.map);
Expand Down Expand Up @@ -250,14 +256,14 @@ static IEnumerator SpawnEventProcess(Map map, int incidentSize, IntVec3 spot, Pr

public static IntVec3 GetValidSpot(Map map, IntVec3 spot, Predicate<IntVec3> cellValidator)
{
if (ZombieSettings.Values.spawnHowType == SpawnHowType.FromTheEdges && map.IsSpace())
return IntVec3.Invalid;
var allOverTheMap = ZombieSettings.Values.spawnHowType == SpawnHowType.AllOverTheMap;
var spotValidator = SpotValidator(cellValidator);

for (var counter = 1; counter <= 10; counter++)
{
if (spot.IsValid)
break;

var allOverTheMap = ZombieSettings.Values.spawnHowType == SpawnHowType.AllOverTheMap;
spot = Tools.RandomSpawnCell(map, allOverTheMap == false, spotValidator);
}
return spot;
Expand Down
2 changes: 1 addition & 1 deletion Source/ZombieLand.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<OutputPath>..\1.3\Assemblies\</OutputPath>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<Version>2.9.2.0</Version>
<Version>2.9.3.0</Version>
<Copyright>Copyright © 2017</Copyright>
</PropertyGroup>

Expand Down

0 comments on commit f11d522

Please sign in to comment.