Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Refactor, add a generic helper for creating delayed actions with saveable progression #48

Open
ReveredRedHood opened this issue Oct 5, 2024 · 0 comments
Labels
common Related to the SOD.Common library. feature New feature implementation.

Comments

@ReveredRedHood
Copy link
Collaborator

ReveredRedHood commented Oct 5, 2024

Introduction

Description of the feature
Consider making a more generic helper for "create a delayed action that accounts for game state, and which also saves and loads partial progression successfully". It seems like a helpful utility in general, and we have two use cases already with illegal status modifiers and input suppression entries.

Feature usage
Plugins would use it to simplify handling persistent states. It would be useful any time a mod wants to temporarily change the state of something which, if that state change is not persisted across saving and loading, would cause broken functionality.

Dependencies and Prerequisites
None

Implementation details
Might look like this (or maybe it would be named something like PersistentState):

public abstract class GameTimeAwareAction {
  // time tracking instance properties go here...
  // Start, Stop, Pause, and Tick are implemented methods in the abstract class
  public abstract string GetUniqueString();
  public abstract string GetSavestorePathPrefix();
  public abstract string GetStateAsJson();
  public abstract void LoadStateFromJson(string json);
  public abstract void OnAfterStarted();
  public abstract void OnAfterTicked(deltaTime, timeSinceStarted, duration);
  public abstract void OnAfterExpiration();
}
// In a helper library elsewhere...
public GameTimeAwareAction CreateGameTimeAwareAction(...); // not sure of the params here, might involve plugin metadata
public List<GameTimeAwareAction> GetGameTimeAwareActions(predicate);

SOD.Common would handle saving and loading for the mods, like it does now with illegal status modifiers.

@ReveredRedHood ReveredRedHood added feature New feature implementation. common Related to the SOD.Common library. labels Oct 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
common Related to the SOD.Common library. feature New feature implementation.
Projects
None yet
Development

No branches or pull requests

1 participant