fixing small issues to save some resources
This commit is contained in:
parent
b714c6f82d
commit
5077c09d38
@ -7,7 +7,8 @@ template<typename StateOwnerType>
|
|||||||
class StateMachinePool {
|
class StateMachinePool {
|
||||||
public:
|
public:
|
||||||
void RegisterEntity(const std::string &id, StateOwnerType &entity) {
|
void RegisterEntity(const std::string &id, StateOwnerType &entity) {
|
||||||
machines[id] = std::make_unique<StateMachine<StateOwnerType>>(entity, factory);
|
auto machine = std::make_unique<StateMachine<StateOwnerType>>(entity, factory);
|
||||||
|
machines[id] = std::move(machine);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnregisterEntity(const std::string &id) {
|
void UnregisterEntity(const std::string &id) {
|
||||||
|
|||||||
@ -13,8 +13,6 @@ using json = nlohmann::json;
|
|||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
class StateMachine {
|
class StateMachine {
|
||||||
using SharedState = std::shared_ptr<State<T>>;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
StateMachine(T &owner, const StateFactory<T> &factory) : owner(owner), factory(factory) {};
|
StateMachine(T &owner, const StateFactory<T> &factory) : owner(owner), factory(factory) {};
|
||||||
|
|
||||||
|
|||||||
@ -48,18 +48,18 @@ class StateSystem {
|
|||||||
GetPool<T>().Deserialize(j, getEntity);
|
GetPool<T>().Deserialize(j, getEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template <typename T>
|
||||||
void SetStrictTransitions(bool enabled) {
|
void SetStrictTransitions(bool enabled) {
|
||||||
GetPool<T>().SetStrictTransitions(enabled);
|
GetPool<T>().SetStrictTransitions(enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template <typename T>
|
||||||
void SetAutoTransitions(bool enabled) {
|
void SetAutoTransitions(bool enabled) {
|
||||||
GetPool<T>().SetAutoTransitions(enabled);
|
GetPool<T>().SetAutoTransitions(enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
template<typename T>
|
template <typename T>
|
||||||
StateMachinePool<T> &GetPool() const {
|
StateMachinePool<T> &GetPool() const {
|
||||||
static StateMachinePool<T> pool;
|
static StateMachinePool<T> pool;
|
||||||
return pool;
|
return pool;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user