forked from bloodypenguin/cities-skylines-unlimiter-1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
LoadingExtension.cs
88 lines (80 loc) · 3.43 KB
/
LoadingExtension.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
using ColossalFramework;
using ColossalFramework.UI;
using ICities;
using UnityEngine;
namespace EightyOne
{
public class LoadingExtension : LoadingExtensionBase
{
public override void OnCreated(ILoading loading)
{
base.OnCreated(loading);
if (loading == null || loading.currentMode == AppMode.Game)
{
Detours.SetUp();
}
}
public override void OnLevelLoaded(LoadMode mode)
{
base.OnLevelLoaded(mode);
if (mode != LoadMode.NewGame && mode != LoadMode.NewGameFromScenario && mode != LoadMode.LoadGame)
{
return;
}
Detours.Deploy();
SimulationManager.instance.AddAction(() => Object.FindObjectOfType<RenderProperties>().m_edgeFogDistance = 2800f);
SimulationManager.instance.AddAction(() => Object.FindObjectOfType<FogEffect>().m_edgeFogDistance = 2800f);
SimulationManager.instance.AddAction(() => Object.FindObjectOfType<FogProperties>().m_EdgeFogDistance = 2800f);
if (Util.IsModActive(Mod.ALL_TILES_START_MOD))
{
UIView.library.ShowModal<ExceptionPanel>("ExceptionPanel").SetMessage(
"81 Tiles - Incompatible mod detected",
$"'81 Tiles' isn't compatible with 'All Tile Start' mod!\nPlease unsubscribe that mod and use '{Mod.UNLOCK_ALL_TILES_FOR_FREE}' button in '81 Tiles' options entry!",
false);
}
SimulationManager.instance.AddAction(FixNotInParkProblem);
}
private static void FixNotInParkProblem()
{
for (uint i = 0; i < BuildingManager.instance.m_buildings.m_size; i++)
{
var data = BuildingManager.instance.m_buildings.m_buffer[i];
if (data.Info == null || !(data.Info.m_buildingAI is IndustryBuildingAI))
{
continue;
}
DistrictManager instance = Singleton<DistrictManager>.instance;
if ((data.m_problems & Notification.Problem.NotInIndustryArea) != Notification.Problem.None)
{
byte park = instance.GetPark(data.m_position);
if (park != (byte) 0)
{
if (!instance.m_parks.m_buffer[(int) park].IsIndustry)
park = (byte) 0;
else
{
var industryBuildingAi = ((IndustryBuildingAI) data.Info.m_buildingAI);
if (industryBuildingAi.m_industryType == DistrictPark.ParkType.Industry ||
industryBuildingAi.m_industryType != instance.m_parks.m_buffer[(int) park].m_parkType)
park = (byte) 0;
}
}
if (park != 0)
{
BuildingManager.instance.m_buildings.m_buffer[i].m_problems = Notification.RemoveProblems(data.m_problems,
Notification.Problem.NotInIndustryArea);
}
}
}
}
public override void OnLevelUnloading()
{
Detours.Revert();
}
public override void OnReleased()
{
base.OnReleased();
Detours.TearDown();
}
}
}