-
Notifications
You must be signed in to change notification settings - Fork 4
2. Helpers
Venomaus edited this page Dec 30, 2023
·
34 revisions
Here you will find an overview of all lib helper implementations.
These can all be accessed via the namespace:
SOD.Common.Lib.{classname}
Contains various helper methods related to displaying messages in-game.
Methods:
- Broadcast: Broadcasts a message on the screen.
- ShowPlayerSpeech: Queues a message on the bottom of the screen resembling the player's internal monologue.
Contains various helper methods and events related to the in-game time.
Events:
- OnGamePaused: Invoked when the game is paused.
- OnGameResumed: Invoked when the game is resumed from a paused state.
- OnMinuteChanged: Invoked when an in-game minute passes.
- OnHourChanged: Invoked when an in-game hour passes.
- OnDayChanged: Invoked when an in-game day passes.
- OnMonthChanged: Invoked when an in-game month passes.
- OnYearChanged: Invoked when an in-game year passes.
- OnTimeInitialized: Invoked once when the time manager is ready to calculate time. (on game load/init)
Structs exposed:
- Time.TimeData: Contains (year, month, day, hour, minute) properties.
Properties:
- IsInitialized: True/False depending if the time manager is ready to calculate time.
- CurrentDateTime: Returns a TimeData struct with all properties filled in.
- CurrentDate: Returns a TimeData struct with only (year, month, day) filled in.
- CurrentDayEnum: Returns the game's SessionData.WeekDay enum of the current week day.
- CurrentMonthEnum: Returns the game's SessionData.Month enum of the current month.
Methods:
- ResumeGame: Resumes a paused game.
- PauseGame: Pauses the game.
Contains various helper methods and events related to the saving and loading the game.
Events:
- OnBeforeSave: Invoked before the game is saved.
- OnAfterSave: Invoked after the game has finished saving.
- OnBeforeLoad: Invoked before a save is loaded.
- OnAfterLoad: Invoked after a save is finished loading.
- OnBeforeDelete: Invoked before a save is deleted.
- OnAfterDelete: Invoked after a save has been deleted.
- OnBeforeNewGame: Invoked when clicking the new game button.
- OnAfterNewGame: Invokved when the new game is loaded. (only for new games)
Methods:
- GetUniqueString(saveFilePath): Returns a unique string (which is the same for the provided path) that can be used to add to your filename.
- GetSavestoreDirectoryPath(assembly): Returns the location path to plugins/YourMod/Savestore where you can store your custom files.
- GetSavestoreDirectoryPath(assembly, fileName): Same as GetSavestoreDirectoryPath(assembly) but also combines a filename with the path.
Example:
var savecode = Lib.SaveGame.GetUniqueString(saveFilePath);
var fileName = $"ModJsonData_{savecode}.json";
return Lib.SaveGame.GetSavestoreDirectoryPath(Assembly.GetExecutingAssembly(), fileName);
Contains various helper methods and events related to the detecting input from the game.
Events:
- OnButtonStateChanged: Invoked when a button is pressed. (both down and up states are known)