mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-22 13:37:22 +00:00
Merge branch 'main' into moreMovementAi
This commit is contained in:
commit
8c8fc2ae87
@ -16,6 +16,7 @@
|
||||
#include "PlayerManager.h"
|
||||
#include "Game.h"
|
||||
#include "EntityManager.h"
|
||||
#include "MovementAIComponent.h"
|
||||
|
||||
TriggerComponent::TriggerComponent(Entity* parent, const std::string triggerInfo) : Component(parent) {
|
||||
m_Parent = parent;
|
||||
@ -177,20 +178,25 @@ std::vector<Entity*> TriggerComponent::GatherTargets(LUTriggers::Command* comman
|
||||
std::vector<Entity*> entities = {};
|
||||
|
||||
if (command->target == "self") entities.push_back(m_Parent);
|
||||
else if (command->target == "zone") { /*TODO*/ }
|
||||
else if (command->target == "target" && optionalTarget) entities.push_back(optionalTarget);
|
||||
else if (command->target == "targetTeam" && optionalTarget) {
|
||||
else if (command->target == "zone") {
|
||||
/*TODO*/
|
||||
} else if (command->target == "target" && optionalTarget) {
|
||||
entities.push_back(optionalTarget);
|
||||
} else if (command->target == "targetTeam" && optionalTarget) {
|
||||
auto* team = TeamManager::Instance()->GetTeam(optionalTarget->GetObjectID());
|
||||
for (const auto memberId : team->members) {
|
||||
auto* member = Game::entityManager->GetEntity(memberId);
|
||||
if (member) entities.push_back(member);
|
||||
}
|
||||
} else if (command->target == "objGroup") entities = Game::entityManager->GetEntitiesInGroup(command->targetName);
|
||||
else if (command->target == "allPlayers") {
|
||||
} else if (command->target == "objGroup") {
|
||||
entities = Game::entityManager->GetEntitiesInGroup(command->targetName);
|
||||
} else if (command->target == "allPlayers") {
|
||||
for (auto* player : PlayerManager::GetAllPlayers()) {
|
||||
entities.push_back(player);
|
||||
}
|
||||
} else if (command->target == "allNPCs") { /*UNUSED*/ }
|
||||
} else if (command->target == "allNPCs") {
|
||||
/*UNUSED*/
|
||||
}
|
||||
|
||||
return entities;
|
||||
}
|
||||
@ -222,18 +228,6 @@ void TriggerComponent::HandleResetRebuild(Entity* targetEntity, std::string args
|
||||
quickBuildComponent->ResetQuickBuild(args == "1");
|
||||
}
|
||||
|
||||
void TriggerComponent::HandleSetPath(Entity* targetEntity, std::vector<std::string> argArray){
|
||||
auto* movementAIComponent = targetEntity->GetComponent<MovementAIComponent>();
|
||||
if (!movementAIComponent) return;
|
||||
movementAIComponent->SetupPath(argArray.at(0));
|
||||
if (argArray.size() >= 2) {
|
||||
auto index = GeneralUtils::TryParse<int32_t>(argArray.at(1));
|
||||
if (!index) return;
|
||||
movementAIComponent->SetPathStartingWaypointIndex(index.value());
|
||||
}
|
||||
if (argArray.size() >= 3 && argArray.at(2) == "1") movementAIComponent->ReversePath();
|
||||
}
|
||||
|
||||
void TriggerComponent::HandleMoveObject(Entity* targetEntity, std::vector<std::string> argArray) {
|
||||
if (argArray.size() <= 2) return;
|
||||
|
||||
@ -490,3 +484,44 @@ void TriggerComponent::HandleActivatePhysics(Entity* targetEntity, std::string a
|
||||
LOG_DEBUG("Invalid argument for ActivatePhysics Trigger: %s", args.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
void TriggerComponent::HandleSetPath(Entity* targetEntity, std::vector<std::string> argArray) {
|
||||
auto* movementAIComponent = targetEntity->GetComponent<MovementAIComponent>();
|
||||
if (!movementAIComponent) return;
|
||||
// movementAIComponent->SetupPath(argArray.at(0));
|
||||
if (argArray.size() >= 2) {
|
||||
auto index = GeneralUtils::TryParse<int32_t>(argArray.at(1));
|
||||
if (!index) return;
|
||||
// movementAIComponent->SetPathStartingWaypointIndex(index.value());
|
||||
}
|
||||
if (argArray.size() >= 3 && argArray.at(2) == "1") {
|
||||
// movementAIComponent->ReversePath();
|
||||
}
|
||||
}
|
||||
|
||||
void TriggerComponent::HandleTurnAroundOnPath(Entity* targetEntity) {
|
||||
auto* movementAIComponent = targetEntity->GetComponent<MovementAIComponent>();
|
||||
// if (movementAIComponent) movementAIComponent->ReversePath();
|
||||
}
|
||||
|
||||
void TriggerComponent::HandleGoForwardOnPath(Entity* targetEntity) {
|
||||
auto* movementAIComponent = targetEntity->GetComponent<MovementAIComponent>();
|
||||
if (!movementAIComponent) return;
|
||||
// if (movementAIComponent->GetIsInReverse()) movementAIComponent->ReversePath();
|
||||
}
|
||||
|
||||
void TriggerComponent::HandleGoBackwardOnPath(Entity* targetEntity) {
|
||||
auto* movementAIComponent = targetEntity->GetComponent<MovementAIComponent>();
|
||||
if (!movementAIComponent) return;
|
||||
// if (!movementAIComponent->GetIsInReverse()) movementAIComponent->ReversePath();
|
||||
}
|
||||
|
||||
void TriggerComponent::HandleStopPathing(Entity* targetEntity) {
|
||||
auto* movementAIComponent = targetEntity->GetComponent<MovementAIComponent>();
|
||||
// if (movementAIComponent) movementAIComponent->Pause();
|
||||
}
|
||||
|
||||
void TriggerComponent::HandleStartPathing(Entity* targetEntity) {
|
||||
auto* movementAIComponent = targetEntity->GetComponent<MovementAIComponent>();
|
||||
// if (movementAIComponent) movementAIComponent->Resume();
|
||||
}
|
||||
|
@ -50,6 +50,12 @@ private:
|
||||
void HandleResetSpawnerNetwork(std::string args);
|
||||
void HandleDestroySpawnerNetworkObjects(std::string args);
|
||||
void HandleActivatePhysics(Entity* targetEntity, std::string args);
|
||||
void HandleTurnAroundOnPath(Entity* targetEntity);
|
||||
void HandleGoForwardOnPath(Entity* targetEntity);
|
||||
void HandleGoBackwardOnPath(Entity* targetEntity);
|
||||
void HandleStopPathing(Entity* targetEntity);
|
||||
void HandleStartPathing(Entity* targetEntity);
|
||||
void HandleSetPath(Entity* targetEntity, std::vector<std::string> argArray);
|
||||
|
||||
LUTriggers::Trigger* m_Trigger;
|
||||
};
|
||||
|
@ -29,7 +29,7 @@ void StoryBoxInteractServer::OnUse(Entity* self, Entity* user) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!self->HasVar(u"storyText") || !self->HasVar(u"altFlagID")) return;
|
||||
if (!self->HasVar(u"storyText")) return;
|
||||
const auto storyText = self->GetVarAsString(u"storyText");
|
||||
if (storyText.length() > 2) {
|
||||
auto storyValue = GeneralUtils::TryParse<uint32_t>(storyText.substr(storyText.length() - 2));
|
||||
|
@ -453,18 +453,20 @@ void Zone::LoadPath(std::istream& file) {
|
||||
std::string value;
|
||||
BinaryIO::ReadString<uint8_t>(file, value, BinaryIO::ReadType::WideString);
|
||||
|
||||
LDFBaseData* ldfConfig = nullptr;
|
||||
if (path.pathType == PathType::Movement || path.pathType == PathType::Rail) {
|
||||
// cause NetDevil puts spaces in things that don't need spaces
|
||||
parameter.erase(std::remove_if(parameter.begin(), parameter.end(), ::isspace), parameter.end());
|
||||
auto waypointCommand = WaypointCommandType::StringToWaypointCommandType(parameter);
|
||||
if (waypointCommand == eWaypointCommandType::DELAY) value.erase(std::remove_if(value.begin(), value.end(), ::isspace), value.end());
|
||||
if (waypointCommand != eWaypointCommandType::INVALID) waypoint.commands.push_back(WaypointCommand(waypointCommand, value));
|
||||
else LOG("Tried to load invalid waypoint command '%s'", parameter.c_str());
|
||||
if (waypointCommand != eWaypointCommandType::INVALID) {
|
||||
auto& command = waypoint.commands.emplace_back();
|
||||
command.command = waypointCommand;
|
||||
command.data = value;
|
||||
} else LOG("Tried to load invalid waypoint command '%s'", parameter.c_str());
|
||||
} else {
|
||||
ldfConfig = LDFBaseData::DataFromString(parameter + "=" + value);
|
||||
if (ldfConfig) waypoint.config.push_back(ldfConfig);
|
||||
waypoint.config.emplace_back(LDFBaseData::DataFromString(parameter + "=" + value));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -14,15 +14,13 @@ namespace LUTriggers {
|
||||
class Level;
|
||||
|
||||
enum class eWaypointCommandType : uint32_t;
|
||||
|
||||
struct WaypointCommand {
|
||||
eWaypointCommandType command;
|
||||
std::string data;
|
||||
WaypointCommand(eWaypointCommandType command, std::string data){
|
||||
this->command = command;
|
||||
this->data = data;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
struct SceneRef {
|
||||
std::string filename;
|
||||
uint32_t id;
|
||||
|
Loading…
Reference in New Issue
Block a user