Files
dota_factory/src/lib/sim/Building.h

83 lines
2.6 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#pragma once
#include <map>
#include <optional>
#include <string>
#include <vector>
#include <QPoint>
#include <QSize>
#include "BuildingType.h"
#include "BuildingId.h"
#include "entt/entity/entity.hpp"
#include "Item.h"
#include "ItemType.h"
#include "Port.h"
#include "Rotation.h"
#include "ShipLayout.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
{
BuildingId id = kInvalidBuildingId;
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
std::optional<ShipLayoutConfig> shipLayout;
};
// A fully constructed, operational building.
struct Building
{
BuildingId id = kInvalidBuildingId;
QPoint anchor; // top-left of body bounding box
QSize footprint;
Rotation rotation = Rotation::East;
BuildingType type = BuildingType::Miner;
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
// Module layout for shipyards (REQ-MOD-LAYOUT).
std::optional<ShipLayoutConfig> shipLayout;
};