feat: OnAttack behavior (#1853)

Adds the `OnAttack` property behavior starting node.
Tested that having the node allows the model to be attacked to trigger the start of behaviors
This commit is contained in:
David Markowitz
2025-08-01 01:09:16 -07:00
committed by GitHub
parent c9e95839ee
commit c083f21e44
11 changed files with 111 additions and 6 deletions

View File

@@ -118,6 +118,16 @@ void Strip::OnChatMessageReceived(const std::string& sMessage) {
}
}
void Strip::OnHit() {
if (m_PausedTime > 0.0f || !HasMinimumActions()) return;
const auto& nextAction = GetNextAction();
if (nextAction.GetType() == "OnAttack") {
IncrementAction();
m_WaitingForAction = false;
}
}
void Strip::IncrementAction() {
if (m_Actions.empty()) return;
m_NextActionIndex++;
@@ -259,6 +269,8 @@ void Strip::RemoveStates(ModelComponent& modelComponent) const {
if (prevActionType == "OnInteract") {
modelComponent.RemoveInteract();
Game::entityManager->SerializeEntity(modelComponent.GetParent());
} else if (prevActionType == "OnAttack") {
modelComponent.RemoveAttack();
} else if (prevActionType == "UnSmash") {
modelComponent.RemoveUnSmash();
}
@@ -336,13 +348,14 @@ void Strip::Update(float deltaTime, ModelComponent& modelComponent) {
if (m_NextActionIndex == 0) {
if (nextAction.GetType() == "OnInteract") {
modelComponent.AddInteract();
Game::entityManager->SerializeEntity(entity);
m_WaitingForAction = true;
} else if (nextAction.GetType() == "OnChat") {
Game::entityManager->SerializeEntity(entity);
m_WaitingForAction = true;
// logic here if needed
} else if (nextAction.GetType() == "OnAttack") {
modelComponent.AddAttack();
}
Game::entityManager->SerializeEntity(entity);
m_WaitingForAction = true;
} else { // should be a normal block
ProcNormalAction(deltaTime, modelComponent);
}