-
Notifications
You must be signed in to change notification settings - Fork 0
/
Slughost.cs
145 lines (130 loc) · 4.97 KB
/
Slughost.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Security;
using System.Security.Permissions;
using UnityEngine;
using RWCustom;
using BepInEx;
using Debug = UnityEngine.Debug;
using System.Data.SqlClient;
using UnityEngine.Rendering;
using System.Runtime.Serialization;
using Newtonsoft.Json.Serialization;
using IL.Menu.Remix.MixedUI;
using Menu.Remix.MixedUI;
using On.Menu.Remix.MixedUI;
using System.Runtime.Remoting.Messaging;
using MonoMod.RuntimeDetour;
using System.Xml;
using MonoMod.Cil;
using System.Runtime.Remoting.Lifetime;
using Steamworks;
using MonoMod;
using Unity.Collections.LowLevel.Unsafe;
using IL.Stove.Sample.Session;
using System.Reflection.Emit;
using On.Stove.Sample.Session;
using MonoMod.Utils.Cil;
using Stove.Sample.Session;
using Microsoft.Win32.SafeHandles;
using Unity.Collections;
using System.Collections;
#pragma warning disable CS0618
[module: UnverifiableCode]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
namespace SlughostMod;
[BepInPlugin("Ravethn.Slughost", "Slughosts", "1.0.4")]
public partial class SlughostMod : BaseUnityPlugin
{
private SlughostModOptions Options;
public SlughostMod()
{
try
{
Options = new SlughostModOptions(this, Logger);
}
catch (Exception ex)
{
Logger.LogError(ex);
throw;
}
}
private void OnEnable()
{
On.RainWorld.OnModsInit += RainWorldOnOnModsInit;
}
private void OnDisable()
{
MyModdedEnums.CreatureTemplateType.UnregisterValues();
}
private bool IsInit;
private void RainWorldOnOnModsInit(On.RainWorld.orig_OnModsInit orig, RainWorld self)
{
orig(self);
try
{
if (IsInit) return;
//Your hooks go here
MyModdedEnums.CreatureTemplateType.RegisterValues();
On.StaticWorld.InitCustomTemplates += StaticWorldOnInitCustomTemplates;
On.StaticWorld.InitStaticWorld += StaticWorldOnInitStaticWorld;
On.AbstractCreature.Realize += AbstractCreatureOnRealize;
On.PlayerGraphics.InitiateSprites += PlayerGraphicsOnInitiateSprites;
On.Player.Die += PlayerOnDie;
On.Player.Grabability += PlayerOnGrabability;
On.ShelterDoor.Close += ShelterDoorOnClose;
On.RainWorldGame.ctor += RainWorldGameOnctor;
On.Player.Destroy += PlayerOnDestroy;
On.Player.Update += PlayerOnUpdate;
On.Player.LungUpdate += PlayerOnLungUpdate;
On.Weapon.HitThisObject += WeaponOnHitThisObject;
On.PlayerGraphics.TailSpeckles.setSpearProgress += PlayerGraphicsOnSetSpearProgress;
On.Player.PyroDeath += PlayerOnPyroDeath;
On.BigEel.JawsSnap += BigEelOnJawsSnap;
On.MirosBirdAI.DoIWantToBiteCreature += MirosBirdAIOnDoIWantToBiteCreature;
On.MirosBird.JawSlamShut += MirosBirdOnJawSlamShut;
On.Player.SlugOnBack.ChangeOverlap += SlugOnBackOnChangeOverlap;
IL.GhostCreatureSedater.Update += GhostCreatureSedaterILUpdate;
On.CreatureSymbol.ColorOfCreature += CreatureSymbolOnColorOfCreature;
On.CreatureSymbol.SpriteNameOfCreature += CreatureSymbolOnSpriteNameOfCreature;
On.CreatureSymbol.SymbolDataFromCreature += CreatureSymbolOnSymbolDataFromCreature;
IL.HUD.Map.Draw += MapILDraw;
On.HUD.Map.ItemMarker.ItemMakerData.DataFromAbstractPhysical += ItemMakerDataOnDataFromAbstractPhysical;
On.HUD.Map.ShelterMarker.ItemInShelterMarker.ItemInShelterData.DataFromAbstractPhysical += ItemInShelterDataOnDataFromAbstractPhysical;
IL.MoreSlugcats.StowawayBug.Update += StowawayBugILUpdate;
On.NoiseTracker.HeardNoise += NoiseTrackerOnHeardNoise;
IL.JellyFish.Update += JellyFishILUpdate;
On.MoreSlugcats.BigJellyFish.ValidGrabCreature += BigJellyFishOnValidGrabCreature;
On.MoreSlugcats.BigJellyFish.HeardNoise += BigJellyFishOnHeardNoise;
On.RainWorldGame.ShutDownProcess += RainWorldGameOnShutDownProcess;
On.GameSession.ctor += GameSessionOnctor;
MachineConnector.SetRegisteredOI("Ravethn.Slughost", Options);
IsInit = true;
}
catch (Exception ex)
{
Logger.LogError(ex);
throw;
}
}
private void RainWorldGameOnShutDownProcess(On.RainWorldGame.orig_ShutDownProcess orig, RainWorldGame self)
{
orig(self);
ClearMemory();
}
private void GameSessionOnctor(On.GameSession.orig_ctor orig, GameSession self, RainWorldGame game)
{
orig(self, game);
ClearMemory();
}
#region Helper Methods
private void ClearMemory()
{
//If you have any collections (lists, dictionaries, etc.)
//Clear them here to prevent a memory leak
//YourList.Clear();
}
#endregion
}