jim87
New Member
- Joined
- Aug 26, 2011
- Messages
- 445
- Reaction score
- 7
Hello!
I'm just unsure about the overrides I have to write to make it work as intended. I usually created Decorators within the treesharp behaviors directly (like new Decorator(CanRunDecoratorDelegate func, Composite decorated)), but from a logic-flow point-of-view, it's way better to create meaningfull-named decorators and place them in the behavior root once implemented (IMHO).
I thus created a new Decorator class, and I think I understood some of the overrides, may you explain me the others / correct me if wrong? Thanks
:
I'm just unsure about the overrides I have to write to make it work as intended. I usually created Decorators within the treesharp behaviors directly (like new Decorator(CanRunDecoratorDelegate func, Composite decorated)), but from a logic-flow point-of-view, it's way better to create meaningfull-named decorators and place them in the behavior root once implemented (IMHO).
I thus created a new Decorator class, and I think I understood some of the overrides, may you explain me the others / correct me if wrong? Thanks

PHP:
using TreeSharp;
namespace MyProject.Decorators
{
class DecoratorMyDecorator : Decorator
{
protected override bool CanRun(object context)
{
// used as CanRunDecoratorDelegate func
}
protected override IEnumerable<RunStatus> Execute(object context)
{
// used as Composite decorated? May I return an Action? Should be fine as
// actions return a RunStatus
}
public override void Start(object context)
{
// used when? (Start/Stop)
}
public override RunStatus Tick(object context)
{
// used when?
}
}
}