Spaces:
Runtime error
Runtime error
File size: 1,944 Bytes
00437a9 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
using Photon.Deterministic;
namespace Quantum
{
public abstract unsafe partial class BTDecorator : BTNode
{
[BotSDKHidden] public AssetRefBTNode Child;
protected BTNode _childInstance;
public BTAbort AbortType;
public BTNode ChildInstance
{
get
{
return _childInstance;
}
}
public override BTNodeType NodeType
{
get
{
return BTNodeType.Decorator;
}
}
public override void OnReset(BTParams btParams)
{
base.OnReset(btParams);
OnExit(btParams);
if (_childInstance != null)
_childInstance.OnReset(btParams);
BTManager.OnDecoratorReset?.Invoke(btParams.Entity, Guid.Value);
}
public override void OnExit(BTParams btParams)
{
base.OnExit(btParams);
}
protected override BTStatus OnUpdate(BTParams btParams)
{
if (DryRun(btParams) == true)
{
BTManager.OnDecoratorChecked?.Invoke(btParams.Entity, Guid.Value, true);
if (_childInstance != null)
{
var childResult = _childInstance.RunUpdate(btParams);
if (childResult == BTStatus.Abort)
{
EvaluateAbortNode(btParams);
SetStatus(btParams.Frame, BTStatus.Abort, btParams.Agent);
return BTStatus.Abort;
}
return childResult;
}
return BTStatus.Success;
}
BTManager.OnDecoratorChecked?.Invoke(btParams.Entity, Guid.Value, false);
return BTStatus.Failure;
}
public override bool OnDynamicRun(BTParams btParams)
{
var result = DryRun(btParams);
if (result == false)
{
return false;
}
else if (ChildInstance.NodeType != BTNodeType.Decorator)
{
return true;
}
else
{
return ChildInstance.OnDynamicRun(btParams);
}
}
public override void Loaded(IResourceManager resourceManager, Native.Allocator allocator)
{
base.Loaded(resourceManager, allocator);
// Cache the child
_childInstance = (BTNode)resourceManager.GetAsset(Child.Id);
_childInstance.Parent = this;
}
}
} |