diff options
Diffstat (limited to 'src/systems/realizing.cpp')
-rw-r--r-- | src/systems/realizing.cpp | 33 |
1 files changed, 9 insertions, 24 deletions
diff --git a/src/systems/realizing.cpp b/src/systems/realizing.cpp index 7f5aefb..baacf5a 100644 --- a/src/systems/realizing.cpp +++ b/src/systems/realizing.cpp | |||
@@ -12,6 +12,7 @@ | |||
12 | #include "components/ponderable.h" | 12 | #include "components/ponderable.h" |
13 | #include "components/transformable.h" | 13 | #include "components/transformable.h" |
14 | #include "components/prototypable.h" | 14 | #include "components/prototypable.h" |
15 | #include "components/automatable.h" | ||
15 | #include "systems/mapping.h" | 16 | #include "systems/mapping.h" |
16 | #include "systems/animating.h" | 17 | #include "systems/animating.h" |
17 | #include "systems/pondering.h" | 18 | #include "systems/pondering.h" |
@@ -223,7 +224,10 @@ RealizingSystem::RealizingSystem( | |||
223 | 224 | ||
224 | if (prototypeId == "movplat") | 225 | if (prototypeId == "movplat") |
225 | { | 226 | { |
226 | prototypable.hasBehavior = true; | 227 | auto& automatable = game_.getEntityManager(). |
228 | emplaceComponent<AutomatableComponent>(mapObject); | ||
229 | |||
230 | automatable.table = prototypeId; | ||
227 | } else if (prototypeId == "checkpoint") | 231 | } else if (prototypeId == "checkpoint") |
228 | { | 232 | { |
229 | auto& ponderable = game_.getEntityManager(). | 233 | auto& ponderable = game_.getEntityManager(). |
@@ -403,19 +407,9 @@ void RealizingSystem::enterActiveMap(id_type entity) | |||
403 | ponderable.active = true; | 407 | ponderable.active = true; |
404 | } | 408 | } |
405 | 409 | ||
406 | if (game_.getEntityManager().hasComponent<PrototypableComponent>(entity)) | 410 | if (game_.getEntityManager().hasComponent<AutomatableComponent>(entity)) |
407 | { | 411 | { |
408 | auto& prototypable = game_.getEntityManager(). | 412 | game_.getSystemManager().getSystem<ScriptingSystem>().startBehavior(entity); |
409 | getComponent<PrototypableComponent>(entity); | ||
410 | |||
411 | if (prototypable.hasBehavior) | ||
412 | { | ||
413 | auto& scripting = game_.getSystemManager().getSystem<ScriptingSystem>(); | ||
414 | |||
415 | prototypable.hasBehavior = true; | ||
416 | prototypable.runningBehavior = true; | ||
417 | prototypable.behaviorScript = scripting.runBehaviorScript(entity); | ||
418 | } | ||
419 | } | 413 | } |
420 | } | 414 | } |
421 | 415 | ||
@@ -437,17 +431,8 @@ void RealizingSystem::leaveActiveMap(id_type entity) | |||
437 | ponderable.active = false; | 431 | ponderable.active = false; |
438 | } | 432 | } |
439 | 433 | ||
440 | if (game_.getEntityManager().hasComponent<PrototypableComponent>(entity)) | 434 | if (game_.getEntityManager().hasComponent<AutomatableComponent>(entity)) |
441 | { | 435 | { |
442 | auto& prototypable = game_.getEntityManager(). | 436 | game_.getSystemManager().getSystem<ScriptingSystem>().stopBehavior(entity); |
443 | getComponent<PrototypableComponent>(entity); | ||
444 | |||
445 | if (prototypable.runningBehavior) | ||
446 | { | ||
447 | auto& scripting = game_.getSystemManager().getSystem<ScriptingSystem>(); | ||
448 | scripting.killScript(prototypable.behaviorScript); | ||
449 | |||
450 | prototypable.runningBehavior = false; | ||
451 | } | ||
452 | } | 437 | } |
453 | } | 438 | } |