Merge branch 'main' into more-behaviors

This commit is contained in:
David Markowitz
2025-06-10 21:49:40 -07:00
22 changed files with 162 additions and 68 deletions

View File

@@ -84,9 +84,11 @@ void Strip::HandleMsg(MigrateActionsMessage& msg) {
template<>
void Strip::HandleMsg(GameMessages::RequestUse& msg) {
if (m_PausedTime > 0.0f) return;
if (m_PausedTime > 0.0f || !HasMinimumActions()) return;
if (m_Actions[m_NextActionIndex].GetType() == "OnInteract") {
auto& nextAction = GetNextAction();
if (nextAction.GetType() == "OnInteract") {
IncrementAction();
m_WaitingForAction = false;
}
@@ -113,7 +115,9 @@ void Strip::Spawn(LOT lot, Entity& entity) {
info.pos = entity.GetPosition();
info.rot = NiQuaternionConstant::IDENTITY;
info.spawnerID = entity.GetObjectID();
Game::entityManager->ConstructEntity(Game::entityManager->CreateEntity(info, nullptr, &entity));
auto* const spawnedEntity = Game::entityManager->CreateEntity(info, nullptr, &entity);
spawnedEntity->AddToGroup("SpawnedPropertyEnemies");
Game::entityManager->ConstructEntity(spawnedEntity);
}
// Spawns a specific drop for all
@@ -139,6 +143,7 @@ void Strip::ProcNormalAction(float deltaTime, ModelComponent& modelComponent) {
// Default velocity is 3 units per second.
entity.SetVelocity(NiPoint3{0.0f, isFlyDown ? -3.0f : 3.0f, 0.0f});
modelComponent.SetVelocity(NiPoint3{0.0f, isFlyDown ? -3.0f : 3.0f, 0.0f});
}
else if (nextActionType == "MoveRight" || nextActionType == "MoveLeft") {
bool isMoveLeft = nextActionType == "MoveLeft";
@@ -205,7 +210,6 @@ void Strip::ProcNormalAction(float deltaTime, ModelComponent& modelComponent) {
LOG("Tried to play action (%s) which is not supported.", nextActionType.data());
g_WarnedActions.insert(nextActionType.data());
}
return;
}
IncrementAction();
@@ -259,13 +263,19 @@ bool Strip::CheckMovement(float deltaTime, ModelComponent& modelComponent) {
}
void Strip::Update(float deltaTime, ModelComponent& modelComponent) {
// No point in running a strip with only one action.
// Strips are also designed to have 2 actions or more to run.
if (!HasMinimumActions()) return;
if (!CheckMovement(deltaTime, modelComponent)) return;
// Don't run this strip if we're paused.
m_PausedTime -= deltaTime;
if (m_PausedTime > 0.0f) return;
m_PausedTime = 0.0f;
// Return here if we're waiting for external interactions to continue.
if (m_WaitingForAction) return;
auto& entity = *modelComponent.GetParent();

View File

@@ -37,6 +37,9 @@ public:
void SpawnDrop(LOT dropLOT, Entity& entity);
void ProcNormalAction(float deltaTime, ModelComponent& modelComponent);
void RemoveStates(ModelComponent& modelComponent) const;
// 2 actions are required for strips to work
bool HasMinimumActions() const { return m_Actions.size() >= 2; }
private:
// Indicates this Strip is waiting for an action to be taken upon it to progress to its actions
bool m_WaitingForAction{ false };