11#include <unordered_map>
42 void setEntry(
const std::string &
name);
44 bool hasState(
const std::string &
name)
const;
54 int addTransition(
const std::string &
from,
const std::string &
to,
float blendSeconds);
57 void addFloatCondition(
int transitionId,
const std::string ¶m,
const std::string &op,
60 void addBoolCondition(
int transitionId,
const std::string ¶m,
bool value);
62 void addTriggerCondition(
int transitionId,
const std::string ¶m);
64 void setExitTime(
int transitionId,
float normalizedTime);
66 void setHasExitTime(
int transitionId,
bool enabled);
69 void setFloat(
const std::string &
name,
float value);
71 float getFloat(
const std::string &
name)
const;
73 void setBool(
const std::string &
name,
bool value);
75 bool getBool(
const std::string &
name)
const;
77 void setTrigger(
const std::string &
name);
79 void resetTrigger(
const std::string &
name);
82 auto it = triggers_.find(
name);
83 return it != triggers_.end() && it->second;
102 [[nodiscard]]
bool hasCurrentTick() const noexcept
override {
return hasLastTick_; }
105 void update(
float dt);
115 bool restoreState(
const StateValue& in, std::string* err =
nullptr);
118 bool resetToDefaults();
121 enum class CondKind {
Float,
Bool, Trigger };
122 enum class FloatOp { Gt, Ge, Lt, Le, Eq, Ne };
125 CondKind
kind = CondKind::Float;
127 FloatOp op = FloatOp::Gt;
128 float threshold = 0.f;
129 bool boolValue =
true;
135 float blendSeconds = 0.2f;
136 bool hasExitTime =
false;
137 float exitTime = 0.f;
138 std::vector<Condition> conditions;
143 AnimClip *
clip =
nullptr;
146 void requireState(
const std::string &
name)
const;
148 static FloatOp parseFloatOp(
const std::string &op);
149 bool conditionsMet(
const Transition &
tr)
const;
150 bool tryTransition();
151 void updateUnchecked(
float dt);
153 AnimSkeleton *skeleton_ =
nullptr;
158 std::unordered_map<std::string, State> states_;
159 std::vector<std::string> stateOrder_;
160 std::vector<Transition> transitions_;
162 std::unordered_map<std::string, float> floats_;
163 std::unordered_map<std::string, bool> bools_;
164 std::unordered_map<std::string, bool> triggers_;
166 std::string currentState_;
167 std::string nextState_;
168 float stateTime_ = 0.f;
169 float blendDuration_ = 0.f;
170 float blendElapsed_ = 0.f;
171 bool blending_ =
false;
172 bool started_ =
false;
174 bool hasLastTick_ =
false;
#define EVENGINE_API_WORLD
HexCoordinates to
Cell the unit walks towards on this segment.
Common time values and an injectable deterministic simulation clock.
Move-only operation result carrying either a value or Status.
JSON-compatible state value tree used by state hot reload.
Keyframed skeletal animation clip (local TRS tracks per bone). Script type: AnimClip.
Evaluated local (and optional world) pose for an AnimSkeleton. Script type: AnimPose.
3D bone hierarchy + bind-pose local TRS for skeletal animation. Independent of ik::Skeleton3D (FABRIK...
Clip-driven animation state machine with float/bool/trigger parameters and cross-fade transitions....
bool hasCurrentTick() const noexcept override
Whether advance has consumed at least one checked step.
std::string getCurrentState() const
Returns the current state.
eve::SimulationTick currentTick() const noexcept override
Last scheduler tick consumed by the checked state-machine API.
bool getTrigger(const std::string &name) const
Query a trigger's current state.
float getStateTime() const
Returns the state time.
int getStateCount() const
Returns the state count.
AnimStateMachine(const AnimStateMachine &)=delete
AnimStateMachine & operator=(const AnimStateMachine &)=delete
AnimSkeleton * getSkeleton() const override
Borrowed pointer accessor. @ownership Borrowed @lifetime Valid while the owning animation object rema...
bool isBlending() const
True when blending.
Borrowed pose provider consumed by AnimLayerMixer.
static constexpr StrongUint64 zero() noexcept
Returns the zero value for this strong type.
State
Lifecycle state of a generic transaction plan.
enum EVENGINE_API_FOUNDATION Float
OT_FLOAT.
enum EVENGINE_API_FOUNDATION Bool
OT_BOOL.
One deterministic fixed-step emitted by SimulationClock.