#pragma once #include "objects/object.hpp" enum class ItemType : uint32_t ; enum class BuildingType { NONE, CRAFTING_STONE_1, CRAFTING_STONE_2, CRAFTING_STONE_3, CRAFTING_WOOD_1, CRAFTING_WOOD_2, CRAFTING_WOOD_3, CRAFTING_IRON_1, CRAFTING_IRON_2, CRAFTING_IRON_3, RESEARCH_STONE_1, RESEARCH_STONE_2, RESEARCH_STONE_3, RESEARCH_WOOD_1, RESEARCH_WOOD_2, RESEARCH_WOOD_3, RESEARCH_IRON_1, RESEARCH_IRON_2, RESEARCH_IRON_3, LAST, }; enum class BuildObjectType { NONE, WORKBENCH, // WALL, DOOR, etc. }; struct BuildingCost { ResourceType type; int amount; }; struct BuildingData_s { BuildingType type; std::string title; float building_duration; int level_max; int required_level; BuildingType research_by; std::initializer_list cost; TileType tileset_type; size_t tileset_id; size_t tileset_object_id; }; struct ActiveBuild { BuildingType type = BuildingType::NONE; BuildingData_s* data = nullptr; TilesetObject object; SDL_FPoint world_position = {0, 0}; SDL_Point tile_position; bool is_colliding = true; // Later add other types // WallTypes wall_type // DoorTypes door_type }; namespace BuildingData { extern std::vector building_data; extern SDL_Texture* workbench_texture; extern ActiveBuild active_build; bool Init(SDL_Renderer*); inline bool is_CraftingTable(BuildingType t) { return t >= BuildingType::CRAFTING_STONE_1 && t <= BuildingType::CRAFTING_IRON_3; } inline bool is_ResearchTable(BuildingType t) { return t >= BuildingType::RESEARCH_STONE_1 && t <= BuildingType::RESEARCH_IRON_3; } BuildingData_s* get_BuildingDataByType(BuildingType); std::vector get_CraftingTable(); std::vector get_ResearchTable(); void draw_WorkbenchMenu(SDL_Renderer* r, SDL_Rect win_size, std::vector& enabled_buildings); // it sucks to pass buildings BuildingType menu_DetectWorkbenchClick(const Input& input, SDL_Rect win_size, std::vector& enabled_buildings); int get_WorkbenchLevel(BuildingType); void update_ActiveBuildData(float pos_x, float pos_y); bool is_BuildingCollidingWithObject(); bool snap_BuildPosition(float in_x, float in_y); void draw_SelectedWorkbenchAt(SDL_Renderer* r); bool menu_Hovering(const Input& input, SDL_Rect win_size, std::vector& enabled_buildings); }