Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaxe-Wilde committed Aug 26, 2018
0 parents commit b570254
Show file tree
Hide file tree
Showing 9 changed files with 171 additions and 0 deletions.
9 changes: 9 additions & 0 deletions About/About.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>

<ModMetaData>
<name>Collapser</name>
<author>Jaxe</author>
<targetVersion>0.19.0</targetVersion>
<description>Collapser is a simple mod that alters how a thick overhead mountain roof will collapse.\n\nIf an overhead mountain roof collapses and there is a non-thick roof on a tile directly adjacent to the north, south, east or west of it then the thick roof will be removed.\nThis does not particularly make it easy to carve out open areas inside mountains but the main purpose of this mod is to deal with randomly isolated overhead mountain tiles.</description>
<url>https://ludeon.com/forums/index.php?topic=43486.0</url>
</ModMetaData>
15 changes: 15 additions & 0 deletions About/ModSync.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>

<ModSyncNinjaData>
<ID>59f538ed-f86d-4506-a4a5-7e9faaa37509</ID>
<ModName>Collapser</ModName>
<Version>v1.0</Version>
<SaveBreaking>False</SaveBreaking>
<Host name="Github">
<Owner>Jaxe-Dev</Owner>
<Project>Collapser</Project>
<AboutDir>About</AboutDir>
<DownloadFrom>ModSyncReleases</DownloadFrom>
<Branch>master</Branch>
</Host>
</ModSyncNinjaData>
Binary file added Assemblies/0Harmony.dll
Binary file not shown.
Binary file added Assemblies/Collapser.dll
Binary file not shown.
54 changes: 54 additions & 0 deletions Source/Collapser.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{D3159CFD-253F-4FA0-8846-1B44B1C6949B}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Collapser</RootNamespace>
<AssemblyName>Collapser</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>false</DebugSymbols>
<DebugType>none</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\Assemblies\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>none</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\Assemblies\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</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>
</ItemGroup>
<ItemGroup>
<Compile Include="Patch.cs" />
<Compile Include="Main.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
22 changes: 22 additions & 0 deletions Source/Collapser.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26228.9
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Collapser", "Collapser.csproj", "{D3159CFD-253F-4FA0-8846-1B44B1C6949B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{D3159CFD-253F-4FA0-8846-1B44B1C6949B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D3159CFD-253F-4FA0-8846-1B44B1C6949B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{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
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
11 changes: 11 additions & 0 deletions Source/Main.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using Harmony;
using Verse;

namespace Collapser
{
[StaticConstructorOnStartup]
internal static class Main
{
static Main() => HarmonyInstance.Create("Collapser").PatchAll();
}
}
53 changes: 53 additions & 0 deletions Source/Patch.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
using System;
using System.Linq;
using Harmony;
using RimWorld;
using Verse;

namespace Collapser
{
[HarmonyPatch(typeof(RoofCollapserImmediate), "DropRoofInCellPhaseTwo")]
internal static class Patch
{
private static void Prefix(IntVec3 c, Map map)
{
var roofDef = map.roofGrid.RoofAt(c);
if (roofDef == null) { return; }
if (roofDef.filthLeaving != null) { FilthMaker.MakeFilth(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 pawn2 in from pawn in map.mapPawns.AllPawnsSpawned where bound.Contains(pawn.Position) select pawn) { TaleRecorder.RecordTale(TaleDefOf.CollapseDodged, pawn2); }
}

private static int AdjacentUnroofedTiles(IntVec3 c, Map map)
{
var adjacent = 0;
for (var side = 0; side < 3; side++)
{
RoofDef roof;
switch (side)
{
case 0:
roof = map.roofGrid.RoofAt(c.x, c.z - 1);
break;
case 1:
roof = map.roofGrid.RoofAt(c.x + 1, c.z);
break;
case 2:
roof = map.roofGrid.RoofAt(c.x, c.z + 1);
break;
case 3:
roof = map.roofGrid.RoofAt(c.x - 1, c.z);
break;
default:
throw new ArgumentOutOfRangeException();
}

if (roof == null) { adjacent++; }
}

return adjacent;
}
}
}
7 changes: 7 additions & 0 deletions Source/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
using System.Reflection;

[assembly: AssemblyTitle("Collapser")]
[assembly: AssemblyProduct("Collapser")]
[assembly: AssemblyCopyright("© Jaxe")]
[assembly: AssemblyVersion("1.0")]
[assembly: AssemblyFileVersion("1.0")]

0 comments on commit b570254

Please sign in to comment.