Closed matthiashermsen closed 3 years ago
I guess you have these options:
Call the reactive System in your first System:
public sealed class FirstInitSystem : IInitializeSystem
{
private readonly Contexts _contexts;
private readonly TheReactiveSystem s;
public FirstInitSystem(Contexts contexts, TheReactiveSystem s)
{
_contexts = contexts;
}
public void Initialize()
{
_contexts.Game.ReplaceItemAmount(10);
s.Execute();
}
}
static
pure Helper Method you can call on both Systems:
public static class Service {
public int ClampItemAmount(int amount) => amount > 5 ? 5 : amount;
}
interface
and pass it to both ctor
I would go with 2. or 3.
I think I'll go with 3 :)
Hi, given the following example:
There is a unique component describing the amount of items
The first init system sets the value
and imagine the value 10 is too big. This would break the game, the maximum would be 5. (In my project this is not a constant value, it's based on a calculation with different components)
The second init system deals with that value but crashes if that value is invalid. So I would have to make a check before
I could avoid this check by creating a reactive system clamping that value whenever it changes
The problem is that the second init system runs before the reactive system. Of course I could clamp the value in the first init system or make the check in the second init system. But it would be nice to encapsulate this logic.
Is there a way I can activate the reactive system before the second init system runs? Or observe the component with another approach?