Control modifiers by object
Concord, in the Concordance.Advanced namespace, acts on everything Concordance holds for
one object: its modifiers and its observers, on every member at once.
Act on an owner or a target
Concord reaches an object in one of two ways:
| Method | Description |
|---|---|
Concord.Owner(obj) | The modifiers and observers the object owns, on any member. |
Concord.Target(obj) | The modifiers and observers on the object's members, whoever wrote them. |
using Concordance.Advanced;
Concord.Owner(this).StopModifying(key: buffId); // one buff, on every member
Concord.Target(enemy).StopModifying(m => m.ScriptType == typeof(SlowAura)); // one script's modifiers on the enemy
Both offer StopModifying, StopObserving, Recombine,
HasModifiers, HasObservers, GetModifiers and GetObservers. A
GameObject covers its components and children too, and a type stands for its static members:
Concord.Target(typeof(Time)).
Release pooled objects
A pooled object is deactivated, not destroyed, so its modifiers would outlive its use. Concord.Release
ends them as destroying the object would. Call it when the object returns to the pool, before deactivating it:
ObjectPool<Bullet> pool = new(Create, actionOnRelease: bullet =>
{
Concord.Release(bullet.gameObject);
bullet.gameObject.SetActive(false);
});
Copy an object without its modifiers
Concord.CloneUnmodified copies an object as it would be without its modifiers: each modified member
of the copy holds its base value. The original keeps its modifiers. It takes a
GameObject, a component or a ScriptableObject, copied with Object.Instantiate, or a plain C# object
that implements ICloneable.
Disposing what it returns destroys the copy, so a copy you only read, such as for a save, fits in a
using statement:
using (Concord.CloneUnmodified(stats, out PlayerStats copy))
json = JsonUtility.ToJson(copy);
To keep the copy, ignore the returned object.