fix: adding custom behaviors (#1969)

This commit is contained in:
David Markowitz
2026-04-14 01:04:26 -07:00
committed by GitHub
parent 8061f512aa
commit 482ff82656
3 changed files with 14 additions and 3 deletions

View File

@@ -189,8 +189,7 @@ void ModelComponent::AddBehavior(AddMessage& msg) {
// Check if this behavior is able to be found via lot (if so, its a loot behavior). // Check if this behavior is able to be found via lot (if so, its a loot behavior).
insertedBehavior.SetIsLoot(inventoryComponent->FindItemByLot(msg.GetBehaviorId(), eInventoryType::BEHAVIORS)); insertedBehavior.SetIsLoot(inventoryComponent->FindItemByLot(msg.GetBehaviorId(), eInventoryType::BEHAVIORS));
} }
auto* const missionComponent = playerEntity->GetComponent<MissionComponent>(); ProgressAddBehaviorMission(*playerEntity);
if (missionComponent) missionComponent->Progress(eMissionTaskType::ADD_BEHAVIOR, 0);
} }
auto* const simplePhysComponent = m_Parent->GetComponent<SimplePhysicsComponent>(); auto* const simplePhysComponent = m_Parent->GetComponent<SimplePhysicsComponent>();
@@ -200,6 +199,11 @@ void ModelComponent::AddBehavior(AddMessage& msg) {
} }
} }
void ModelComponent::ProgressAddBehaviorMission(Entity& playerEntity) {
auto* const missionComponent = playerEntity.GetComponent<MissionComponent>();
if (missionComponent) missionComponent->Progress(eMissionTaskType::ADD_BEHAVIOR, 0);
}
std::string ModelComponent::SaveBehavior(const PropertyBehavior& behavior) const { std::string ModelComponent::SaveBehavior(const PropertyBehavior& behavior) const {
tinyxml2::XMLDocument doc; tinyxml2::XMLDocument doc;
auto* root = doc.NewElement("Behavior"); auto* root = doc.NewElement("Behavior");

View File

@@ -98,6 +98,8 @@ public:
return msg.GetNeedsNewBehaviorID(); return msg.GetNeedsNewBehaviorID();
}; };
void ProgressAddBehaviorMission(Entity& playerEntity);
void AddBehavior(AddMessage& msg); void AddBehavior(AddMessage& msg);
void RemoveBehavior(MoveToInventoryMessage& msg, const bool keepItem); void RemoveBehavior(MoveToInventoryMessage& msg, const bool keepItem);

View File

@@ -164,7 +164,12 @@ void ControlBehaviors::ProcessCommand(Entity* const modelEntity, const AMFArrayV
LOG("Unknown behavior command (%s)", command.data()); LOG("Unknown behavior command (%s)", command.data());
} }
if (needsNewBehaviorID) RequestUpdatedID(context); // If we need a new behaviorID, request it and progress the mission for adding a behavior.
// "add" takes care of this in the ModelComponent directly so we do not need to do it here for that command.
if (needsNewBehaviorID) {
RequestUpdatedID(context);
context.modelComponent->ProgressAddBehaviorMission(*context.modelOwner);
}
} }
ControlBehaviors::ControlBehaviors() { ControlBehaviors::ControlBehaviors() {