@@ -516,6 +516,58 @@ public class TreeBuilderCustom : BehaviorTreeBuilderBase<TreeBuilderCustom> {
516516
517517### Custom Decorators
518518
519+ Decorators can also be custom written to cut down on repetitive code.
520+
521+ ``` C#
522+ using Adnc .FluidBT .Tasks ;
523+
524+ public class Inverter : DecoratorBase {
525+ protected override TaskStatus OnUpdate () {
526+ if (Child == null ) {
527+ return TaskStatus .Success ;
528+ }
529+
530+ var childStatus = Child .Update ();
531+ var status = childStatus ;
532+
533+ switch (childStatus ) {
534+ case TaskStatus .Success :
535+ status = TaskStatus .Failure ;
536+ break ;
537+ case TaskStatus .Failure :
538+ status = TaskStatus .Success ;
539+ break ;
540+ }
541+
542+ return status ;
543+ }
544+ }
545+ ```
546+
547+ Implementing decorators is a lot like composites and can be done in a more complex manner if desired for more customization.
548+ See the commented area for more details.
549+
550+ ``` C#
551+ using Adnc .FluidBT .Trees ;
552+
553+ public class TreeBuilderCustom : BehaviorTreeBuilderBase <TreeBuilderCustom > {
554+ public TreeBuilderCustom (GameObject owner ) : base (owner ) {
555+ }
556+
557+ public TreeBuilderCustom (string name = " My Custom Decorator" ) {
558+ return ParentTask <CustomDecorator >(name );
559+
560+ // Or you can code this manually if you need more specifics
561+ //
562+ // var parent = new CustomComposite { Name = name };
563+ // _tree.AddNode(Pointer, parent);
564+ // _pointer.Add(parent);
565+ //
566+ // return this;
567+ }
568+ }
569+ ```
570+
519571## Submitting your own actions, conditions, ect
520572
521573Please fill out the following details if you'd like to contribute new code to this project.
0 commit comments