Skip to content

Commit

Permalink
v1.3
Browse files Browse the repository at this point in the history
- Added 1.1 support
  • Loading branch information
Jaxe-Dev committed Feb 28, 2020
1 parent 86ffa95 commit 364b27b
Show file tree
Hide file tree
Showing 10 changed files with 82 additions and 67 deletions.
11 changes: 7 additions & 4 deletions About/About.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>

<?xml version="1.0" encoding="utf-8"?>
<ModMetaData>
<packageId>Jaxe.Collapser</packageId>
<name>Collapser</name>
<author>Jaxe</author>
<targetVersion>1.0.0</targetVersion>
<description>Mod Version: 1.2\n\n\nRemove overhead mountains on collapse as long as there is non-overhead mountain roof next to the collapse.\n\nWithout this mod there is no way to remove overhead mountain, no matter how many times it collapses it does not go away. With this mod if an overhead mountain roof collapses and there is a non-overhead roof on a tile directly adjacent to it then the overhead mountain will be removed..</description>
<supportedVersions>
<li>1.0</li>
<li>1.1</li>
</supportedVersions>
<description>Mod Version: 1.3\n\n\nRemove overhead mountains on collapse as long as there is non-overhead mountain roof next to the collapse.\n\nWithout this mod there is no way to remove overhead mountain, no matter how many times it collapses it does not go away. With this mod if an overhead mountain roof collapses and there is a non-overhead roof on a tile directly adjacent to it then the overhead mountain will be removed..</description>
</ModMetaData>
8 changes: 0 additions & 8 deletions About/Manifest.xml

This file was deleted.

15 changes: 0 additions & 15 deletions About/ModSync.xml

This file was deleted.

21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2019 Jaxe

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
14 changes: 14 additions & 0 deletions LoadFolders.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<loadFolders>
<default>
<li></li>
<li>v1.1</li>
</default>
<v1.0>
<li></li>
</v1.0>
<v1.1>
<li></li>
<li>v1.1</li>
</v1.1>
</loadFolders>
14 changes: 11 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Collapser
![Mod Version](https://img.shields.io/badge/Mod_Version-1.2-blue.svg)
![RimWorld Version](https://img.shields.io/badge/Built_for_RimWorld-1.0-blue.svg)
![Harmony Version](https://img.shields.io/badge/Powered_by_Harmony-1.2.0.1-blue.svg)\
![Mod Version](https://img.shields.io/badge/Mod_Version-1.3-blue.svg)
![RimWorld Version](https://img.shields.io/badge/Built_for_RimWorld-1.1-blue.svg)
![Harmony Version](https://img.shields.io/badge/Powered_by_Harmony-2.0-blue.svg)\
![Steam Subscribers](https://img.shields.io/badge/dynamic/xml.svg?label=Steam+Subscribers&query=//table/tr[2]/td[1]&colorB=blue&url=https://steamcommunity.com/sharedfiles/filedetails/%3Fid=1499847220&suffix=+total)
![GitHub Downloads](https://img.shields.io/github/downloads/Jaxe-Dev/Collapser/total.svg?colorB=blue&label=GitHub+Downloads)

Expand All @@ -25,3 +25,11 @@ While there are other mods that enable removing overhead mountains manually like

##### NON-STEAM INSTALLATION
- **[Download the latest release](https://github.com/Jaxe-Dev/Collapser/releases/latest) and unzip it into your *RimWorld/Mods* folder.**

---

The following base methods are patched with Harmony:
```
Prefix* : Verse.RoofCollapserImmediate.DropRoofInCellPhaseTwo
```
*A prefix marked by a \* denotes that in some circumstances the original method will be bypassed*
32 changes: 12 additions & 20 deletions Source/Collapser.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,61 +4,53 @@
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{D3159CFD-253F-4FA0-8846-1B44B1C6949B}</ProjectGuid>
<ProjectGuid>{1B6D6E59-BB54-4841-AF95-645BB3A61EB8}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Collapser</RootNamespace>
<AssemblyName>Collapser</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>none</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\Assemblies\</OutputPath>
<OutputPath>..\v1.1\Assemblies\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="0Harmony, Version=1.2.0.1, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\Assemblies\0Harmony.dll</HintPath>
</Reference>
<Reference Include="Assembly-CSharp">
<HintPath>..\..\..\RimWorldWin64_Data\Managed\Assembly-CSharp.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System.Core" />
<Reference Include="UnityEngine">
<HintPath>..\..\..\RimWorldWin64_Data\Managed\UnityEngine.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System.Runtime.InteropServices.RuntimeInformation" />
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Mod.cs" />
<Compile Include="Patch.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="..\.gitignore">
<Link>-\.gitignore</Link>
</Content>
<Content Include="..\About\About.xml">
<Link>-\About\About.xml</Link>
</Content>
<Content Include="..\About\Manifest.xml">
<Link>-\About\Manifest.xml</Link>
</Content>
<Content Include="..\About\ModSync.xml">
<Link>-\About\ModSync.xml</Link>
<Content Include="..\LoadFolders.xml">
<Link>-\LoadFolders.xml</Link>
</Content>
</ItemGroup>
<ItemGroup>
<None Include="..\README.md">
<Link>-\README.md</Link>
</None>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Lib.Harmony">
<Version>2.0.0.7</Version>
</PackageReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
11 changes: 5 additions & 6 deletions Source/Collapser.sln
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26228.9
# Visual Studio Version 16
VisualStudioVersion = 16.0.29418.71
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Collapser", "Collapser.csproj", "{D3159CFD-253F-4FA0-8846-1B44B1C6949B}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Collapser", "Collapser.csproj", "{1B6D6E59-BB54-4841-AF95-645BB3A61EB8}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{D3159CFD-253F-4FA0-8846-1B44B1C6949B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D3159CFD-253F-4FA0-8846-1B44B1C6949B}.Release|Any CPU.Build.0 = Release|Any CPU
{1B6D6E59-BB54-4841-AF95-645BB3A61EB8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1B6D6E59-BB54-4841-AF95-645BB3A61EB8}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
6 changes: 3 additions & 3 deletions Source/Mod.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Harmony;
using HarmonyLib;
using Verse;

namespace Collapser
Expand All @@ -8,8 +8,8 @@ internal static class Mod
{
public const string Id = "Collapser";
public const string Name = Id;
public const string Version = "1.2";
public const string Version = "1.3";

static Mod() => HarmonyInstance.Create(Id).PatchAll();
static Mod() => new Harmony(Id).PatchAll();
}
}
17 changes: 9 additions & 8 deletions Source/Patch.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;
using System.Linq;
using Harmony;
using HarmonyLib;
using RimWorld;
using Verse;

Expand All @@ -9,18 +9,20 @@ namespace Collapser
[HarmonyPatch(typeof(RoofCollapserImmediate), "DropRoofInCellPhaseTwo")]
internal static class Patch
{
private static void Prefix(IntVec3 c, Map map)
private static bool Prefix(IntVec3 c, Map map)
{
var roofDef = map.roofGrid.RoofAt(c);
if (roofDef == null) { return; }
if (roofDef == null) { return false; }

if (roofDef.filthLeaving != null) { FilthMaker.MakeFilth(c, map, roofDef.filthLeaving); }
if (roofDef.VanishOnCollapse) { map.roofGrid.SetRoof(c, null); }
if (roofDef.filthLeaving != null) { FilthMaker.TryMakeFilth(c, map, roofDef.filthLeaving); }

if (roofDef.VanishOnCollapse) { map.roofGrid.SetRoof(c, null); }
else if (AdjacentUnroofedTiles(c, map) > 0) { map.roofGrid.SetRoof(c, null); }

var bound = CellRect.CenteredOn(c, 2);
foreach (var pawn in map.mapPawns.AllPawnsSpawned.ToArray().Where(pawn => bound.Contains(pawn.Position))) { TaleRecorder.RecordTale(TaleDefOf.CollapseDodged, pawn); }
foreach (var pawn2 in map.mapPawns.AllPawnsSpawned.Where(pawn => bound.Contains(pawn.Position))) { TaleRecorder.RecordTale(TaleDefOf.CollapseDodged, pawn2); }

return false;
}

private static int AdjacentUnroofedTiles(IntVec3 c, Map map)
Expand All @@ -43,8 +45,7 @@ private static int AdjacentUnroofedTiles(IntVec3 c, Map map)
case 3:
cell = map.cellIndices.CellToIndex(c.x - 1, c.z);
break;
default:
throw new ArgumentOutOfRangeException();
default: throw new ArgumentOutOfRangeException();
}

if ((cell < 0) || (cell >= map.cellIndices.NumGridCells)) { continue; }
Expand Down

0 comments on commit 364b27b

Please sign in to comment.