feat: Dragonmaw (#1562)

* rigid as heck

* abstract physics creation to separate function

* loading

Update FvRacePillarDServer.cpp

consolidate abcd pillar logic

modularization

Update SimplePhysicsComponent.cpp

Update EntityManager.cpp

Update MovingPlatformComponent.cpp

still need another pass

* geiser works

* columns working finally

* consolidate logic

* constiness

* Update PhantomPhysicsComponent.cpp

* Update PhysicsComponent.cpp

* revert testing code

* add versions info

---------

Co-authored-by: Aaron Kimbre <aronwk.aaron@gmail.com>
This commit is contained in:
David Markowitz
2024-05-10 07:22:26 -07:00
committed by GitHub
parent 07cb19cc30
commit 2ca61c3e57
29 changed files with 611 additions and 214 deletions

View File

@@ -1,6 +1,10 @@
set(DSCRIPTS_SOURCES_AI_RACING_OBJECTS
"RaceImagineCrateServer.cpp"
"RaceImaginePowerup.cpp"
"FvRaceDragon.cpp"
"FvRacePillarServer.cpp"
"FvRacePillarABCServer.cpp"
"FvRacePillarDServer.cpp"
"FvRaceSmashEggImagineServer.cpp"
"RaceSmashServer.cpp"
PARENT_SCOPE)

View File

@@ -0,0 +1,30 @@
#include "FvRaceDragon.h"
#include "RenderComponent.h"
#include "RacingControlComponent.h"
void FvRaceDragon::OnCollisionPhantom(Entity* self, Entity* target) {
if (!target) return;
const auto racingControllers = Game::entityManager->GetEntitiesByComponent(eReplicaComponentType::RACING_CONTROL);
if (racingControllers.empty()) return;
auto* racingControlComponent = racingControllers[0]->GetComponent<RacingControlComponent>();
if (!racingControlComponent) return;
const auto* player = racingControlComponent->GetPlayerData(target->GetObjectID());
if (!player) return;
if (player->lap != m_Lap) return;
const auto dragons = Game::entityManager->GetEntitiesInGroup("dragon");
for (const auto& dragon : dragons) {
if (!dragon || dragon->GetLOT() != this->m_Dragon) continue;
auto* renderComponent = dragon->GetComponent<RenderComponent>();
if (!renderComponent) continue;
renderComponent->PlayAnimation(dragon, m_LapAnimName);
}
Game::entityManager->DestroyEntity(self);
}

View File

@@ -0,0 +1,15 @@
#pragma once
#include "CppScripts.h"
#include <string>
#include <string_view>
class FvRaceDragon : public CppScripts::Script {
public:
FvRaceDragon(const std::string_view lapAnimName, const int32_t lap) : m_LapAnimName(lapAnimName), m_Lap(lap) {}
private:
void OnCollisionPhantom(Entity* self, Entity* target) override;
const std::string m_LapAnimName;
const int32_t m_Lap;
const LOT m_Dragon = 11898;
};

View File

@@ -0,0 +1,34 @@
#include "FvRacePillarABCServer.h"
#include "RenderComponent.h"
#include "RacingControlComponent.h"
void FvRacePillarABCServer::OnCollisionPhantom(Entity* self, Entity* target) {
if (!target) return;
const auto racingControllers = Game::entityManager->GetEntitiesByComponent(eReplicaComponentType::RACING_CONTROL);
if (racingControllers.empty()) return;
auto* racingControlComponent = racingControllers[0]->GetComponent<RacingControlComponent>();
if (!racingControlComponent) return;
const auto* player = racingControlComponent->GetPlayerData(target->GetObjectID());
if (!player || player->lap != 1) return;
PlayAnimation("crumble", "pillars", m_PillarA);
PlayAnimation("roar", "dragon", m_Dragon);
self->AddTimer("PillarBFall", 2.5f);
self->AddTimer("PillarCFall", 3.7f);
self->AddTimer("DeleteObject", 3.8f);
}
void FvRacePillarABCServer::OnTimerDone(Entity* self, std::string timerName) {
if (timerName == "PillarBFall") {
PlayAnimation("crumble", "pillars", m_PillarB);
} else if (timerName == "PillarCFall") {
PlayAnimation("crumble", "pillars", m_PillarC);
} else if (timerName == "DeleteObject") {
Game::entityManager->DestroyEntity(self);
}
}

View File

@@ -0,0 +1,13 @@
#pragma once
#include "CppScripts.h"
#include "FvRacePillarServer.h"
class FvRacePillarABCServer : public FvRacePillarServer {
void OnCollisionPhantom(Entity* self, Entity* target) override;
void OnTimerDone(Entity* self, std::string timerName) override;
private:
const LOT m_PillarA = 11946;
const LOT m_PillarB = 11947;
const LOT m_PillarC = 11948;
const LOT m_Dragon = 11898;
};

View File

@@ -0,0 +1,21 @@
#include "FvRacePillarDServer.h"
#include "RenderComponent.h"
#include "RacingControlComponent.h"
void FvRacePillarDServer::OnCollisionPhantom(Entity* self, Entity* target) {
if (!target) return;
const auto racingControllers = Game::entityManager->GetEntitiesByComponent(eReplicaComponentType::RACING_CONTROL);
if (racingControllers.empty()) return;
auto* racingControlComponent = racingControllers[0]->GetComponent<RacingControlComponent>();
if (!racingControlComponent) return;
const auto* player = racingControlComponent->GetPlayerData(target->GetObjectID());
if (!player) return;
if (player->lap == 2) {
PlayAnimation("crumble", "pillars", m_PillarD);
PlayAnimation("roar", "dragon", m_Dragon);
}
}

View File

@@ -0,0 +1,10 @@
#pragma once
#include "CppScripts.h"
#include "FvRacePillarServer.h"
class FvRacePillarDServer : public FvRacePillarServer {
void OnCollisionPhantom(Entity* self, Entity* target) override;
private:
const LOT m_PillarD = 11949;
const LOT m_Dragon = 11898;
};

View File

@@ -0,0 +1,15 @@
#include "FvRacePillarServer.h"
#include "Game.h"
#include "EntityManager.h"
#include "RenderComponent.h"
void FvRacePillarServer::PlayAnimation(const std::string animName, const std::string group, const LOT lot) {
const auto entities = Game::entityManager->GetEntitiesInGroup(group);
for (const auto& entity : entities) {
if (!entity || entity->GetLOT() != lot) continue;
auto* renderComponent = entity->GetComponent<RenderComponent>();
if (!renderComponent) continue;
renderComponent->PlayAnimation(entity, animName);
}
}

View File

@@ -0,0 +1,12 @@
#ifndef FVRACEPILLARSERVER__H
#define FVRACEPILLARSERVER__H
#include "CppScripts.h"
class FvRacePillarServer : public virtual CppScripts::Script {
protected:
// Plays an animation on all entities in a group with a specific LOT
void PlayAnimation(const std::string animName, const std::string group, const LOT lot);
};
#endif // FVRACEPILLARSERVER__H