91 lines
2.8 KiB
C++
91 lines
2.8 KiB
C++
#pragma once
|
||
|
||
#include <map>
|
||
#include <optional>
|
||
#include <string>
|
||
#include <vector>
|
||
|
||
#include <QPoint>
|
||
#include <QSize>
|
||
|
||
#include "BuildingType.h"
|
||
#include "EntityId.h"
|
||
#include "Item.h"
|
||
#include "ItemType.h"
|
||
#include "Port.h"
|
||
#include "Rotation.h"
|
||
#include "Tick.h"
|
||
|
||
// Per-material input buffer for a production building.
|
||
struct InputBuffer
|
||
{
|
||
std::map<ItemType, int> counts; // current item counts per material
|
||
std::map<ItemType, int> caps; // max items per material (2× per-cycle requirement)
|
||
};
|
||
|
||
// Output buffer shared by all output materials for a production building.
|
||
struct OutputBuffer
|
||
{
|
||
std::vector<Item> items;
|
||
int capacity = 0; // 2× per-cycle output; 1× for ReprocessingPlant
|
||
};
|
||
|
||
// Active production cycle for a building.
|
||
struct Production
|
||
{
|
||
std::string recipeId;
|
||
Tick completesAt = 0;
|
||
std::vector<Item> chosenOutputs; // resolved at cycle start (reprocessing rolls here)
|
||
};
|
||
|
||
// A building placed on the map that is still under construction.
|
||
// Occupies tiles but does not produce.
|
||
struct ConstructionSite
|
||
{
|
||
EntityId id = kInvalidEntityId;
|
||
QPoint anchor; // top-left of body bounding box
|
||
QSize footprint;
|
||
std::vector<QPoint> bodyCells; // absolute world tile coordinates
|
||
Rotation rotation = Rotation::East;
|
||
BuildingType type = BuildingType::Miner;
|
||
std::string recipeId; // may be configured before completion
|
||
Tick completesAt = 0; // 0 = queued but not yet started
|
||
};
|
||
|
||
// Weapon state for stationary structures (defence stations).
|
||
// Distinct from Ship::Weapon; stations have no movement intent.
|
||
struct StationWeapon
|
||
{
|
||
float damage;
|
||
float range;
|
||
float fireRateHz;
|
||
float cooldownTicks;
|
||
std::optional<EntityId> currentTarget;
|
||
};
|
||
|
||
// A fully constructed, operational building.
|
||
struct Building
|
||
{
|
||
EntityId id = kInvalidEntityId;
|
||
QPoint anchor; // top-left of body bounding box
|
||
QSize footprint;
|
||
Rotation rotation = Rotation::East;
|
||
BuildingType type = BuildingType::Miner;
|
||
float hp = 0.0f;
|
||
float maxHp = 0.0f;
|
||
std::string recipeId; // empty = none selected
|
||
|
||
InputBuffer inputBuffer;
|
||
OutputBuffer outputBuffer;
|
||
std::optional<Production> production;
|
||
|
||
// Pre-computed from surface mask at placement; in absolute world coordinates.
|
||
std::vector<QPoint> bodyCells;
|
||
std::vector<Port> outputPorts;
|
||
std::vector<Port> inputPorts; // perimeter tiles (minus output-port tiles),
|
||
// direction pointing INTO building
|
||
|
||
// Set only for defence stations; nullopt for all other building types.
|
||
std::optional<StationWeapon> weapon;
|
||
};
|