Skip to content

Commit 2440c0e

Browse files
committed
release soon?
1 parent b2470c9 commit 2440c0e

File tree

18 files changed

+256
-573
lines changed

18 files changed

+256
-573
lines changed

.vitepress/config.mjs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export default defineConfig({
1515
['meta', { name: 'og:type', content: 'website' }],
1616
['meta', { name: 'og:title', content: 'S1API' }],
1717
['meta', { name: 'og:description', content: 'A Schedule One Mono / Il2Cpp Cross Compatibility Layer' }],
18-
['meta', { name: 'og:image', content: '/og-image.png' }],
18+
['meta', { name: 'og:image', content: '/logo.png' }],
1919
['meta', { name: 'twitter:card', content: 'summary_large_image' }],
2020
['meta', { name: 'twitter:title', content: 'S1API' }],
2121
['meta', { name: 'twitter:description', content: 'A Schedule One Mono / Il2Cpp Cross Compatibility Layer' }]
@@ -109,6 +109,11 @@ export default defineConfig({
109109
level: 'deep',
110110
label: 'On this page'
111111
},
112+
113+
editLink: {
114+
pattern: 'https://github.com/ifBars/S1API-docs/edit/dev/.vitepress/docs/:path',
115+
text: 'Help improve this page'
116+
},
112117

113118
// i18n support (if needed in the future)
114119
i18n: {

.vitepress/docs/api/dead-drops/index.md

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,4 @@ if (deadDrop != null)
104104
// Now you can use StorageInstance methods to interact with items
105105
// (See StorageInstance documentation for details)
106106
}
107-
```
108-
109-
## Best Practices
110-
111-
1. Always check if a dead drop exists before attempting to access its properties
112-
2. For quest-related features, associate dead drops with quest objectives using their GUID
113-
3. When finding nearby dead drops, consider using a reasonable search radius to avoid performance issues
114-
4. Consider caching dead drop references that you'll use frequently instead of searching every time
115-
5. Use the storage system appropriately for adding or removing items from dead drops
107+
```
Lines changed: 95 additions & 206 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Game Time API
22

3-
The Game Time API provides tools for working with and manipulating in-game time, including day/night cycles, seasons, and time-based events.
3+
The Game Time API provides tools for working with and manipulating in-game time.
44

55
## Namespace
66

@@ -10,249 +10,138 @@ using S1API.GameTime;
1010

1111
## Key Classes
1212

13-
### GameClock
13+
### Day
1414

15-
The main class for accessing and controlling the game's time system.
15+
Enum representing days of the week.
1616

1717
```csharp
18-
public static class GameClock
18+
public enum Day
1919
{
20-
// Current time properties
21-
public static int Hour { get; }
22-
public static int Minute { get; }
23-
public static int Day { get; }
24-
public static int Month { get; }
25-
public static int Year { get; }
26-
public static Season CurrentSeason { get; }
27-
public static WeatherType CurrentWeather { get; }
28-
public static DayPhase CurrentDayPhase { get; }
29-
public static bool IsNight { get; }
30-
31-
// Time flow control
32-
public static float TimeScale { get; set; }
33-
public static bool IsPaused { get; }
34-
35-
// Methods
36-
public static void AdvanceTime(int hours = 0, int minutes = 0, int days = 0);
37-
public static void PauseTime();
38-
public static void ResumeTime();
39-
public static float GetDayProgress(); // 0.0 to 1.0 representing progress through the day
40-
public static TimeSpan GetTimeUntil(int hour, int minute);
41-
public static void SetTime(int hour, int minute);
42-
public static void SetDate(int day, int month, int year);
43-
44-
// Formatted time strings
45-
public static string GetTimeString(bool use24HourFormat = false);
46-
public static string GetDateString(string format = "d MMM yyyy");
20+
Monday,
21+
Tuesday,
22+
Wednesday,
23+
Thursday,
24+
Friday,
25+
Saturday,
26+
Sunday
4727
}
4828
```
4929

50-
### Season
30+
### GameDateTime
5131

52-
Enum representing seasons in the game.
32+
Represents an in-game datetime (elapsed days and 24-hour time).
5333

5434
```csharp
55-
public enum Season
35+
public struct GameDateTime
5636
{
57-
Spring,
58-
Summer,
59-
Fall,
60-
Winter
61-
}
62-
```
63-
64-
### DayPhase
65-
66-
Enum representing different phases of the day.
67-
68-
```csharp
69-
public enum DayPhase
70-
{
71-
Dawn,
72-
Morning,
73-
Noon,
74-
Afternoon,
75-
Dusk,
76-
Evening,
77-
Midnight
78-
}
79-
```
80-
81-
### WeatherType
82-
83-
Enum representing different weather conditions.
84-
85-
```csharp
86-
public enum WeatherType
87-
{
88-
Clear,
89-
Cloudy,
90-
Rainy,
91-
Stormy,
92-
Foggy,
93-
Snowy
94-
}
95-
```
96-
97-
### TimeEvent
98-
99-
A class for scheduling events at specific times.
100-
101-
```csharp
102-
public class TimeEvent
103-
{
104-
public string EventID { get; }
105-
public string Description { get; set; }
106-
public bool IsRecurring { get; set; }
107-
public TimeSpan RecurrenceInterval { get; set; }
37+
public int ElapsedDays;
38+
public int Time;
10839

109-
public TimeEvent(string eventID, string description, DateTime triggerTime);
110-
public TimeEvent(string eventID, string description, int hour, int minute, bool triggerToday = true);
40+
// Constructors
41+
public GameDateTime(int elapsedDays, int time);
42+
public GameDateTime(int minSum);
11143

112-
public void SetRecurring(TimeSpan interval);
113-
public void SetRecurringDaily(int hour, int minute);
114-
public void SetRecurringWeekly(DayOfWeek day, int hour, int minute);
115-
public void Cancel();
44+
// Methods
45+
public int GetMinSum();
46+
public GameDateTime AddMinutes(int minutes);
47+
public string GetFormattedTime();
48+
public bool IsNightTime();
49+
public bool IsSameDay(GameDateTime other);
50+
public bool IsSameTime(GameDateTime other);
51+
public override string ToString();
52+
53+
// Operators
54+
public static GameDateTime operator +(GameDateTime a, GameDateTime b);
55+
public static GameDateTime operator -(GameDateTime a, GameDateTime b);
56+
public static bool operator >(GameDateTime a, GameDateTime b);
57+
public static bool operator <(GameDateTime a, GameDateTime b);
11658
}
11759
```
11860

119-
### TimeEventManager
61+
### TimeManager
12062

121-
Static class for managing time-based events.
63+
Provides access to various time management functions in the game.
12264

12365
```csharp
124-
public static class TimeEventManager
66+
public static class TimeManager
12567
{
126-
public static event Action<TimeEvent> OnEventTriggered;
68+
// Events
69+
public static Action OnDayPass;
70+
public static Action OnWeekPass;
71+
public static Action OnSleepStart;
72+
public static Action<int> OnSleepEnd;
12773

128-
public static void RegisterEvent(TimeEvent timeEvent);
129-
public static void UnregisterEvent(string eventID);
130-
public static TimeEvent GetEvent(string eventID);
131-
public static List<TimeEvent> GetUpcomingEvents(int maxCount = 10);
74+
// Properties
75+
public static Day CurrentDay { get; }
76+
public static int ElapsedDays { get; }
77+
public static int CurrentTime { get; }
78+
public static bool IsNight { get; }
79+
public static bool IsEndOfDay { get; }
80+
public static bool SleepInProgress { get; }
81+
public static bool TimeOverridden { get; }
82+
public static float NormalizedTime { get; }
83+
public static float Playtime { get; }
84+
85+
// Methods
86+
public static void FastForwardToWakeTime();
87+
public static void SetTime(int time24h, bool local = false);
88+
public static void SetElapsedDays(int days);
89+
public static string GetFormatted12HourTime();
90+
public static bool IsCurrentTimeWithinRange(int startTime24h, int endTime24h);
91+
public static int GetMinutesFrom24HourTime(int time24h);
92+
public static int Get24HourTimeFromMinutes(int minutes);
13293
}
13394
```
13495

13596
## Usage Examples
13697

137-
### Basic Time Manipulation
98+
### Working with GameDateTime
13899

139100
```csharp
140-
// Get current time information
141-
int currentHour = GameClock.Hour;
142-
int currentMinute = GameClock.Minute;
143-
string timeString = GameClock.GetTimeString(); // e.g. "3:45 PM"
144-
string dateString = GameClock.GetDateString(); // e.g. "15 Jun 2025"
145-
146-
// Check time conditions
147-
bool isNighttime = GameClock.IsNight;
148-
bool isWinter = GameClock.CurrentSeason == Season.Winter;
149-
bool isStormy = GameClock.CurrentWeather == WeatherType.Stormy;
150-
151-
Console.WriteLine($"It's {timeString} on {dateString}");
152-
Console.WriteLine($"Current day phase: {GameClock.CurrentDayPhase}");
153-
154-
// Manipulate time
155-
GameClock.AdvanceTime(hours: 2, minutes: 30); // Advance 2.5 hours
156-
GameClock.SetTime(18, 0); // Set time to 6:00 PM
157-
```
158-
159-
### Time Flow Control
101+
// Create a new game date time (day 3, 2:30 PM)
102+
GameDateTime dateTime = new GameDateTime(3, 1430);
160103

161-
```csharp
162-
// Speed up time (2x normal speed)
163-
GameClock.TimeScale = 2.0f;
104+
// Add 60 minutes
105+
GameDateTime later = dateTime.AddMinutes(60);
164106

165-
// Pause time for a cutscene
166-
GameClock.PauseTime();
107+
// Check if it's night time
108+
bool isNight = dateTime.IsNightTime();
167109

168-
// Resume normal time flow
169-
GameClock.ResumeTime();
170-
GameClock.TimeScale = 1.0f;
110+
// Format the time
111+
string timeString = dateTime.GetFormattedTime(); // e.g., "2:30 PM"
171112
172-
// Skip to morning
173-
if (GameClock.IsNight)
174-
{
175-
// Calculate hours until 7:00 AM
176-
var hoursUntilMorning = GameClock.GetTimeUntil(7, 0).TotalHours;
177-
GameClock.AdvanceTime(hours: (int)hoursUntilMorning);
178-
}
113+
// Compare game date times
114+
bool sameDay = dateTime.IsSameDay(later);
115+
bool laterInTime = later > dateTime;
179116
```
180117

181-
### Scheduling Time Events
118+
### Using TimeManager
182119

183120
```csharp
184-
// Create a one-time event for shop closing
185-
var shopClosingEvent = new TimeEvent(
186-
"mymod.shop_closing",
187-
"Local shop closes for the night",
188-
hour: 20,
189-
minute: 0,
190-
triggerToday: true
191-
);
192-
193-
// Register the event
194-
TimeEventManager.RegisterEvent(shopClosingEvent);
121+
// Get current day and time information
122+
Day today = TimeManager.CurrentDay;
123+
int currentTime = TimeManager.CurrentTime;
124+
bool isNightTime = TimeManager.IsNight;
125+
float dayProgress = TimeManager.NormalizedTime; // 0.0 to 1.0
195126
196-
// Create a recurring daily event for shop opening
197-
var shopOpeningEvent = new TimeEvent(
198-
"mymod.shop_opening",
199-
"Local shop opens for the day",
200-
hour: 8,
201-
minute: 0
202-
);
203-
shopOpeningEvent.SetRecurringDaily(8, 0);
127+
// Format current time
128+
string timeString = TimeManager.GetFormatted12HourTime(); // e.g., "2:30 PM"
204129
205-
// Register the event
206-
TimeEventManager.RegisterEvent(shopOpeningEvent);
130+
// Check time conditions
131+
bool isOpeningHours = TimeManager.IsCurrentTimeWithinRange(900, 1700); // 9 AM to 5 PM
207132
208-
// Listen for events
209-
TimeEventManager.OnEventTriggered += (timeEvent) => {
210-
if (timeEvent.EventID == "mymod.shop_closing")
211-
{
212-
// Handle shop closing
213-
CloseShop();
214-
DisplayNotification("The shop has closed for the night!");
215-
}
216-
else if (timeEvent.EventID == "mymod.shop_opening")
217-
{
218-
// Handle shop opening
219-
OpenShop();
220-
DisplayNotification("The shop is now open!");
221-
}
133+
// Manipulate time
134+
TimeManager.SetTime(1800); // Set to 6:00 PM
135+
TimeManager.SetElapsedDays(10); // Set to day 10
136+
TimeManager.FastForwardToWakeTime(); // Skip to 7 AM
137+
138+
// Subscribe to time events
139+
TimeManager.OnDayPass += () => {
140+
// Handle new day starting
141+
Console.WriteLine("A new day has begun!");
222142
};
223143

224-
// Get upcoming events
225-
var upcomingEvents = TimeEventManager.GetUpcomingEvents(5);
226-
foreach (var evt in upcomingEvents)
227-
{
228-
Console.WriteLine($"Upcoming: {evt.Description}");
229-
}
230-
```
231-
232-
## Events
233-
234-
The Game Time API provides events to hook into time changes:
235-
236-
```csharp
237-
// Time changes
238-
GameClock.OnHourChanged += (oldHour, newHour) => { /* ... */ };
239-
GameClock.OnDayChanged += (oldDay, newDay) => { /* ... */ };
240-
GameClock.OnSeasonChanged += (oldSeason, newSeason) => { /* ... */ };
241-
242-
// Day/night cycle
243-
GameClock.OnDayPhaseChanged += (oldPhase, newPhase) => { /* ... */ };
244-
GameClock.OnNightBegin += () => { /* ... */ };
245-
GameClock.OnDayBegin += () => { /* ... */ };
246-
247-
// Weather changes
248-
GameClock.OnWeatherChanged += (oldWeather, newWeather) => { /* ... */ };
249-
```
250-
251-
## Best Practices
252-
253-
1. Use the GameClock for all time-related operations rather than implementing your own time system
254-
2. Consider performance when scheduling many recurring events
255-
3. Be mindful of time scale changes and how they affect gameplay
256-
4. Use time events for scheduling rather than continuously checking time conditions
257-
5. When advancing time, consider the impact on scheduled events and NPC schedules
258-
6. Use the day/night and season events to adjust your mod's behavior appropriately
144+
TimeManager.OnSleepEnd += (minutesSlept) => {
145+
Console.WriteLine($"Good morning! You slept for {minutesSlept/60} hours.");
146+
};
147+
```

0 commit comments

Comments
 (0)