switch to using own event system
This commit is contained in:
@@ -6,7 +6,6 @@ SET(HDRS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/EntityAdmin.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Blueprint.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/BuildingId.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/FireEvent.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ItemType.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Item.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Port.h
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "Tick.h"
|
||||
|
||||
#include "entt/entity/entity.hpp"
|
||||
|
||||
// Transient record emitted each time a weapon fires (REQ-SHP-FIRING,
|
||||
// REQ-SHP-FIRING-BEAM). Buffered in a sim-owned queue and drained by the
|
||||
// renderer each frame to draw the 0.3-second laser beam.
|
||||
struct FireEvent
|
||||
{
|
||||
entt::entity shooter;
|
||||
entt::entity target;
|
||||
Tick emittedAt;
|
||||
};
|
||||
@@ -21,7 +21,7 @@ CombatSystem::CombatSystem(const GameConfig& config)
|
||||
void CombatSystem::tick(Tick currentTick,
|
||||
EntityAdmin& admin,
|
||||
BuildingSystem& /*buildings*/,
|
||||
std::vector<FireEvent>& outFireEvents)
|
||||
std::vector<WeaponFiredEvent>& outWeaponFiredEvents)
|
||||
{
|
||||
TRACE();
|
||||
// All weapons (ships and stations) are child entities linked via ModuleOwnerComponent.
|
||||
@@ -35,7 +35,7 @@ void CombatSystem::tick(Tick currentTick,
|
||||
}
|
||||
const PositionComponent& pos = admin.get<PositionComponent>(owner.owner);
|
||||
const FactionComponent& faction = admin.get<FactionComponent>(owner.owner);
|
||||
resolveWeapon(owner.owner, weapon, pos, faction, currentTick, admin, outFireEvents);
|
||||
resolveWeapon(owner.owner, weapon, pos, faction, currentTick, admin, outWeaponFiredEvents);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ void CombatSystem::resolveWeapon(
|
||||
const FactionComponent& ownFaction,
|
||||
Tick currentTick,
|
||||
EntityAdmin& admin,
|
||||
std::vector<FireEvent>& out)
|
||||
std::vector<WeaponFiredEvent>& out)
|
||||
{
|
||||
if (weapon.cooldownTicks > 0.0f)
|
||||
{
|
||||
@@ -115,7 +115,7 @@ void CombatSystem::resolveWeapon(
|
||||
m_pendingDamage.push_back({targetEntity, weapon.damage,
|
||||
currentTick + kWeaponImpactDelayTicks});
|
||||
|
||||
FireEvent evt;
|
||||
WeaponFiredEvent evt;
|
||||
evt.shooter = shipEntity;
|
||||
evt.target = targetEntity;
|
||||
evt.emittedAt = currentTick;
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#include "Building.h"
|
||||
#include "FactionComponent.h"
|
||||
#include "FireEvent.h"
|
||||
#include "WeaponFiredEvent.h"
|
||||
#include "GameConfig.h"
|
||||
#include "PositionComponent.h"
|
||||
#include "Tick.h"
|
||||
@@ -26,7 +26,7 @@ public:
|
||||
void tick(Tick currentTick,
|
||||
EntityAdmin& admin,
|
||||
BuildingSystem& buildings,
|
||||
std::vector<FireEvent>& outFireEvents);
|
||||
std::vector<WeaponFiredEvent>& outWeaponFiredEvents);
|
||||
|
||||
void applyPendingDamage(Tick currentTick, EntityAdmin& admin);
|
||||
|
||||
@@ -47,7 +47,7 @@ private:
|
||||
const FactionComponent& ownFaction,
|
||||
Tick currentTick,
|
||||
EntityAdmin& admin,
|
||||
std::vector<FireEvent>& out);
|
||||
std::vector<WeaponFiredEvent>& out);
|
||||
|
||||
const GameConfig& m_config;
|
||||
};
|
||||
|
||||
10
src/lib/eventsystem/event/ArenaInspectRequestedEvent.h
Normal file
10
src/lib/eventsystem/event/ArenaInspectRequestedEvent.h
Normal file
@@ -0,0 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include "Event.h"
|
||||
|
||||
class ArenaInspectRequestedEvent : public Event
|
||||
{
|
||||
public:
|
||||
explicit ArenaInspectRequestedEvent(int arenaIndex) : arenaIndex(arenaIndex) {}
|
||||
const int arenaIndex;
|
||||
};
|
||||
10
src/lib/eventsystem/event/ArenaStartRequestedEvent.h
Normal file
10
src/lib/eventsystem/event/ArenaStartRequestedEvent.h
Normal file
@@ -0,0 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include "Event.h"
|
||||
|
||||
class ArenaStartRequestedEvent : public Event
|
||||
{
|
||||
public:
|
||||
explicit ArenaStartRequestedEvent(int arenaIndex) : arenaIndex(arenaIndex) {}
|
||||
const int arenaIndex;
|
||||
};
|
||||
7
src/lib/eventsystem/event/BlueprintModeExitedEvent.h
Normal file
7
src/lib/eventsystem/event/BlueprintModeExitedEvent.h
Normal file
@@ -0,0 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "Event.h"
|
||||
|
||||
class BlueprintModeExitedEvent : public Event
|
||||
{
|
||||
};
|
||||
12
src/lib/eventsystem/event/BlueprintPlacementRequestedEvent.h
Normal file
12
src/lib/eventsystem/event/BlueprintPlacementRequestedEvent.h
Normal file
@@ -0,0 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include "Blueprint.h"
|
||||
#include "Event.h"
|
||||
|
||||
class BlueprintPlacementRequestedEvent : public Event
|
||||
{
|
||||
public:
|
||||
explicit BlueprintPlacementRequestedEvent(Blueprint blueprint)
|
||||
: blueprint(std::move(blueprint)) {}
|
||||
const Blueprint blueprint;
|
||||
};
|
||||
7
src/lib/eventsystem/event/BuilderModeExitedEvent.h
Normal file
7
src/lib/eventsystem/event/BuilderModeExitedEvent.h
Normal file
@@ -0,0 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "Event.h"
|
||||
|
||||
class BuilderModeExitedEvent : public Event
|
||||
{
|
||||
};
|
||||
11
src/lib/eventsystem/event/BuildingTypeSelectedEvent.h
Normal file
11
src/lib/eventsystem/event/BuildingTypeSelectedEvent.h
Normal file
@@ -0,0 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include "BuildingType.h"
|
||||
#include "Event.h"
|
||||
|
||||
class BuildingTypeSelectedEvent : public Event
|
||||
{
|
||||
public:
|
||||
explicit BuildingTypeSelectedEvent(BuildingType type) : type(type) {}
|
||||
const BuildingType type;
|
||||
};
|
||||
@@ -7,6 +7,23 @@ SET(HDRS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/GameSpeedChangedEvent.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/BossWaveUpdatedEvent.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/SchematicChoicesAvailableEvent.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/SelectionChangedEvent.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/GameOverEvent.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/BuilderModeExitedEvent.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/BlueprintModeExitedEvent.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/EscapeMenuRequestedEvent.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/DemolishModeChangedEvent.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/BuildingTypeSelectedEvent.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ExitBuilderModeRequestedEvent.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/DemolishModeToggleRequestedEvent.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/BlueprintPlacementRequestedEvent.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ExitBlueprintModeRequestedEvent.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/SpeedChangeRequestedEvent.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/LayoutDialogRequestedEvent.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/InspectWindowClosedEvent.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ArenaStartRequestedEvent.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ArenaInspectRequestedEvent.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/WeaponFiredEvent.h
|
||||
PARENT_SCOPE
|
||||
)
|
||||
|
||||
|
||||
10
src/lib/eventsystem/event/DemolishModeChangedEvent.h
Normal file
10
src/lib/eventsystem/event/DemolishModeChangedEvent.h
Normal file
@@ -0,0 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include "Event.h"
|
||||
|
||||
class DemolishModeChangedEvent : public Event
|
||||
{
|
||||
public:
|
||||
explicit DemolishModeChangedEvent(bool active) : active(active) {}
|
||||
const bool active;
|
||||
};
|
||||
@@ -0,0 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "Event.h"
|
||||
|
||||
class DemolishModeToggleRequestedEvent : public Event
|
||||
{
|
||||
};
|
||||
7
src/lib/eventsystem/event/EscapeMenuRequestedEvent.h
Normal file
7
src/lib/eventsystem/event/EscapeMenuRequestedEvent.h
Normal file
@@ -0,0 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "Event.h"
|
||||
|
||||
class EscapeMenuRequestedEvent : public Event
|
||||
{
|
||||
};
|
||||
@@ -0,0 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "Event.h"
|
||||
|
||||
class ExitBlueprintModeRequestedEvent : public Event
|
||||
{
|
||||
};
|
||||
@@ -0,0 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "Event.h"
|
||||
|
||||
class ExitBuilderModeRequestedEvent : public Event
|
||||
{
|
||||
};
|
||||
7
src/lib/eventsystem/event/GameOverEvent.h
Normal file
7
src/lib/eventsystem/event/GameOverEvent.h
Normal file
@@ -0,0 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "Event.h"
|
||||
|
||||
class GameOverEvent : public Event
|
||||
{
|
||||
};
|
||||
7
src/lib/eventsystem/event/InspectWindowClosedEvent.h
Normal file
7
src/lib/eventsystem/event/InspectWindowClosedEvent.h
Normal file
@@ -0,0 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "Event.h"
|
||||
|
||||
class InspectWindowClosedEvent : public Event
|
||||
{
|
||||
};
|
||||
12
src/lib/eventsystem/event/LayoutDialogRequestedEvent.h
Normal file
12
src/lib/eventsystem/event/LayoutDialogRequestedEvent.h
Normal file
@@ -0,0 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include "BuildingId.h"
|
||||
#include "Event.h"
|
||||
|
||||
class LayoutDialogRequestedEvent : public Event
|
||||
{
|
||||
public:
|
||||
explicit LayoutDialogRequestedEvent(BuildingId shipyardId)
|
||||
: shipyardId(shipyardId) {}
|
||||
const BuildingId shipyardId;
|
||||
};
|
||||
14
src/lib/eventsystem/event/SelectionChangedEvent.h
Normal file
14
src/lib/eventsystem/event/SelectionChangedEvent.h
Normal file
@@ -0,0 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "BuildingId.h"
|
||||
#include "Event.h"
|
||||
|
||||
class SelectionChangedEvent : public Event
|
||||
{
|
||||
public:
|
||||
explicit SelectionChangedEvent(std::vector<BuildingId> ids)
|
||||
: ids(std::move(ids)) {}
|
||||
const std::vector<BuildingId> ids;
|
||||
};
|
||||
10
src/lib/eventsystem/event/SpeedChangeRequestedEvent.h
Normal file
10
src/lib/eventsystem/event/SpeedChangeRequestedEvent.h
Normal file
@@ -0,0 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include "Event.h"
|
||||
|
||||
class SpeedChangeRequestedEvent : public Event
|
||||
{
|
||||
public:
|
||||
explicit SpeedChangeRequestedEvent(double multiplier) : multiplier(multiplier) {}
|
||||
const double multiplier;
|
||||
};
|
||||
17
src/lib/eventsystem/event/WeaponFiredEvent.h
Normal file
17
src/lib/eventsystem/event/WeaponFiredEvent.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
#include "Event.h"
|
||||
#include "Tick.h"
|
||||
|
||||
#include "entt/entity/entity.hpp"
|
||||
|
||||
struct WeaponFiredEvent : public Event
|
||||
{
|
||||
WeaponFiredEvent() = default;
|
||||
WeaponFiredEvent(entt::entity shooter, entt::entity target, Tick emittedAt)
|
||||
: shooter(shooter), target(target), emittedAt(emittedAt) {}
|
||||
|
||||
entt::entity shooter = entt::null;
|
||||
entt::entity target = entt::null;
|
||||
Tick emittedAt = 0;
|
||||
};
|
||||
@@ -136,7 +136,7 @@ void Simulation::reset(unsigned int seed)
|
||||
m_playerStation2Entity = entt::null;
|
||||
m_currentEnemyStationEntities[0] = entt::null;
|
||||
m_currentEnemyStationEntities[1] = entt::null;
|
||||
m_fireEvents.clear();
|
||||
m_weaponFiredEvents.clear();
|
||||
m_pendingSchematicChoices.clear();
|
||||
|
||||
m_admin.clear();
|
||||
@@ -246,7 +246,7 @@ void Simulation::tick()
|
||||
|
||||
// Step 8: combat resolution
|
||||
m_combatSystem->tick(m_currentTick, m_admin,
|
||||
*m_buildingSystem, m_fireEvents);
|
||||
*m_buildingSystem, m_weaponFiredEvents);
|
||||
|
||||
// Step 8b: deferred damage whose impact tick has arrived
|
||||
m_combatSystem->applyPendingDamage(m_currentTick, m_admin);
|
||||
@@ -745,10 +745,10 @@ bool Simulation::isItemUnlocked(const std::string& itemId) const
|
||||
// Drains
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
std::vector<FireEvent> Simulation::drainFireEvents()
|
||||
std::vector<WeaponFiredEvent> Simulation::drainWeaponFiredEvents()
|
||||
{
|
||||
std::vector<FireEvent> result;
|
||||
result.swap(m_fireEvents);
|
||||
std::vector<WeaponFiredEvent> result;
|
||||
result.swap(m_weaponFiredEvents);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
#include "BuildingType.h"
|
||||
#include "BuildingId.h"
|
||||
#include "EventHandler.h"
|
||||
#include "FireEvent.h"
|
||||
#include "WeaponFiredEvent.h"
|
||||
#include "GameConfig.h"
|
||||
#include "Rotation.h"
|
||||
#include "Tick.h"
|
||||
@@ -50,7 +50,7 @@ public:
|
||||
|
||||
// Returns all fire events accumulated since the last drain, clearing the
|
||||
// internal queue. Call once per rendered frame (REQ-SHP-FIRING-BEAM).
|
||||
std::vector<FireEvent> drainFireEvents();
|
||||
std::vector<WeaponFiredEvent> drainWeaponFiredEvents();
|
||||
|
||||
// Returns the pending schematic choices (empty if no drop is pending).
|
||||
const std::vector<SchematicChoiceOption>& getPendingSchematicChoices() const;
|
||||
@@ -165,6 +165,6 @@ private:
|
||||
std::unique_ptr<WaveSystem> m_waveSystem;
|
||||
std::unique_ptr<CombatSystem> m_combatSystem;
|
||||
|
||||
std::vector<FireEvent> m_fireEvents;
|
||||
std::vector<WeaponFiredEvent> m_weaponFiredEvents;
|
||||
std::vector<SchematicChoiceOption> m_pendingSchematicChoices;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user