-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSceneSetup.cs
435 lines (386 loc) · 19 KB
/
SceneSetup.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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
using LobbyAppearanceImprovements.Scenes;
using R2API;
using RoR2;
using System;
using UnityEngine;
namespace LobbyAppearanceImprovements
{
public static class SceneSetup
{
#region ActionSetup
public static Action<GameObject[]> SceneAssetAPI_IntroAction;
public static Action<GameObject[]> SceneAssetAPI_LobbyAction;
public static Action<GameObject[]> SceneAssetAPI_TitleAction;
public static Action<GameObject[]> SceneAssetAPI_VoidOutroAction;
public static Action<GameObject[]> SceneAssetAPI_itmoonAction;
public static Action<GameObject[]> SceneAssetAPI_BazaarAction;
public static Action<GameObject[]> SceneAssetAPI_LemurianTempleAction;
public static Action<GameObject[]> SceneAssetAPI_OutroAction;
public static void Init()
{
SceneAssetAPI_IntroAction += CaptainHelm_Setup;
SceneAssetAPI.AddAssetRequest("intro", SceneAssetAPI_IntroAction);
//SceneAssetAPI_LobbyAction += SceneAssetAPI_GetLobbyObjects;
//SceneAssetAPI.AddAssetRequest("lobby", SceneAssetAPI_LobbyAction);
//SetupContactLight();
SceneAssetAPI_TitleAction += LobbyMulti_Setup;
SceneAssetAPI.AddAssetRequest("title", SceneAssetAPI_TitleAction);
SceneAssetAPI_VoidOutroAction += VoidOceanFloor_Setup;
SceneAssetAPI.AddAssetRequest("voidoutro", SceneAssetAPI_VoidOutroAction);
//SceneAssetAPI_BazaarAction += BazaarStoreObject_Setup;
//SceneAssetAPI.AddAssetRequest("bazaar", SceneAssetAPI_BazaarAction);
//SceneAssetAPI_LemurianTempleAction += LemurianTempleSetup;
//SceneAssetAPI.AddAssetRequest("lemuriantemple", SceneAssetAPI_LemurianTempleAction);
//SceneAssetAPI_OutroAction += OutroSetup;
//SceneAssetAPI.AddAssetRequest("outro", SceneAssetAPI_OutroAction);
}
public static GameObject outroArenaStuff;
private static void OutroSetup(GameObject[] obj)
{
foreach (var go in obj)
{
if (go.name == "Set 4 - Arena")
{
go.SetActive(true);
go.transform.Find("FX").gameObject.SetActive(false);
outroArenaStuff = PrefabAPI.InstantiateClone(go, "LAI_OutroArena");
return;
}
}
}
public static GameObject chefLemTempleStuff;
private static void LemurianTempleSetup(GameObject[] obj)
{
var newHolder = new GameObject();
foreach (var go in obj)
{
if (go.name == "HOLDER: ChefZone")
{
go.transform.parent = newHolder.transform;
}
else if (go.name == "HOLDER:Terrain")
{
go.transform.parent = newHolder.transform;
UnityEngine.Object.Destroy(go.transform.Find("Water Plane").gameObject);
UnityEngine.Object.Destroy(go.transform.Find("Water Plane (1)").gameObject);
UnityEngine.Object.Destroy(go.transform.Find("Water Plane (2)").gameObject);
UnityEngine.Object.Destroy(go.transform.Find("Water Plane (3)").gameObject);
UnityEngine.Object.Destroy(go.transform.Find("LTAltar").gameObject);
//var terrain = go.transform.Find("LtTerrain");
//UnityEngine.Object.Destroy(terrain.transform.Find("meshLTColumn").gameObject);
//UnityEngine.Object.Destroy(terrain.transform.Find("meshLTGold").gameObject);
//UnityEngine.Object.Destroy(terrain.transform.Find("meshLTSecretPlate").gameObject);
//UnityEngine.Object.Destroy(terrain.transform.Find("meshLTStairs").gameObject);
}
else if (go.name == "HOLDER: Prop")
{
go.transform.parent = newHolder.transform;
UnityEngine.Object.Destroy(go.transform.Find("YellowCoral").gameObject);
UnityEngine.Object.Destroy(go.transform.Find("Crystal").gameObject);
UnityEngine.Object.Destroy(go.transform.Find("LTPebbles").gameObject);
UnityEngine.Object.Destroy(go.transform.Find("GoldDecal").gameObject);
UnityEngine.Object.Destroy(go.transform.Find("RedRoots").gameObject);
}
else if (go.name == "Weather, LemurianTemple")
{
go.transform.parent = newHolder.transform;
}
}
chefLemTempleStuff = PrefabAPI.InstantiateClone(newHolder, "LAI_CHEFROOM", false);
//LAIScene.CloneFromAddressable("RoR2/DLC2/lakes/Weather, Lakes.prefab", chefLemTempleStuff.transform);
UnityEngine.Object.Destroy(newHolder);
}
public static string GetPath(this Transform current)
{
if (current.parent == null)
return "/" + current.name;
return current.parent.GetPath() + "/" + current.name;
}
public static GameObject VoidOutroSet7;
private static void VoidOceanFloor_Setup(GameObject[] obj)
{
foreach (var go in obj)
{
if (go.name == "Set 7: Bottom of the Ocean")
{
VoidOutroSet7 = PrefabAPI.InstantiateClone(go, "LAI_VOIDOUTROSET7", false);
VoidOutroSet7.transform.Find("CrabHolder").GetComponent<ShakeEmitter>().enabled = false;
VoidOutroSet7.SetActive(true);
return;
}
}
}
public static GameObject SpaceCabin;
private static void LobbyMulti_Setup(GameObject[] gameObjects)
{
foreach (var gameObject in gameObjects)
{
if (gameObject.name == "MainMenu")
{
SpaceCabin = PrefabAPI.InstantiateClone(gameObject.transform.Find("MENU: Multiplayer/World Position/HOLDER: Background").gameObject, "LAI_SPACECABIN", false);
//https://forum.unity.com/threads/changing-objects-to-from-static-at-runtime.575080/#post-7140668
SpaceCabin.isStatic = false;
foreach (var tool in SpaceCabin.transform.GetComponentsInChildren<Transform>())
{
tool.gameObject.isStatic = false;
}
return;
}
}
}
#endregion ActionSetup
// Scene Prefabs
#region Captain's Helm Setup
public static GameObject CaptainHelmObject;
public static void CaptainHelm_Setup(GameObject[] gameObjects)
{
GameObject cabin = null;
GameObject skybox = null;
GameObject planet = null;
foreach (var gameObject in gameObjects)
{
switch (gameObject.name)
{
case "Set 2 - Cabin":
cabin = gameObject;
continue;
case "Cutscene Space Skybox":
skybox = gameObject;
continue;
case "Set 3 - Space, Small Planet":
planet = gameObject;
planet.SetActive(false); //for now
continue;
}
}
var newHolder = new GameObject();
cabin.transform.parent = newHolder.transform;
cabin.transform.position = new Vector3(1f, 1f, 1f);
cabin.transform.Find("CabinPosition").transform.localScale = Vector3.one * 200;
cabin.transform.Find("CabinPosition").transform.localPosition = new Vector3(-18, 4.2f, 6);
skybox.transform.parent = newHolder.transform;
skybox.transform.localScale = Vector3.one * 30;
planet.transform.parent = newHolder.transform;
//planet.SetActive(true);
CaptainHelmObject = PrefabAPI.InstantiateClone(newHolder, "LAI_CaptainsHelm_Cabin", false);
UnityEngine.Object.Destroy(newHolder);
}
#endregion Captain's Helm Setup
#region UES Contact Light Setup
public static void SceneAssetAPI_GetLobbyObjects(GameObject[] gameObjects)
{
foreach (var gameObject in gameObjects)
{
if (gameObject.name == "MeshProps")
{
var backWall = GameObject.Find("spacecabin");
CaptainHelmObject = PrefabAPI.InstantiateClone(backWall, "Cabin", false);
}
}
}
public static GameObject ContactLightPrefab;
public static GameObject ContactLight_RestraintBar;
public static GameObject ContactLight_Commando;
public static GameObject ContactLight_Enforcer;
public static GameObject ContactLight_Bandit2;
public static GameObject ContactLight_Huntress;
public static GameObject ContactLight_HAND;
public static GameObject ContactLight_Engineer;
public static GameObject ContactLight_Miner;
public static GameObject ContactLight_Sniper;
public static GameObject ContactLight_Acrid;
public static GameObject ContactLight_Mercenary;
public static GameObject ContactLight_Loader;
public static GameObject ContactLight_CHEF;
public static void SetupContactLight()
{
var restraintMesh = RoR2Content.Survivors.Croco.displayPrefab.transform.Find("mdlCroco/Spawn/SpawnFX/Chunks, Solid").GetComponent<ParticleSystemRenderer>().mesh;
var obj = new GameObject();
ContactLightPrefab = PrefabAPI.InstantiateClone(obj, "Contact Light Prefab", false);
ContactLight_RestraintBar = new GameObject();
ContactLight_RestraintBar = PrefabAPI.InstantiateClone(obj, "RestraintBar", false);
var meshRenderer = ContactLight_RestraintBar.AddComponent<MeshRenderer>();
var meshFilter = ContactLight_RestraintBar.AddComponent<MeshFilter>();
meshFilter.mesh = restraintMesh;
SetupCommando();
SetupBandit2();
UnityEngine.Object.Destroy(obj);
}
public static void SetupCommando()
{
ContactLight_Commando = PrefabAPI.InstantiateClone(RoR2Content.Survivors.Commando.displayPrefab, "ContactLight_Commando", false);
ContactLight_Commando.transform.localEulerAngles = new Vector3(0, 180, 0);
ContactLight_Commando.transform.position = new Vector3(0f, 0f, 2f);
var restraintBar = ContactLight_RestraintBar.InstantiateClone("Commando_RestraintBar", false);
restraintBar.transform.SetParent(ContactLight_Commando.transform);
restraintBar.transform.localEulerAngles = new Vector3(310, 0, 0);
restraintBar.transform.localScale = new Vector3(0.25f, 0.6f, 0.4f);
restraintBar.transform.localPosition = new Vector3(0.02f, 1.4f, 0.2f);
ContactLight_Commando.GetComponentInChildren<Animator>().enabled = false;
var chest = ContactLight_Commando.transform.Find("mdlCommandoDualies/CommandoArmature/ROOT/base/stomach/chest");
chest.Find("upper_arm.l").localEulerAngles = new Vector3(0, 0, 145);
chest.Find("upper_arm.l/lower_arm.l").localEulerAngles = new Vector3(340, 270, 240);
chest.Find("upper_arm.l/lower_arm.l/hand.l").localEulerAngles = new Vector3(15, 35, -8.8389f);
chest.Find("upper_arm.l/lower_arm.l/hand.l/gun.l").localScale = Vector3.zero;
chest.Find("upper_arm.r").localEulerAngles = new Vector3(3, 4, 205);
chest.Find("upper_arm.r/lower_arm.r").localEulerAngles = new Vector3(340, 270, 240);
chest.Find("upper_arm.r/lower_arm.r/hand.r").localEulerAngles = new Vector3(15, 35, -8.8389f);
chest.Find("upper_arm.r/lower_arm.r/hand.r/gun.r").transform.localScale = Vector3.zero;
}
public static void SetupBandit2()
{
ContactLight_Bandit2 = PrefabAPI.InstantiateClone(RoR2Content.Survivors.Bandit2.displayPrefab, "ContactLight_Bandit2", false);
ContactLight_Bandit2.transform.localEulerAngles = new Vector3(0, 180, 0);
ContactLight_Bandit2.transform.position = new Vector3(0f, 0f, 2f);
ContactLight_Commando.GetComponentInChildren<Animator>().enabled = false;
var restraintBar = ContactLight_RestraintBar.InstantiateClone("Commando_RestraintBar", false);
restraintBar.transform.SetParent(ContactLight_Bandit2.transform);
restraintBar.transform.localEulerAngles = new Vector3(310, 0, 0);
restraintBar.transform.localScale = new Vector3(0.25f, 0.6f, 0.4f);
restraintBar.transform.localPosition = new Vector3(-0.06f, 1.6f, 2.75f);
}
#endregion UES Contact Light Setup
#region Bazaar Setup
public static GameObject BazaarStoreObject;
public static void BazaarStoreObject_Setup(GameObject[] gameObjects)
{
GameObject store = null;
GameObject cave2 = null;
GameObject sceneInfo = null;
foreach (var gameObject in gameObjects)
{
switch (gameObject.name)
{
//case "GameManager":
//gameObject.SetActive(false);
//continue;
case "HOLDER: Store":
store = gameObject;
continue;
case "HOLDER: Starting Cave":
cave2 = gameObject.transform.Find("Static").gameObject;
continue;
case "SceneInfo":
sceneInfo = gameObject;
continue;
}
}
//var lunarTable = store.transform.Find("HOLDER: Store/LunarShop/LunarTable/");
//store
foreach (var path in new string[]
{
"HOLDER: Store Platforms/LockedMage",
"CauldronShop/LunarCauldron, GreenToRed",
"CauldronShop/LunarCauldron, WhiteToGreen",
"SeerShop/SeerStation (1)",
"SeerShop/SeerStation",
"LunarShop/LunarRecycler",
"LunarShop/LunarTable/LunarShopTerminal (1)",
"LunarShop/LunarTable/LunarShopTerminal",
"LunarShop/LunarTable/LunarShopTerminal",
"LunarShop/LunarTable/LunarShopTerminal",
"LunarShop/LunarTable/LunarShopTerminal",
})
{
Transform transform = store.transform.Find(path);
transform.gameObject.name += "d";
if (transform.TryGetComponent(out PurchaseAvailabilityIndicator pai))
{
UnityEngine.Object.Destroy(pai);
}
if (transform.TryGetComponent(out PurchaseInteraction pi))
{
UnityEngine.Object.Destroy(pi);
}
if (transform.TryGetComponent(out ShopTerminalBehavior stb))
{
UnityEngine.Object.Destroy(stb);
}
}
int i = 0;
foreach (var obj in store.GetComponentsInChildren<NetworkStateMachine>())
{
i++;
obj.enabled = false;
//UnityEngine.Object.Destroy(obj);
}
Debug.Log("NSMs: " + i);
/*
foreach (var obj in store.GetComponentsInChildren<Transform>())
{
var name = obj.name;
if (name.StartsWith("LunarShopTerminal"))
{
UnityEngine.Object.Destroy(obj.GetComponent<PurchaseInteraction>());
UnityEngine.Object.Destroy(obj.GetComponent<ShopTerminalBehavior>());
}
else if (name.StartsWith("SeerStation"))
{
UnityEngine.Object.Destroy(obj.GetComponent<EntityStateMachine>());
UnityEngine.Object.Destroy(obj.GetComponent<NetworkStateMachine>());
UnityEngine.Object.Destroy(obj.GetComponent<SeerStationController>());
}
}*/
/*foreach (var pur in store.GetComponentsInChildren<NetworkStateMachine>())
{
UnityEngine.Object.Destroy(pur);
}
foreach (var pur in store.GetComponentsInChildren<PurchaseAvailabilityIndicator>())
{
UnityEngine.Object.Destroy(pur);
}
foreach (var pur in store.GetComponentsInChildren<ShopTerminalBehavior>())
{
UnityEngine.Object.Destroy(pur);
}
foreach (var pur in store.GetComponentsInChildren<PurchaseInteraction>())
{
UnityEngine.Object.Destroy(pur);
}
foreach (var pur in store.GetComponentsInChildren<SeerStationController>())
{
UnityEngine.Object.Destroy(pur);
}*/
var newHolder = new GameObject();
//var comp = newHolder.gameObject.AddComponent<Bazaar.LAIBazaarController>();
store.transform.parent = newHolder.transform;
store.transform.position = Vector3.zero;
cave2.transform.parent = newHolder.transform;
cave2.transform.position = Vector3.zero;
foreach (var pur in store.GetComponentsInChildren<PickupDisplay>())
{
//pur.gameObject.AddComponent<Bazaar.PUTracker>();
}
//var store = store.transform.Find("HOLDER: Store");
//var lunarShop = store.Find("LunarShop/LunarTable");
sceneInfo.transform.Find("PP, Global").parent = newHolder.transform;
BazaarStoreObject = PrefabAPI.InstantiateClone(newHolder, "LAI_Bazaar_Store", false);
UnityEngine.Object.Destroy(newHolder);
}
private static void GlobalEventManager_OnEnable(On.RoR2.GlobalEventManager.orig_OnEnable orig, GlobalEventManager self)
{
if (GlobalEventManager.instance)
{
LAILogging.LogMessage($"GEM OnEnable", ConfigSetup.LoggingStyle.ObscureSoOnlyDevSees);
self.enabled = false;
return;
}
orig(self);
}
public static void DestroyComponentInChildren(Transform parent)
{
// Get the type of the component from the name
// Destroy the component if it exists on the current GameObject
if (parent.TryGetComponent<NetworkStateMachine>(out var component))
{
UnityEngine.Object.Destroy(component);
}
// Recursively call this method on all child GameObjects
foreach (Transform child in parent)
{
DestroyComponentInChildren(child);
}
}
#endregion Bazaar Setup
}
}