P3R.CalendarUtils.Interfaces
1.0.0
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package P3R.CalendarUtils.Interfaces --version 1.0.0
NuGet\Install-Package P3R.CalendarUtils.Interfaces -Version 1.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="P3R.CalendarUtils.Interfaces" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add P3R.CalendarUtils.Interfaces --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: P3R.CalendarUtils.Interfaces, 1.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install P3R.CalendarUtils.Interfaces as a Cake Addin #addin nuget:?package=P3R.CalendarUtils.Interfaces&version=1.0.0 // Install P3R.CalendarUtils.Interfaces as a Cake Tool #tool nuget:?package=P3R.CalendarUtils.Interfaces&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
P3R Calendar Utilities Interface
Overview
This package will allow you to implement time-dependent changes into your Persona 3 Reload mod by registering Date Actions with the main P3R.CalendarUtils
mod.
Setup
- Go into your
ModConfig.json
file and add the following to the"ModDependencies"
array:P3R.CalendarUtils
. - In your
Mod.cs
file add the following code (or something similar): In yourusing
list:
using P3R.CalendarUtils.Interfaces.Types;```
_Above your ``public Mod(ModContext)`` declaration:__
```csharp private ICalendarMethods _calendarMethods;```
_Inside the declaration:__
```csharp public Mod(ModContext)
{
/// Standard reloaded code
...
var calendarController = _modLoader.GetController<ICalendarMethods>();
if (calendarController == null || !calendarController.TryGetTarget(out var calendarMethods))
throw new Exception($[{_modConfig.ModName}] Could not get controller for \"{modName}\". This depedency is likely missing.");)
_calendarMethods = calendarMethods;
...
/// Things like loading files via UnrealEssentials
...
_modLoader.OnModLoaderInitialized += OnAllModsLoaded;
}```
## Implementation
3. Set up the actions that will be called by __P3R Calendar Utilities__. For this example let's create something to check if the player has reached September.
*. _Below your ``Mod(ModContext)`` block, define your actions like so:__
```csharp private Action IfSeptember;
private Action IfNotSeptember;```
*. _Now define your ``OnAllModsLoaded`` method;
```csharp private void OnAllModsLoaded()
{
IfSeptember = () => { /* Any changes to be done when it is September */ };
IfNotSeptember = () => { /* Code to revert the above changes to their default states */ };
_calendarMethods.RegisterAction(new(IfSeptember, IfNotSeptember, DateOperation.During, new(2009, 09, 01), new(2009, 09, 30)))
}```
*. The three ``new`` declarations define in the following order: the ``DateAction``, the starting ``P3Date``, and the ending ``P3Date``. In the following sections I will give an overview of these types.
### DateAction
A ``DateAction`` is a structure that defines any time-dependent method/action. __All__ date actions require the following arguments:
1. An ``ApplyAction`` - the actual action that applies any change a given ``DateAction`` controls.
2. A ``RevertAction`` - as the name implies this is the opposite of the ``ApplyAction``
3. A ``DateOperation`` type - this is an enum value that controls how the ``DateAction`` is processed.
*. ``DateOperation.After`` tells __P3R Calendar Utilities__ to invoke the ``ApplyAction`` once the current game session _proceeds past_ a specified ``P3Date`` trigger, if the player loads a save from before this date the ``RevertAction`` is invoked.
*. ``DateOperation.Before`` tells __P3R Calendar Utilities__ to invoke the ``ApplyAction`` if the current game session _has not yet reached_ a specified ``P3Date`` trigger, if the player loads a save from after this date the ``RevertAction`` is invoked. _Note: It will be reapplied if the load a third save that's before the date._
*. ``DateOperation.During`` tells __P3R Calendar Utilities__ to invoke the ``ApplyAction`` when the current game session first reaches the specified time frame trigger. Once the game leaves it, the ``RevertAction`` is invoked.
*. ``DateOperation.On`` tells __P3R Calendar Utilities__ to invoke the ``ApplyAction`` only if the current game session is on a specified ``P3Date``. If the in-game date no longer equals the trigger, the ``RevertAction`` is invoked.
4. A ``P3Date Start``, the main trigger that __P3R Calendar Utilities__ checks against.
If you are defining a ``DateOperation.During`` action you also need a ``P3Date End`` argument to tell __P3R Calendar Utilities__ when the changes need to be reverted. They will always be reverted if a player loads a save from before the defined time frame.
_Note: During actions are the only inclusive type, meaning they are triggered ON the start day instead of the day after. Likewise they automatically revert the day after the end day.
### P3Date
The ``P3Date`` struct is an extension of the standard ``DateOnly`` made specifically for Persona 3 Reload. It converts the internal daycount (as defined by the ``GlobalWork.Calendar.DaysSinceApril1`` value) to its equivalent number of days since January 1, 0001 in the Proleptic Gregorian calendar, using April 1, 2009 as an epoch.
This allows you to define dates in a user friendly way, in fact it's the same way you would a ``DateOnly``:
```csharp public P3Date(int year, int month, int day)```
So before when I defined the trigger in ``_calendarMethods.RegisterAction(new(IfSeptember, IfNotSeptember, DateOperation.During, new(2009, 09, 01), new(2009, 09, 30)))`` our start date would be September 1, 2009 and our end is September 30, 2009.
##Conclusion
Once you register your ``DateAction`` the main mod will handle all the logic, and invoke or revert your changes accordingly.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- P3R.CalendarAPI (>= 1.0.0)
- p3rpc.nativetypes.Interfaces (>= 1.4.5)
- Unreal.ObjectsEmitter.Interfaces (>= 1.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.