Optimizations
This commit is contained in:
@@ -14,11 +14,19 @@ namespace Jovian.EncounterSystem {
|
||||
public Dictionary<string, IEncounter> GetEncounters() => encounters;
|
||||
|
||||
public void RegisterEncounter(IEncounter encounter) {
|
||||
encounters?.TryAdd(encounter?.EncounterDefinition?.internalId, encounter);
|
||||
var id = encounter?.EncounterDefinition?.internalId;
|
||||
if(string.IsNullOrEmpty(id)) {
|
||||
return;
|
||||
}
|
||||
encounters.TryAdd(id, encounter);
|
||||
}
|
||||
|
||||
public void UnregisterEncounter(IEncounter encounter) {
|
||||
encounters.Remove(encounter.EncounterDefinition.internalId);
|
||||
var id = encounter?.EncounterDefinition?.internalId;
|
||||
if(string.IsNullOrEmpty(id)) {
|
||||
return;
|
||||
}
|
||||
encounters.Remove(id);
|
||||
}
|
||||
|
||||
public void ClearEncounters() {
|
||||
@@ -26,10 +34,24 @@ namespace Jovian.EncounterSystem {
|
||||
}
|
||||
|
||||
public void PopulateEncounters() {
|
||||
foreach(var collection in encounterCollections) {
|
||||
foreach(var encounter in collection.encounterTables) {
|
||||
foreach(var encounterInstance in encounter.encounters) {
|
||||
RegisterEncounter(encounterInstance);
|
||||
if(encounterCollections == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
for(int c = 0; c < encounterCollections.Length; c++) {
|
||||
var collection = encounterCollections[c];
|
||||
if(collection?.encounterTables == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for(int t = 0; t < collection.encounterTables.Length; t++) {
|
||||
var table = collection.encounterTables[t];
|
||||
if(table?.encounters == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for(int i = 0; i < table.encounters.Count; i++) {
|
||||
RegisterEncounter(table.encounters[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user