Created
June 9, 2023 22:49
-
-
Save alexjlockwood/a17c083edd3712672b0c3b5c221864e4 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using FG.Common; | |
using SRF; | |
using UnityEngine; | |
namespace Levels.CrownMaze | |
{ | |
// Token: 0x020004C1 RID: 1217 | |
public class CrownMazeRoomRandomiser : SeededRandomisable | |
{ | |
// Token: 0x06001C21 RID: 7201 RVA: 0x0005E920 File Offset: 0x0005CB20 | |
public override string HandleRandomisation(FGRandom rand) | |
{ | |
List<Transform> list = this._holdersParent.GetChildren().ToList<Transform>(); | |
List<CrownMazeRoom> list2 = this._mazeRoomsParent.GetComponentsInChildren<CrownMazeRoom>(true).ToList<CrownMazeRoom>(); | |
List<CrownMazeRoom> list3 = (from room in list2 | |
where room.IsRoomEnabledThroughVariation | |
select room).ToList<CrownMazeRoom>(); | |
List<CrownMazeRoom> list4 = new List<CrownMazeRoom>(list2); | |
Debug.Log(string.Format("Active Room Pool Count: {0}", list3.Count)); | |
rand.Shuffle<CrownMazeRoom>(list3); | |
bool flag = true; | |
for (int i = 0; i < list.Count; i++) | |
{ | |
Transform parent = list[i]; | |
if (i < list3.Count) | |
{ | |
CrownMazeRoom crownMazeRoom = list3[i]; | |
Transform transform = crownMazeRoom.transform; | |
transform.SetParent(parent); | |
transform.localPosition = Vector3.zero; | |
crownMazeRoom.gameObject.SetActive(true); | |
list4.Remove(crownMazeRoom); | |
} | |
else | |
{ | |
flag = false; | |
UnityEngine.Object.Instantiate<GameObject>(this._defaultMazeRoomPrefab, parent, false); | |
} | |
} | |
foreach (CrownMazeRoom crownMazeRoom2 in list4) | |
{ | |
UnityEngine.Object.Destroy(crownMazeRoom2.gameObject); | |
} | |
if (!flag) | |
{ | |
Debug.LogError("CrownMazeRoomRandomiser:HandleRandomisation - not enough active gauntlets to fill maze! Fix Setup in scene and on CMS! "); | |
} | |
return string.Format("CrownMazeRoomRandomiser:HandleRandomisation - random setup finished with success = {0}", flag); | |
} | |
// Token: 0x04001AE6 RID: 6886 | |
[SerializeField] | |
private Transform _holdersParent; | |
// Token: 0x04001AE7 RID: 6887 | |
[SerializeField] | |
private Transform _mazeRoomsParent; | |
// Token: 0x04001AE8 RID: 6888 | |
[SerializeField] | |
private GameObject _defaultMazeRoomPrefab; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment