-
Notifications
You must be signed in to change notification settings - Fork 1
/
AdvancedDungeonPrerequisite.cs
200 lines (196 loc) · 10.4 KB
/
AdvancedDungeonPrerequisite.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;
namespace SpecialItemPack
{
class AdvancedDungeonPrerequisite : DungeonPrerequisite
{
public new bool CheckConditionsFulfilled()
{
if(this.advancedPrerequisiteType != AdvancedPrerequisiteType.NONE)
{
if(this.advancedPrerequisiteType == AdvancedPrerequisiteType.CUSTOM_FLAG)
{
return AdvancedGameStatsManager.Instance.GetFlag(this.customFlagToCheck) == this.requireCustomFlag;
}
else if(this.advancedPrerequisiteType == AdvancedPrerequisiteType.CUSTOM_STAT)
{
return false;
}
}
else
{
return this.CheckConditionsFulfilledOrig();
}
return false;
}
public bool CheckConditionsFulfilledOrig()
{
EncounterDatabaseEntry encounterDatabaseEntry = null;
if (!string.IsNullOrEmpty(this.encounteredObjectGuid))
{
encounterDatabaseEntry = EncounterDatabase.GetEntry(this.encounteredObjectGuid);
}
switch (this.prerequisiteType)
{
case DungeonPrerequisite.PrerequisiteType.ENCOUNTER:
if (encounterDatabaseEntry == null && this.encounteredRoom == null)
{
return true;
}
if (encounterDatabaseEntry != null)
{
int num = GameStatsManager.Instance.QueryEncounterable(encounterDatabaseEntry);
switch (this.prerequisiteOperation)
{
case DungeonPrerequisite.PrerequisiteOperation.LESS_THAN:
return num < this.requiredNumberOfEncounters;
case DungeonPrerequisite.PrerequisiteOperation.EQUAL_TO:
return num == this.requiredNumberOfEncounters;
case DungeonPrerequisite.PrerequisiteOperation.GREATER_THAN:
return num > this.requiredNumberOfEncounters;
default:
Debug.LogError("Switching on invalid stat comparison operation!");
break;
}
}
else if (this.encounteredRoom != null)
{
int num2 = GameStatsManager.Instance.QueryRoomEncountered(this.encounteredRoom.GUID);
switch (this.prerequisiteOperation)
{
case DungeonPrerequisite.PrerequisiteOperation.LESS_THAN:
return num2 < this.requiredNumberOfEncounters;
case DungeonPrerequisite.PrerequisiteOperation.EQUAL_TO:
return num2 == this.requiredNumberOfEncounters;
case DungeonPrerequisite.PrerequisiteOperation.GREATER_THAN:
return num2 > this.requiredNumberOfEncounters;
default:
Debug.LogError("Switching on invalid stat comparison operation!");
break;
}
}
return false;
case DungeonPrerequisite.PrerequisiteType.COMPARISON:
{
float playerStatValue = GameStatsManager.Instance.GetPlayerStatValue(this.statToCheck);
switch (this.prerequisiteOperation)
{
case DungeonPrerequisite.PrerequisiteOperation.LESS_THAN:
return playerStatValue < this.comparisonValue;
case DungeonPrerequisite.PrerequisiteOperation.EQUAL_TO:
return playerStatValue == this.comparisonValue;
case DungeonPrerequisite.PrerequisiteOperation.GREATER_THAN:
return playerStatValue > this.comparisonValue;
default:
Debug.LogError("Switching on invalid stat comparison operation!");
break;
}
break;
}
case DungeonPrerequisite.PrerequisiteType.CHARACTER:
{
PlayableCharacters playableCharacters = (PlayableCharacters)(-1);
if (!BraveRandom.IgnoreGenerationDifferentiator)
{
if (GameManager.Instance.PrimaryPlayer != null)
{
playableCharacters = GameManager.Instance.PrimaryPlayer.characterIdentity;
}
else if (GameManager.PlayerPrefabForNewGame != null)
{
playableCharacters = GameManager.PlayerPrefabForNewGame.GetComponent<PlayerController>().characterIdentity;
}
else if (GameManager.Instance.BestGenerationDungeonPrefab != null)
{
playableCharacters = GameManager.Instance.BestGenerationDungeonPrefab.defaultPlayerPrefab.GetComponent<PlayerController>().characterIdentity;
}
}
return this.requireCharacter == (playableCharacters == this.requiredCharacter);
}
case DungeonPrerequisite.PrerequisiteType.TILESET:
if (GameManager.Instance.BestGenerationDungeonPrefab != null)
{
return this.requireTileset == (GameManager.Instance.BestGenerationDungeonPrefab.tileIndices.tilesetId == this.requiredTileset);
}
return this.requireTileset == (GameManager.Instance.Dungeon.tileIndices.tilesetId == this.requiredTileset);
case DungeonPrerequisite.PrerequisiteType.FLAG:
return GameStatsManager.Instance.GetFlag(this.saveFlagToCheck) == this.requireFlag;
case DungeonPrerequisite.PrerequisiteType.DEMO_MODE:
return !this.requireDemoMode;
case DungeonPrerequisite.PrerequisiteType.MAXIMUM_COMPARISON:
{
float playerMaximum = GameStatsManager.Instance.GetPlayerMaximum(this.maxToCheck);
switch (this.prerequisiteOperation)
{
case DungeonPrerequisite.PrerequisiteOperation.LESS_THAN:
return playerMaximum < this.comparisonValue;
case DungeonPrerequisite.PrerequisiteOperation.EQUAL_TO:
return playerMaximum == this.comparisonValue;
case DungeonPrerequisite.PrerequisiteOperation.GREATER_THAN:
return playerMaximum > this.comparisonValue;
default:
Debug.LogError("Switching on invalid stat comparison operation!");
break;
}
break;
}
case DungeonPrerequisite.PrerequisiteType.ENCOUNTER_OR_FLAG:
if (GameStatsManager.Instance.GetFlag(this.saveFlagToCheck) == this.requireFlag)
{
return true;
}
if (encounterDatabaseEntry != null)
{
int num3 = GameStatsManager.Instance.QueryEncounterable(encounterDatabaseEntry);
switch (this.prerequisiteOperation)
{
case DungeonPrerequisite.PrerequisiteOperation.LESS_THAN:
return num3 < this.requiredNumberOfEncounters;
case DungeonPrerequisite.PrerequisiteOperation.EQUAL_TO:
return num3 == this.requiredNumberOfEncounters;
case DungeonPrerequisite.PrerequisiteOperation.GREATER_THAN:
return num3 > this.requiredNumberOfEncounters;
default:
Debug.LogError("Switching on invalid stat comparison operation!");
break;
}
}
else if (this.encounteredRoom != null)
{
int num4 = GameStatsManager.Instance.QueryRoomEncountered(this.encounteredRoom.GUID);
switch (this.prerequisiteOperation)
{
case DungeonPrerequisite.PrerequisiteOperation.LESS_THAN:
return num4 < this.requiredNumberOfEncounters;
case DungeonPrerequisite.PrerequisiteOperation.EQUAL_TO:
return num4 == this.requiredNumberOfEncounters;
case DungeonPrerequisite.PrerequisiteOperation.GREATER_THAN:
return num4 > this.requiredNumberOfEncounters;
default:
Debug.LogError("Switching on invalid stat comparison operation!");
break;
}
}
return false;
case DungeonPrerequisite.PrerequisiteType.NUMBER_PASTS_COMPLETED:
return (float)GameStatsManager.Instance.GetNumberPastsBeaten() >= this.comparisonValue;
default:
Debug.LogError("Switching on invalid prerequisite type!!!");
break;
}
return false;
}
public AdvancedPrerequisiteType advancedPrerequisiteType;
public CustomDungeonFlags customFlagToCheck;
public bool requireCustomFlag;
public enum AdvancedPrerequisiteType
{
NONE,
CUSTOM_FLAG,
CUSTOM_STAT
}
}
}