Browse Source

Pickup and Need Work

- Fixed PickupDirect making Need better instead of worse as well as actually destroying the Pickup regardless of whether there was a Need found or not
- NeedType now comes from the NeedDef only
- AgentComponentManager now should destroy entities when DieNow NeedTrigger is hit (though it doesn't seem to be working yet)
combatComponentRefactor
Macoy Madson 6 years ago
parent
commit
6db848a451
  1. 8
      TODO.txt
  2. 7
      src/game/InteractComponentManager.cpp
  3. 18
      src/game/agent/AgentComponentManager.cpp
  4. 7
      src/game/agent/Needs.hpp
  5. 10
      src/project/galavantSublime/galavant.sublime-project

8
TODO.txt

@ -6,12 +6,8 @@ What does agent component manager do with triggers once plan is done? How to kno
statics don't work well with hot reloading
FragmentedPool crashed during in-editor compile hotreload
Still hitting TestMovementComponent segfault. Need a way to detect when an entity is destroyed outside GV control
Added code to EndPlay() which unsubscribes shit manually
Play with Polyvox chunk scale
**** LEFT OFF AT:
InteractTask added, it should be hooked up and working
Pickups sort of working, sometimes they aren't picked up, Actors are being destroyed strangely
Agents should be destroyed by the AgentComponentManager if DieNow, but they don't seem to be hitting it

7
src/game/InteractComponentManager.cpp

@ -77,10 +77,9 @@ bool InteractComponentManager::PickupDirect(Entity pickupEntity, Entity claimer)
// TODO: For testing only
if (needPickupAffects)
{
needPickupAffects->Level += 100;
LOGV << "Entity " << claimer << " restored need "
needPickupAffects->Level -= 100;
LOGD << "Entity " << claimer << " restored need "
<< needPickupAffects->Def->Name << " by 100 picking up " << pickupEntity;
return true;
}
// TODO: Are we allocating for this? :(
@ -90,6 +89,8 @@ bool InteractComponentManager::PickupDirect(Entity pickupEntity, Entity claimer)
if (pickup->DestroySelfOnPickup)
entityComponentManager->MarkDestroyEntities(entitiesPickedUp);
return true;
}
}
}

18
src/game/agent/AgentComponentManager.cpp

@ -4,6 +4,7 @@
#include "../../entityComponentSystem/PooledComponentManager.hpp"
#include "../../entityComponentSystem/ComponentTypes.hpp"
#include "../../entityComponentSystem/EntityComponentManager.hpp"
#include "../../ai/htn/HTNTaskDb.hpp"
namespace gv
@ -36,6 +37,7 @@ void AddGoalIfUniqueType(AgentGoalList& goals, AgentGoal& goalToAdd)
void AgentComponentManager::Update(float deltaSeconds)
{
EntityList entitiesToUnsubscribe;
EntityList entitiesToDestroy;
PlanComponentManager::PlanComponentList newPlans;
WorldTime += deltaSeconds;
@ -56,7 +58,10 @@ void AgentComponentManager::Update(float deltaSeconds)
AgentGoalList& goals = currentComponent->data.Goals;
if (!currentComponent->data.IsAlive)
{
entitiesToDestroy.push_back(currentEntity);
continue;
}
// Update Needs
for (Need& need : needs)
@ -95,7 +100,7 @@ void AgentComponentManager::Update(float deltaSeconds)
{
currentComponent->data.IsAlive = false;
LOGD_IF(DebugPrint) << "Agent Entity " << currentEntity
<< " has died!";
<< " has died from need " << need.Def->Name;
}
}
}
@ -132,7 +137,7 @@ void AgentComponentManager::Update(float deltaSeconds)
Htn::TaskDb::GetTask(Htn::TaskName::InteractPickup), parameters};
Htn::TaskCallList getResourceTasks = {getResourceCall,
pickupResourceCall};
gv::PooledComponent<PlanComponentData> newPlanComponent;
newPlanComponent.entity = currentEntity;
newPlanComponent.data.Tasks.insert(newPlanComponent.data.Tasks.end(),
@ -166,6 +171,13 @@ void AgentComponentManager::Update(float deltaSeconds)
if (!entitiesToUnsubscribe.empty())
UnsubscribeEntities(entitiesToUnsubscribe);
if (!entitiesToDestroy.empty())
{
EntityComponentManager* entityComponentManager = EntityComponentManager::GetSingleton();
if (entityComponentManager)
entityComponentManager->MarkDestroyEntities(entitiesToDestroy);
}
}
void AgentComponentManager::SubscribeEntitiesInternal(const EntityList& subscribers,
@ -250,7 +262,7 @@ Need* AgentComponentManager::GetAgentNeed(Entity entity, NeedType needType)
{
for (Need& need : currentComponent->data.Needs)
{
if (need.Type == needType)
if (need.Def->Type == needType)
return &need;
}
}

7
src/game/agent/Needs.hpp

@ -26,7 +26,7 @@ typedef std::vector<NeedLevelTrigger> NeedLevelTriggerList;
struct NeedDef
{
NeedType Type;
NeedType Type = gv::NeedType::None;
const char* Name;
@ -39,11 +39,10 @@ struct NeedDef
struct Need
{
NeedType Type = gv::NeedType::None;
NeedDef* Def = nullptr;
float Level = 0;
float LastUpdateTime = 0;
float Level = 0.f;
float LastUpdateTime = 0.f;
};
typedef std::vector<Need> NeedList;

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

@ -10,7 +10,7 @@
{
"path": "../../../../galavant-unreal/GalavantUnreal/Source",
"name": "Source - Galavant Unreal",
"file_include_patterns": ["*.c", "*.cpp", "*.h", "*.hpp", "*.txt", "*.cs", "*.md"]
"file_include_patterns": ["*.c", "*.cpp", "*.h", "*.hpp", "*.txt", "*.cs", "*.md", "*.sh"]
},
{
"path": "../../../gamedata",
@ -51,7 +51,7 @@
// "Full build"
{
"name": "Full Unreal Build",
"name": "Full Unreal Build (build Galavant lib and Unreal)",
"shell_cmd": "cd galavant && jam -j4 -q -sUNREAL=true GalavantPseudotarget && cd ../galavant-unreal/GalavantUnreal && make GalavantUnreal",
"working_dir": "$project_path/../../../.."
},
@ -69,6 +69,12 @@
"working_dir": "$project_path/../../../../galavant-unreal/GalavantUnreal"
},
{
"name": "Unreal Generate Project Files",
"shell_cmd": "/home/macoy/Downloads/UnrealEngine/GenerateProjectFiles.sh -project=/home/macoy/Development/code/repositories/galavant-unreal/GalavantUnreal/GalavantUnreal.uproject -game -editor",
"working_dir": "$project_path/../../../../galavant-unreal/GalavantUnreal"
},
// Jam
{
"name": "Jam Current Directory",

Loading…
Cancel
Save