#Instead of instantiating everything in
1 messages · Page 1 of 1 (latest)
oh, cool, I think I see, let me try that
Shoot, that gives me a stack overflow, I wonder if I'm messing something up
If a strategy ever recursively tries to access itself, it would:
get rush -> no rush -> make rush:
rush construct -> get wait -> no wait -> make wait:
wait construct -> get rush !!! recursive construction
Yeah, I think that's what's happening, but unfortunately I do need that to happen, because the state machine is cyclical (which is applicable)
In that case should probably treat it as a graph. create all the strategies first, then connect them to each other in a second step.
public CharacterStrategyFactory() {
_strategyDict = new() {
{"Rush", new CharacterStrategyRush(this)}, // ...
};
foreach (var pair in _strategyDict)
pair.Value.SetTransitions(); // overriden CharacterStrategy method to set _strategyTransitions
}
sorry to send you back to what you had before