API
Assembly: Spark.Rules Interface: IRulesPlugin Implementation: RulesPlugin
Interface
public interface IRulesPlugin
{
// Query
List<RuleEntry> GetAllRuleEntries();
RuleEntry GetRuleEntry(string id);
RuleEntry GetRuleEntryByKey(string key);
// GameObject target
bool GetRuleValue(GameObject target, string key);
void SetRuleValue(GameObject target, string key, bool value);
Dictionary<string, bool> GetAllRuleValues(GameObject target);
void ApplyRuleModification(GameObject target, string key, bool value,
float duration, string sourceId, int priority);
void RemoveRuleModifications(GameObject target, string sourceId);
// RulesEntity target (same signatures using RulesEntity)
bool GetRuleValue(RulesEntity entity, string key);
void SetRuleValue(RulesEntity entity, string key, bool value);
Dictionary<string, bool> GetAllRuleValues(RulesEntity entity);
void ApplyRuleModification(RulesEntity entity, string key, bool value,
float duration, string sourceId, int priority);
void RemoveRuleModifications(RulesEntity entity, string sourceId);
}RuleEntry
Extends SparkDatabaseEntry. Defines a boolean rule.
key
string
Unique rule identifier (e.g., "CAN_MOVE", "DEAD")
defaultValue
bool
Initial state when no modifications apply
Methods:
RulesEntity
MonoBehaviour that stores and manages rule state on a per-entity basis.
Fields
ruleStates
List<RuleState>
Serialized base rule values
Core Methods
Modification System
Applies a temporary rule override. The highest-priority modification wins when multiple modifications target the same rule. Modifications with duration > 0 auto-expire. Permanent modifications use duration = 0.
Removes all modifications from the given source.
RuleModification struct:
ruleKey
string
Target rule
value
bool
Override value
startTime
float
When applied
duration
float
0 = permanent
sourceId
string
Who applied it
priority
int
Higher wins conflicts
IsExpired
bool
Property: true if past duration
IsPermanent
bool
Property: true if duration is 0
Subscription System
Refresh
Reloads all rules from the database. Useful after runtime database changes.
Built-in Rule Keys
Some rules have special behavior in the framework:
DEAD
When true, blocks UI panel opening
UI_OPENED
Set true/false by GamePanel when any panel opens/closes
ROOT_MOTION
Blocked from becoming true while MOTION_WARP is active
MOTION_WARP
Motion warping state
Internal Behavior
A cleanup coroutine runs every 0.1 seconds to remove expired modifications and recalculate effective rule values.
Usage
Last updated
Was this helpful?
