This repository was archived by the owner on Apr 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMod.cs
More file actions
71 lines (58 loc) · 2.32 KB
/
Copy pathMod.cs
File metadata and controls
71 lines (58 loc) · 2.32 KB
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
using HarmonyLib;
using System.Reflection;
using System.Linq;
using Colossal.Logging;
using Game.Modding;
using Unity.Entities;
using MapImageLayer.Systems;
using Game;
using Game.SceneFlow;
using System.IO;
using UnityEngine;
namespace MapImageLayer
{
public class Mod : IMod
{
public static string AssemblyPath
{
get;
private set;
}
public static readonly string MOD_PATH = Path.Combine( Application.persistentDataPath, "Mods", "LegacyFlavour" );
private const string HARMONY_ID = "cities2modding_mapimagelayer";
private static ILog _log = LogManager.GetLogger( "Cities2Modding" ).SetShowsErrorsInUI( false );
public static Harmony _harmony;
private World _world;
public void OnLoad( UpdateSystem updateSystem )
{
if ( GameManager.instance.modManager.TryGetExecutableAsset( this, out var asset ) )
{
AssemblyPath = Path.GetDirectoryName( asset.path.Replace( '/', Path.DirectorySeparatorChar ) );
}
_world = updateSystem.World;
_harmony = new Harmony( HARMONY_ID );
_harmony.PatchAll( );
_world.GetOrCreateSystemManaged<ImageOverlaySystem>( );
_log.Info( @" __ __ _____ _
| \/ | |_ _| | |
| \ / | __ _ _ __ | | _ __ ___ __ _ __ _ ___| | __ _ _ _ ___ _ __
| |\/| |/ _` | '_ \ | | | '_ ` _ \ / _` |/ _` |/ _ \ | / _` | | | |/ _ \ '__|
| | | | (_| | |_) || |_| | | | | | (_| | (_| | __/ |___| (_| | |_| | __/ |
|_| |_|\__,_| .__/_____|_| |_| |_|\__,_|\__, |\___|______\__,_|\__, |\___|_|
| | __/ | __/ |
|_| |___/ |___/ " );
}
public void OnDispose( )
{
SafelyRemove<ImageOverlaySystem>( );
_harmony.UnpatchAll( HARMONY_ID );
}
private void SafelyRemove<T>( )
where T : GameSystemBase
{
var system = _world.GetExistingSystemManaged<T>( );
if ( system != null )
_world.DestroySystemManaged( system );
}
}
}