Switched scene update to state event

This commit is contained in:
2023-03-01 09:40:57 -08:00
parent 6aa7d317d1
commit 1061cda666
10 changed files with 438 additions and 473 deletions

View File

@ -22,10 +22,10 @@ void AnimationController::addAnimation(Animation *animation) {
void AnimationController::onStart() {
SceneItemComponent::onStart();
useEventLegacy([&]{
useEvent([&](float_t delta){
auto it = this->animations.begin();
while(it != this->animations.end()) {
(*it)->tick(this->getGame()->timeManager.delta);
(*it)->tick(delta);
++it;
}
}, getScene()->eventSceneUnpausedUpdate);

View File

@ -28,11 +28,11 @@ ExampleSpin::ExampleSpin(SceneItem *item) :
}
void ExampleSpin::onStart() {
useEventLegacy([&]{
useEvent([&](float_t delta){
auto quat = this->transform->getLocalRotation();
quat = glm::rotate(quat, getGame()->timeManager.delta, glm::vec3(0, 1, 0));
quat = glm::rotate(quat, getGame()->timeManager.delta / 2.0f, glm::vec3(1, 0, 0));
quat = glm::rotate(quat, getGame()->timeManager.delta / 4.0f, glm::vec3(0, 0, 1));
quat = glm::rotate(quat, delta, glm::vec3(0, 1, 0));
quat = glm::rotate(quat, delta / 2.0f, glm::vec3(1, 0, 0));
quat = glm::rotate(quat, delta / 4.0f, glm::vec3(0, 0, 1));
this->transform->setLocalRotation(quat);
}, getScene()->eventSceneUnpausedUpdate);
}

View File

@ -14,13 +14,13 @@ SubSceneController::SubSceneController(SceneItem *i) : SceneItemComponent(i) {
void SubSceneController::onStart() {
auto myScene = this->getScene();
useEventLegacy([&]{
useEvent([&](float_t d){
if(!this->onlyUpdateUnpaused) return;
if(this->subScene == nullptr) return;
this->subScene->update();
}, myScene->eventSceneUnpausedUpdate);
useEventLegacy([&]{
useEvent([&](float_t d){
if(this->onlyUpdateUnpaused) return;
if(this->subScene == nullptr) return;
this->subScene->update();

View File

@ -67,7 +67,7 @@ void UICanvas::onStart() {
}, this->currentMenu);
// Scene Update
useEventLegacy([&]{
useEvent([&](float_t delta){
if(this->currentMenu == nullptr) return;
this->currentMenu->onTick();
}, getScene()->eventSceneUpdate);