Browse Source

Agent Consciousness, list macros, Standalone debug

- AgentComponentManager now has GetUnconsciousAgents(), which fits the needs of external systems better
- Added some for macros for iteration etc. because I'm lazy
- Added standalone debug unreal build commands and debug option. The whole workflow is working now, though it does take an unfortunate amount of time to link
master
Macoy Madson 6 years ago
parent
commit
84bb8a1bdc
  1. 10
      src/entityComponentSystem/EntityTypes.cpp
  2. 53
      src/game/agent/AgentComponentManager.cpp
  3. 6
      src/game/agent/AgentComponentManager.hpp
  4. 10
      src/project/galavantSublime/galavant.sublime-project
  5. 7
      src/util/CppHelperMacros.hpp

10
src/entityComponentSystem/EntityTypes.cpp

@ -2,6 +2,8 @@
#include "EntityTypes.hpp"
#include "util/CppHelperMacros.hpp"
namespace gv
{
const Entity NullEntity = 0;
@ -108,12 +110,6 @@ void EntityListRemoveUniqueEntitiesInSuspect(const EntityList& list, EntityList&
bool EntityListFindEntity(const EntityList& list, Entity entity)
{
for (EntityListConstIterator it = list.begin(); it != list.end(); ++it)
{
Entity currentEntity = (*it);
if (currentEntity == entity)
return true;
}
return false;
return IS_IN_LIST(list, entity);
}
}

53
src/game/agent/AgentComponentManager.cpp

@ -29,6 +29,26 @@ void AgentComponentManager::Initialize(PlanComponentManager* newPlanComponentMan
MovementComponentManager = newMovementComponentManager;
}
void AgentComponentManager::SetAgentConsciousState(PooledComponent<AgentComponentData>* agent,
AgentConsciousState newState)
{
if (agent)
{
if (agent->data.ConsciousState != newState)
{
if (newState != AgentConsciousState::Conscious &&
!EntityListFindEntity(UnconsciousAgents, agent->entity))
UnconsciousAgents.push_back(agent->entity);
if (newState == AgentConsciousState::Conscious &&
EntityListFindEntity(UnconsciousAgents, agent->entity))
EntityListRemoveNonUniqueEntitiesInSuspect({agent->entity}, UnconsciousAgents);
agent->data.ConsciousState = newState;
}
}
}
void AddGoalIfUniqueType(AgentGoalList& goals, AgentGoal& goalToAdd)
{
if (!goalToAdd.Def)
@ -51,7 +71,6 @@ void AgentComponentManager::Update(float deltaSeconds)
EntityList entitiesToUnsubscribe;
EntityList entitiesToDestroy;
PlanComponentManager::PlanComponentList newPlans;
std::vector<gv::PooledComponent<AgentComponentData>*> newlyDeadAgents;
if (!PlanManager)
{
@ -125,14 +144,14 @@ void AgentComponentManager::Update(float deltaSeconds)
if (needLevelTrigger.SetConsciousState != AgentConsciousState::None &&
currentComponent->data.ConsciousState != needLevelTrigger.SetConsciousState)
{
currentComponent->data.ConsciousState = needLevelTrigger.SetConsciousState;
SetAgentConsciousState(currentComponent,
needLevelTrigger.SetConsciousState);
if (currentComponent->data.ConsciousState == AgentConsciousState::Dead)
{
currentComponent->data.IsAlive = false;
LOGD_IF(DebugPrint) << "Agent Entity " << currentEntity
<< " has died from need " << need.Def->Name;
newlyDeadAgents.push_back(currentComponent);
}
}
@ -266,27 +285,6 @@ void AgentComponentManager::Update(float deltaSeconds)
if (!newPlans.empty())
PlanManager->SubscribeEntities(newPlans);
if (!newlyDeadAgents.empty())
{
EntityList deadEntities;
std::vector<float> deadEntitySpeeds;
for (gv::PooledComponent<AgentComponentData>* currentComponent : newlyDeadAgents)
{
// temporary
static CombatActionDef deathActionDef;
deathActionDef.Die = true;
CombatAction deathAction{&deathActionDef, nullptr, 0.f};
g_CombatComponentManager.ActivateCombatAction(currentComponent->entity, deathAction);
deadEntities.push_back(currentComponent->entity);
deadEntitySpeeds.push_back(0.f);
}
// TODO: @Purity: How do I want other systems to interact? Is this dirty, or fine?
if (MovementComponentManager)
MovementComponentManager->SetEntitySpeeds(deadEntities, deadEntitySpeeds);
}
if (!entitiesToUnsubscribe.empty())
UnsubscribeEntities(entitiesToUnsubscribe);
@ -302,7 +300,7 @@ void AgentComponentManager::SubscribeEntitiesInternal(const EntityList& subscrib
if (!currentComponent)
continue;
currentComponent->data.ConsciousState = AgentConsciousState::Conscious;
SetAgentConsciousState(currentComponent, AgentConsciousState::Conscious);
}
LOGD_IF(DebugPrint) << "AgentComponentManager: Subscribed " << subscribers.size()
@ -357,6 +355,11 @@ void AgentComponentManager::GetAgentConsciousStates(const EntityList& entities,
}
}
const EntityList& AgentComponentManager::GetUnconsciousAgents()
{
return UnconsciousAgents;
}
Need* AgentComponentManager::GetAgentNeed(Entity entity, NeedType needType)
{
// TODO: Adding true iterator support to pool will drastically help damning this to hell

6
src/game/agent/AgentComponentManager.hpp

@ -49,6 +49,11 @@ private:
MovementManager* MovementComponentManager;
EntityList UnconsciousAgents;
void SetAgentConsciousState(PooledComponent<AgentComponentData>* agent,
AgentConsciousState newState);
protected:
typedef std::vector<PooledComponent<AgentComponentData>*> AgentComponentRefList;
@ -71,6 +76,7 @@ public:
virtual void Update(float deltaSeconds);
void GetAgentConsciousStates(const EntityList& entities, AgentConsciousStateList& stateListOut);
const EntityList& GetUnconsciousAgents();
Need* GetAgentNeed(Entity entity, NeedType needType);
};

10
src/project/galavantSublime/galavant.sublime-project

@ -120,15 +120,13 @@
{
"name": "GalavantUnreal Standalone Package",
"shell_cmd": "mono AutomationTool.exe -ScriptsForProject=/home/macoy/Development/code/repositories/galavant-unreal/GalavantUnreal/GalavantUnreal.uproject BuildCookRun -nocompile -nocompileeditor -nop4 -project=/home/macoy/Development/code/repositories/galavant-unreal/GalavantUnreal/GalavantUnreal.uproject -cook -stage -archive -archivedirectory=/home/macoy/Development/code/repositories/galavant-unreal/GalavantUnreal/LOCAL_package/package/ -package -clientconfig=Development -ue4exe=UE4Editor-Linux-Debug -pak -prereqs -nodebuginfo -nativizeAssets -targetplatform=Linux -build -utf8output",
// "working_dir": "$project_path/../../../../galavant-unreal/GalavantUnreal",
"working_dir": "/home/macoy/Development/code/3rdParty/repositories/UnrealEngine/Engine/Binaries/DotNET",
"syntax":"JamUnrealBuildOutput.sublime-syntax"
},
{
"name": "GalavantUnreal Standalone Package Debug",
"shell_cmd": "mono AutomationTool.exe -ScriptsForProject=/home/macoy/Development/code/repositories/galavant-unreal/GalavantUnreal/GalavantUnreal.uproject BuildCookRun -nocompile -nocompileeditor -nop4 -project=/home/macoy/Development/code/repositories/galavant-unreal/GalavantUnreal/GalavantUnreal.uproject -cook -stage -archive -archivedirectory=/home/macoy/Development/code/repositories/galavant-unreal/GalavantUnreal/LOCAL_package/package/ -package -clientconfig=Debug -ue4exe=UE4Editor-Linux-Debug -pak -prereqs -nativizeAssets -targetplatform=Linux -build -utf8output",
// "working_dir": "$project_path/../../../../galavant-unreal/GalavantUnreal",
"shell_cmd": "mono AutomationTool.exe -ScriptsForProject=/home/macoy/Development/code/repositories/galavant-unreal/GalavantUnreal/GalavantUnreal.uproject BuildCookRun -nocompile -nocompileeditor -nop4 -project=/home/macoy/Development/code/repositories/galavant-unreal/GalavantUnreal/GalavantUnreal.uproject -cook -stage -archive -archivedirectory=/home/macoy/Development/code/repositories/galavant-unreal/GalavantUnreal/LOCAL_package/package/ -package -clientconfig=DebugGame -ue4exe=UE4Editor-Linux-Debug -pak -prereqs -nodebuginfo -nativizeAssets -targetplatform=Linux -build -utf8output",
"working_dir": "/home/macoy/Development/code/3rdParty/repositories/UnrealEngine/Engine/Binaries/DotNET",
"syntax":"JamUnrealBuildOutput.sublime-syntax"
},
@ -265,6 +263,12 @@
"commandline": "gdb --interpreter=mi --args ./LOCAL_package/package/LinuxNoEditor/GalavantUnreal/Binaries/Linux/GalavantUnreal -windowed -resx=1920 -resy=1080"
},
"GalavantUnreal Standalone Debug":
{
"workingdir": "/home/macoy/Development/code/repositories/galavant-unreal/GalavantUnreal",
"commandline": "gdb --interpreter=mi --args ./LOCAL_package/package/LinuxNoEditor/GalavantUnreal/Binaries/Linux/GalavantUnreal-Linux-Debug -windowed -resx=1920 -resy=1080"
},
//"htnTest":
//{
// "workingdir": "../../../bin",

7
src/util/CppHelperMacros.hpp

@ -0,0 +1,7 @@
#pragma once
#define LIST_FIND(list, object) std::find(list.begin(), list.end(), object)
#define IS_IN_LIST(list, object) (std::find(list.begin(), list.end(), object) != list.end())
#define FOR_ITERATE(listType, list, iteratorName) for (listType::iterator iteratorName = list.begin(); iteratorName != list.end(); ++iteratorName)
#define FOR_ITERATE_NO_INCR(listType, list, iteratorName) for (listType::iterator iteratorName = list.begin(); iteratorName != list.end();)
Loading…
Cancel
Save