forked from asquared31415/ONI-mods
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f5a6369
commit 2decf8e
Showing
5 changed files
with
131 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using HarmonyLib; | ||
using JetBrains.Annotations; | ||
using KMod; | ||
using UnityEngine; | ||
|
||
namespace GermThing; | ||
|
||
[UsedImplicitly] | ||
public class GermThing : UserMod2 | ||
{ | ||
} | ||
|
||
public class GermOverlayMode : OverlayModes.Mode | ||
{ | ||
public static HashedString Id = "asquared31415_" + nameof(GermOverlayMode); | ||
|
||
public override HashedString ViewMode() | ||
{ | ||
return Id; | ||
} | ||
|
||
public override string GetSoundName() | ||
{ | ||
return "Decor"; | ||
} | ||
} | ||
|
||
// The overlay code | ||
[HarmonyPatch(typeof(SimDebugView), "OnPrefabInit")] | ||
public static class SimDebugView_OnPrefabInit_Patch | ||
{ | ||
[UsedImplicitly] | ||
public static void Postfix(Dictionary<HashedString, Func<SimDebugView, int, Color>> ___getColourFuncs) | ||
{ | ||
___getColourFuncs.Add( | ||
GermOverlayMode.Id, | ||
(view, cell) => | ||
{ | ||
var color = (Color) AccessTools.Method(typeof(SimDebugView), "GetDiseaseColour") | ||
.Invoke(null, new object[] { view, cell }); | ||
color.a = (Grid.DiseaseCount[cell] <= 0) || (Grid.DiseaseIdx[cell] == byte.MaxValue) ? 0 : 1; | ||
return color; | ||
} | ||
); | ||
} | ||
} | ||
|
||
// Register in the overlay | ||
[HarmonyPatch(typeof(OverlayMenu), "InitializeToggles")] | ||
public static class OverlayMenu_InitializeToggles_Patch | ||
{ | ||
[UsedImplicitly] | ||
public static void Postfix(List<KIconToggleMenu.ToggleInfo> ___overlayToggleInfos) | ||
{ | ||
var constructor = AccessTools.Constructor( | ||
AccessTools.Inner(typeof(OverlayMenu), "OverlayToggleInfo"), | ||
new[] | ||
{ | ||
typeof(string), | ||
typeof(string), | ||
typeof(HashedString), | ||
typeof(string), | ||
typeof(Action), | ||
typeof(string), | ||
typeof(string), | ||
} | ||
); | ||
var _ = Action.NumActions.ToString(); | ||
|
||
var obj = constructor.Invoke( | ||
new object[] | ||
{ | ||
"Germ Overlay", | ||
"overlay_disease", | ||
GermOverlayMode.Id, | ||
"", | ||
Action.NumActions, | ||
"Displays germs betterer", | ||
"Germ Overlay", | ||
} | ||
); | ||
|
||
___overlayToggleInfos.Add((KIconToggleMenu.ToggleInfo) obj); | ||
} | ||
} | ||
|
||
[HarmonyPatch(typeof(OverlayScreen), "RegisterModes")] | ||
public static class OverlayScreen_RegisterModes_Patch | ||
{ | ||
[UsedImplicitly] | ||
public static void Postfix() | ||
{ | ||
var overlayScreen = Traverse.Create(OverlayScreen.Instance); | ||
overlayScreen.Method("RegisterMode", new GermOverlayMode()).GetValue(); | ||
} | ||
} | ||
|
||
[HarmonyPatch(typeof(StatusItem), "GetStatusItemOverlayBySimViewMode")] | ||
public static class StatusItem_GetStatusItemOverlayBySimViewMode_Patch | ||
{ | ||
[UsedImplicitly] | ||
public static void Prefix(Dictionary<HashedString, StatusItem.StatusItemOverlays> ___overlayBitfieldMap) | ||
{ | ||
if (!___overlayBitfieldMap.ContainsKey(GermOverlayMode.Id)) | ||
{ | ||
___overlayBitfieldMap.Add(GermOverlayMode.Id, StatusItem.StatusItemOverlays.None); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<Configurations>Mergedown</Configurations> | ||
<RootNamespace>GermThing</RootNamespace> | ||
<AssemblyName>GermThing</AssemblyName> | ||
<Platforms>AnyCPU</Platforms> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)' == 'Mergedown'" /> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
title: "Brighter Germ Overlay" | ||
staticID: "asquared31415.GermThing" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
supportedContent: ALL | ||
minimumSupportedBuild: 535842 | ||
version: "0.0.1" | ||
APIVersion: 2 |