time should be calculated in the correct handler
This commit is contained in:
@@ -26,9 +26,9 @@ namespace Nox.Game {
|
|||||||
public int suppliesAvailable = -1;
|
public int suppliesAvailable = -1;
|
||||||
public float currentTime = -1f;
|
public float currentTime = -1f;
|
||||||
public DayPhase currentDayPhase = DayPhase.Morning;
|
public DayPhase currentDayPhase = DayPhase.Morning;
|
||||||
public List<string> completedEncounterIds = new ();
|
public List<string> completedEncounterIds = new();
|
||||||
public List<string> abandonedEncounterIds = new ();
|
public List<string> abandonedEncounterIds = new();
|
||||||
public List<QuestLogEntry> questLogEntries = new ();
|
public List<QuestLogEntry> questLogEntries = new();
|
||||||
}
|
}
|
||||||
|
|
||||||
public class AdventurePlayMode : IPlayMode {
|
public class AdventurePlayMode : IPlayMode {
|
||||||
@@ -139,11 +139,7 @@ namespace Nox.Game {
|
|||||||
|
|
||||||
var calendarSettings = Addressables.LoadAssetAsync<CalendarSettings>("CalendarSettings").WaitForCompletion();
|
var calendarSettings = Addressables.LoadAssetAsync<CalendarSettings>("CalendarSettings").WaitForCompletion();
|
||||||
var worldClock = new WorldClock(calendarSettings);
|
var worldClock = new WorldClock(calendarSettings);
|
||||||
var totalMinutes = adventureData.currentDay * calendarSettings.MinutesPerDay
|
timeHandler ??= new TimeHandler(adventureSettings, adventureData, worldClock, calendarSettings);
|
||||||
+ (int)(adventureData.currentTime * calendarSettings.MinutesPerDay);
|
|
||||||
worldClock.AdvanceMinutes(totalMinutes);
|
|
||||||
worldClock.Tick(adventureData.currentTime);
|
|
||||||
timeHandler ??= new TimeHandler(adventureSettings, adventureData, worldClock);
|
|
||||||
|
|
||||||
zoneSystem ??= new ZoneSystem(mapRef.zonesObjectHolder);
|
zoneSystem ??= new ZoneSystem(mapRef.zonesObjectHolder);
|
||||||
encounterHandler = new EncounterHandler(zoneSystem, encounterRegistry, encounterPrefabs, adventureData, questProgress);
|
encounterHandler = new EncounterHandler(zoneSystem, encounterRegistry, encounterPrefabs, adventureData, questProgress);
|
||||||
@@ -169,7 +165,7 @@ namespace Nox.Game {
|
|||||||
var popupViewPrefab = Addressables.LoadAssetAsync<GameObject>("PopupReferencePrefab").WaitForCompletion().GetComponent<PopupReference>();
|
var popupViewPrefab = Addressables.LoadAssetAsync<GameObject>("PopupReferencePrefab").WaitForCompletion().GetComponent<PopupReference>();
|
||||||
var guiCanvas = guiReferences.GetComponentInParent<Canvas>().transform;
|
var guiCanvas = guiReferences.GetComponentInParent<Canvas>().transform;
|
||||||
popupSystem = new PopupSystem(popupSettings, popupViewPrefab, guiCanvas);
|
popupSystem = new PopupSystem(popupSettings, popupViewPrefab, guiCanvas);
|
||||||
popupSystem.RegisterCategory(PopupCategory.Character, priority: 10);
|
popupSystem.RegisterCategory(PopupCategory.Character, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
partyGuiView = new PartyGuiView(guiReferences.portraitsContainer, guiReferences.partyMemberSlotPrefab, portraitsHolder, popupSystem);
|
partyGuiView = new PartyGuiView(guiReferences.portraitsContainer, guiReferences.partyMemberSlotPrefab, portraitsHolder, popupSystem);
|
||||||
@@ -207,7 +203,7 @@ namespace Nox.Game {
|
|||||||
activePlayMode = PlayMode.Adventure,
|
activePlayMode = PlayMode.Adventure,
|
||||||
activeParty = partyDefinition,
|
activeParty = partyDefinition,
|
||||||
partyPosition = partyRef ? SerializableVector3.FromVector3(partyRef.transform.position) : SerializableVector3.Zero,
|
partyPosition = partyRef ? SerializableVector3.FromVector3(partyRef.transform.position) : SerializableVector3.Zero,
|
||||||
adventureData = this.adventureData,
|
adventureData = adventureData,
|
||||||
questLogEntries = questLog?.CreateSnapshot() ?? new List<QuestLogEntry>()
|
questLogEntries = questLog?.CreateSnapshot() ?? new List<QuestLogEntry>()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,10 +28,14 @@ namespace Nox.Game {
|
|||||||
(0.90f, DayPhase.Night)
|
(0.90f, DayPhase.Night)
|
||||||
};
|
};
|
||||||
|
|
||||||
public TimeHandler(AdventureSettings adventureSettings, AdventureData adventureData, WorldClock worldClock) {
|
public TimeHandler(AdventureSettings adventureSettings, AdventureData adventureData, WorldClock worldClock, CalendarSettings calendarSettings) {
|
||||||
this.adventureSettings = adventureSettings;
|
this.adventureSettings = adventureSettings;
|
||||||
this.adventureData = adventureData;
|
this.adventureData = adventureData;
|
||||||
this.worldClock = worldClock;
|
this.worldClock = worldClock;
|
||||||
|
// restore time from saved data
|
||||||
|
var totalMinutes = (adventureData.currentDay * calendarSettings.MinutesPerDay)
|
||||||
|
+ (int)(adventureData.currentTime * calendarSettings.MinutesPerDay);
|
||||||
|
worldClock.AdvanceMinutes(totalMinutes);
|
||||||
localTime = adventureData.currentTime * adventureSettings.dayLength;
|
localTime = adventureData.currentTime * adventureSettings.dayLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user