Added a custom calendar system

This commit is contained in:
Sebastian Bularca
2026-04-12 19:14:37 +02:00
parent 3428f168f9
commit 0e00e798fd
27 changed files with 790 additions and 22 deletions

View File

@@ -115,6 +115,11 @@ MonoBehaviour:
m_ReadOnly: 0
m_SerializedLabels: []
FlaggedDuringContentUpdateRestriction: 0
- m_GUID: 7b5e9961dadecea4bba3be6de61909f3
m_Address: CalendarSettings
m_ReadOnly: 0
m_SerializedLabels: []
FlaggedDuringContentUpdateRestriction: 0
- m_GUID: 7e443a969de292045b2224c779d96139
m_Address: Assets/Art/UI/menu_bar_left.png
m_ReadOnly: 0

View File

@@ -1,3 +1,4 @@
using Jovian.Calendar;
using Jovian.PopupSystem;
using Jovian.PopupSystem.UI;
using Jovian.SaveSystem;
@@ -125,14 +126,16 @@ namespace Nox.Game {
partyInventoryHandler ??= new PartyInventoryHandler(adventureData, adventureSettings);
partyInventoryHandler.Initialize();
timeHandler ??= new TimeHandler(adventureSettings, adventureData);
var calendarSettings = Addressables.LoadAssetAsync<CalendarSettings>("CalendarSettings").WaitForCompletion();
var worldClock = new WorldClock(calendarSettings);
timeHandler ??= new TimeHandler(adventureSettings, adventureData, worldClock);
zoneSystem ??= new ZoneSystem(mapRef.zonesObjectHolder);
partyMovementHandler ??= new PartyMovementHandler(partyRef, cameraController, mapLocationsReference, platformSettings.inputSettings, zoneSystem, adventureData, adventureSettings);
partyMovementHandler.Initialize();
guiReferences ??= Object.FindFirstObjectByType<GuiReferences>();
adventureView ??= new AdventureView(gameDataState, guiReferences, inputActions, adventureData, adventureSettings);
adventureView ??= new AdventureView(gameDataState, guiReferences, inputActions, adventureData, adventureSettings, worldClock);
adventureView.Initialize();
if(partyGuiView == null && guiReferences.partyMemberSlotPrefab != null) {

View File

@@ -1,3 +1,4 @@
using System;
using UnityEngine;
namespace Nox.Game {

View File

@@ -1,3 +1,4 @@
using Jovian.Calendar;
using UnityEngine;
namespace Nox.Game {
@@ -13,6 +14,7 @@ namespace Nox.Game {
public class TimeHandler {
private readonly AdventureSettings adventureSettings;
private readonly AdventureData adventureData;
private readonly WorldClock worldClock;
private float localTime;
@@ -23,34 +25,44 @@ namespace Nox.Game {
(0.25f, DayPhase.Morning),
(0.50f, DayPhase.Afternoon),
(0.75f, DayPhase.Dusk),
(0.90f, DayPhase.Night),
(0.90f, DayPhase.Night)
};
public TimeHandler(AdventureSettings adventureSettings, AdventureData adventureData) {
public TimeHandler(AdventureSettings adventureSettings, AdventureData adventureData, WorldClock worldClock) {
this.adventureSettings = adventureSettings;
this.adventureData = adventureData;
this.worldClock = worldClock;
localTime = adventureData.currentTime * adventureSettings.dayLength;
}
public void Tick() {
if (!adventureData.isPartyMoving) return;
if(!adventureData.isPartyMoving) {
return;
}
localTime += Time.deltaTime;
if (localTime >= adventureSettings.dayLength) {
if(localTime >= adventureSettings.dayLength) {
localTime -= adventureSettings.dayLength;
adventureData.currentDay++;
}
adventureData.currentTime = localTime / adventureSettings.dayLength;
adventureData.currentDayPhase = GetPhase(adventureData.currentTime);
var normalized = localTime / adventureSettings.dayLength;
worldClock.Tick(normalized);
adventureData.currentTime = normalized;
adventureData.currentDayPhase = GetPhase(normalized);
}
private static DayPhase GetPhase(float t) {
var phase = DayPhase.Midnight;
foreach (var (start, p) in PhaseThresholds) {
if (t >= start) phase = p;
else break;
foreach(var (start, p) in PhaseThresholds) {
if(t >= start) {
phase = p;
}
else {
break;
}
}
return phase;
}

View File

@@ -1,3 +1,4 @@
using Jovian.Calendar;
using Nox.Core;
namespace Nox.Game.UI {
@@ -7,20 +8,22 @@ namespace Nox.Game.UI {
private readonly InputSystem_Actions inputActions;
private readonly AdventureData adventureData;
private readonly AdventureSettings adventureSettings;
private DayPhase dayPhase = DayPhase.Midnight;
private readonly WorldClock worldClock;
private int currentDay;
private int previousTime;
public AdventureView(
GameDataState gameDataState,
public AdventureView(GameDataState gameDataState,
GuiReferences guiReferences,
InputSystem_Actions inputActions,
AdventureData adventureData,
AdventureSettings adventureSettings) {
AdventureSettings adventureSettings,
WorldClock worldClock) {
this.gameDataState = gameDataState;
this.guiReferences = guiReferences;
this.inputActions = inputActions;
this.adventureData = adventureData;
this.adventureSettings = adventureSettings;
this.worldClock = worldClock;
}
private void InvokePauseMenu() {
gameDataState.ChangePlayMode(PlayMode.PauseMenu);
@@ -28,7 +31,8 @@ namespace Nox.Game.UI {
public void Initialize() {
guiReferences.pauseMenuButton.onClick.AddListener(InvokePauseMenu);
guiReferences.dayText.text = $"Day {adventureData.currentDay}, {adventureData.currentDayPhase.ToString()}";
guiReferences.dayText.text = $"{worldClock.FullStringNamed()}";
previousTime = -1;
guiReferences.suppliesBar.fillAmount = (float)adventureData.suppliesAvailable / adventureSettings.maxSupplies;
guiReferences.suppliesText.text = $"{adventureData.suppliesAvailable}/{adventureSettings.maxSupplies}";
}
@@ -40,14 +44,14 @@ namespace Nox.Game.UI {
throw new System.NotImplementedException();
}
public void Tick() {
if(dayPhase != adventureData.currentDayPhase) {
dayPhase = adventureData.currentDayPhase;
guiReferences.dayText.text = $"Day {adventureData.currentDay}, {adventureData.currentDayPhase.ToString()}";
var time = worldClock.Now.minute;
if (time != previousTime) {
previousTime = time;
}
guiReferences.dayText.text = $"{worldClock.FullStringNamed()}";
if(currentDay != adventureData.currentDay) {
currentDay = adventureData.currentDay;
guiReferences.dayText.text = $"Day {adventureData.currentDay}, {adventureData.currentDayPhase.ToString()}";
guiReferences.suppliesBar.fillAmount = (float)adventureData.suppliesAvailable / adventureSettings.maxSupplies;
guiReferences.suppliesText.text = $"{adventureData.suppliesAvailable}/{adventureSettings.maxSupplies}";
}

View File

@@ -12,6 +12,8 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 1d2424482c4843c0b7a33a9cc67411b2, type: 3}
m_Name: AdventureSettings
m_EditorClassIdentifier: Assembly-CSharp::Nox.Game.AdventureSettings
startingDate: 2026-04-12
startingTime: 08:00:00
dayLength: 20
maxSupplies: 20
partyBaseSpeed: 0.3

View File

@@ -0,0 +1,29 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e3a6df85a820d0a4db469ae8a20ea773, type: 3}
m_Name: CalendarSettings
m_EditorClassIdentifier: Assembly-CSharp::Nox.Game.CalendarSettings
secondsPerFullDay: 60
hoursPerDay: 24
minutesPerHour: 60
daysPerMonth: 5a0000005a0000005a0000005a000000
monthNames:
- Ashveil
- Thornmere
- Duskhollow
- 'Frosthollow '
daysPerWeek: 7
startYear: 4232
startMonth: 1
startDay: 0
startHour: 8
startMinute: 0

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 7b5e9961dadecea4bba3be6de61909f3
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -680,6 +680,50 @@ PrefabInstance:
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5547799966266031405, guid: ddc1b5dd628590a4084c1997dd102f62, type: 3}
propertyPath: m_fontSize
value: 32.83
objectReference: {fileID: 0}
- target: {fileID: 5547799966266031405, guid: ddc1b5dd628590a4084c1997dd102f62, type: 3}
propertyPath: m_fontSizeMax
value: 32.83
objectReference: {fileID: 0}
- target: {fileID: 5547799966266031405, guid: ddc1b5dd628590a4084c1997dd102f62, type: 3}
propertyPath: m_fontSizeMin
value: 4.7
objectReference: {fileID: 0}
- target: {fileID: 5547799966266031405, guid: ddc1b5dd628590a4084c1997dd102f62, type: 3}
propertyPath: m_enableAutoSizing
value: 1
objectReference: {fileID: 0}
- target: {fileID: 5547799966266031405, guid: ddc1b5dd628590a4084c1997dd102f62, type: 3}
propertyPath: m_HorizontalAlignment
value: 2
objectReference: {fileID: 0}
- target: {fileID: 7031164879444458698, guid: ddc1b5dd628590a4084c1997dd102f62, type: 3}
propertyPath: m_AnchorMin.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7031164879444458698, guid: ddc1b5dd628590a4084c1997dd102f62, type: 3}
propertyPath: m_AnchorMin.y
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: 7031164879444458698, guid: ddc1b5dd628590a4084c1997dd102f62, type: 3}
propertyPath: m_SizeDelta.x
value: -45.73
objectReference: {fileID: 0}
- target: {fileID: 7031164879444458698, guid: ddc1b5dd628590a4084c1997dd102f62, type: 3}
propertyPath: m_SizeDelta.y
value: 60.911
objectReference: {fileID: 0}
- target: {fileID: 7031164879444458698, guid: ddc1b5dd628590a4084c1997dd102f62, type: 3}
propertyPath: m_AnchoredPosition.x
value: -24.619995
objectReference: {fileID: 0}
- target: {fileID: 7031164879444458698, guid: ddc1b5dd628590a4084c1997dd102f62, type: 3}
propertyPath: m_AnchoredPosition.y
value: 2.125
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []