ADD: ProducingSystem for placed Buildings
|
Before Width: | Height: | Size: 2.8 MiB After Width: | Height: | Size: 2.8 MiB |
28
assets/buildings/forest_hut/cabin.json
Normal file
@ -0,0 +1,28 @@
|
||||
{
|
||||
"name": "cabin",
|
||||
"allowedTileResources" : ["stone"],
|
||||
"cost" : {"wood": 15},
|
||||
"modelStages": [
|
||||
{
|
||||
"name": "cabin-base",
|
||||
"filename": "cabin.obj",
|
||||
"conditionKey": "fillRatio",
|
||||
"minValue": 0.0,
|
||||
"maxValue": 0.1
|
||||
},
|
||||
{
|
||||
"name": "cabin-one",
|
||||
"filename": "cabin_1.obj",
|
||||
"conditionKey": "fillRatio",
|
||||
"minValue": 0.1,
|
||||
"maxValue": 0.2
|
||||
},
|
||||
{
|
||||
"name": "cabin-two",
|
||||
"filename": "cabin_2.obj",
|
||||
"conditionKey": "fillRatio",
|
||||
"minValue": 0.2,
|
||||
"maxValue": 1.0
|
||||
}
|
||||
]
|
||||
}
|
||||
12
assets/buildings/forest_hut/cabin.mtl
Normal file
@ -0,0 +1,12 @@
|
||||
# Blender 5.0.1 MTL File: 'Untitled.blend'
|
||||
# www.blender.org
|
||||
|
||||
newmtl Material_0.003
|
||||
Ns 250.000000
|
||||
Ka 1.000000 1.000000 1.000000
|
||||
Ks 0.500000 0.500000 0.500000
|
||||
Ke 0.000000 0.000000 0.000000
|
||||
Ni 1.500000
|
||||
d 1.000000
|
||||
illum 2
|
||||
map_Kd textures/forest_hut.png
|
||||
528137
assets/buildings/forest_hut/cabin.obj
Normal file
BIN
assets/buildings/forest_hut/textures/Log_C1.jpg
Normal file
|
After Width: | Height: | Size: 1.5 MiB |
BIN
assets/buildings/forest_hut/textures/Log_NRM.jpg
Normal file
|
After Width: | Height: | Size: 1.2 MiB |
BIN
assets/buildings/forest_hut/textures/Log_Roughness.jpg
Normal file
|
After Width: | Height: | Size: 909 KiB |
BIN
assets/buildings/forest_hut/textures/Log_Spec.jpg
Normal file
|
After Width: | Height: | Size: 909 KiB |
BIN
assets/buildings/forest_hut/textures/Log_occlusion.jpg
Normal file
|
After Width: | Height: | Size: 809 KiB |
BIN
assets/buildings/forest_hut/textures/forest_hut.png
Normal file
|
After Width: | Height: | Size: 4.0 MiB |
@ -1,31 +0,0 @@
|
||||
# 3ds Max Wavefront OBJ Exporter v0.97b - (c)2007 guruware
|
||||
# File Created: 03.06.2013 16:07:05
|
||||
|
||||
newmtl 20958_Log_Cabin_v1
|
||||
Ns 18.0000
|
||||
Ni 1.5000
|
||||
d 1.0000
|
||||
Tr 0.0000
|
||||
Tf 1.0000 1.0000 1.0000
|
||||
illum 2
|
||||
Ka 1.0000 1.0000 1.0000
|
||||
Kd 1.0000 1.0000 1.0000
|
||||
Ks 0.3240 0.3240 0.3240
|
||||
Ke 0.0000 0.0000 0.0000
|
||||
map_Ka cabin.jpg
|
||||
map_Kd cabin.jpg
|
||||
map_Ks 20958_Log_Cabin_v1_specular.jpg
|
||||
|
||||
newmtl 02___Default
|
||||
Ns 10.0000
|
||||
Ni 1.5000
|
||||
d 1.0000
|
||||
Tr 0.0000
|
||||
Tf 1.0000 1.0000 1.0000
|
||||
illum 2
|
||||
Ka 1.0000 1.0000 1.0000
|
||||
Kd 1.0000 1.0000 1.0000
|
||||
Ks 0.0000 0.0000 0.0000
|
||||
Ke 0.0000 0.0000 0.0000
|
||||
map_Ka disc_diffuse.JPG
|
||||
map_Kd disc_diffuse.JPG
|
||||
150567
assets/cabin/cabin.obj
@ -49,38 +49,9 @@ void GameLayer::onAttach()
|
||||
|
||||
|
||||
|
||||
const std::string stoneMasonPath = "assets/buildings/stone_mason/";
|
||||
|
||||
auto cabinModel = AssetManager::loadModel("cabin", "assets/cabin/cabin.obj", "assets/cabin/cabin.jpg", loader);
|
||||
auto stoneMasonModel = AssetManager::loadModel("stoneMason", stoneMasonPath + "stone_mason.obj", stoneMasonPath + "stone_mason.png", loader);
|
||||
//entities.push_back(std::make_shared<Entity>(Entity(cabinModel, glm::vec3(0,0,0), 0,0,0, 1.f)));
|
||||
|
||||
/*auto transformComponent = std::make_shared<TransformComponent>(glm::vec3(0,0,0), glm::vec3(0), 1.f);
|
||||
auto modelComponent = std::make_shared<ModelComponent>(stoneMasonModel);
|
||||
|
||||
EntityID entityID = entityManager->createEntity();
|
||||
entityManager->addComponent(entityID, transformComponent);
|
||||
entityManager->addComponent(entityID, modelComponent);*/
|
||||
|
||||
|
||||
|
||||
AssetManager::loadAsset("assets/buildings/stone_mason/stone_mason.json", loader);
|
||||
auto modelStages = AssetManager::getModelStages("stoneMason");
|
||||
AssetManager::loadAsset("assets/buildings/forest_hut/cabin.json", loader);
|
||||
|
||||
auto transformComponent = std::make_shared<TransformComponent>(glm::vec3(0,0,0), glm::vec3(0), 1.f);
|
||||
auto modelComponent = std::make_shared<ModelComponent>(modelStages, "stoneMason");
|
||||
auto modelStateComponent = std::make_shared<ModelStateComponent>();
|
||||
auto producingComponent = std::make_shared<ProducingComponent>(RessourceType::STONE, 2, false);
|
||||
auto ownerComponent = std::make_shared<OwnerComponent>(gameMode->getCurrentPlayer());
|
||||
modelStateComponent->params["fillRatio"] = 0.f;
|
||||
modelComponent->updateStage("stone_mason_empty");
|
||||
EntityID entityID = entityManager->createEntity();
|
||||
entityManager->addComponent(entityID, transformComponent);
|
||||
entityManager->addComponent(entityID, modelComponent);
|
||||
entityManager->addComponent(entityID, modelStateComponent);
|
||||
entityManager->addComponent(entityID, producingComponent);
|
||||
entityManager->addComponent(entityID, ownerComponent);
|
||||
testEntity = entityID;
|
||||
|
||||
events.subscribe<TurnChangedEvent>([this](const TurnChangedEvent& event) {
|
||||
ProducingSystem::onTurnEnded(*entityManager);
|
||||
|
||||
@ -13,6 +13,11 @@ struct BuildingDefinition {
|
||||
std::unordered_map<RessourceType, int> resourceCosts;
|
||||
|
||||
std::string model;
|
||||
|
||||
int maxStorage;
|
||||
int baseAmountPerTurn;
|
||||
|
||||
RessourceType produces;
|
||||
};
|
||||
|
||||
#endif //DICEWARS_SIEDLER_BUILDINGDEFINITION_H
|
||||
@ -5,15 +5,17 @@
|
||||
#include "BuildingFactory.h"
|
||||
|
||||
#include "../../../engine/core/ECS/ModelComponent.h"
|
||||
#include "../../../engine/core/ECS/ModelStateComponent.h"
|
||||
#include "../../../engine/core/ECS/TransformComponent.h"
|
||||
#include "../../../engine/renderer/loader/AssetManager.h"
|
||||
#include "../ecs/components/ProducingComponent.h"
|
||||
|
||||
EntityID BuildingFactory::create(EntityManager &em, const BuildingDefinition &def,
|
||||
const TransformComponent &tileTransform, EntityID tileEntity, PlayerID owner) {
|
||||
|
||||
EntityID e = em.createEntity();
|
||||
|
||||
em.addComponent(e, std::make_shared<ModelComponent>(AssetManager::getModel(def.model), def.model));
|
||||
em.addComponent(e, std::make_shared<ModelComponent>(AssetManager::getModelStages(def.model), def.model));
|
||||
|
||||
if (def.type == BuildingType::FOREST_HUT) {
|
||||
em.addComponent(e, std::make_shared<TransformComponent>(
|
||||
@ -31,5 +33,14 @@ EntityID BuildingFactory::create(EntityManager &em, const BuildingDefinition &de
|
||||
|
||||
em.addComponent(e, std::make_shared<OwnerComponent>(owner));
|
||||
|
||||
auto modelStateComponent = std::make_shared<ModelStateComponent>();
|
||||
modelStateComponent->params["fillRatio"] = 0.f;
|
||||
|
||||
auto producingComponent = std::make_shared<ProducingComponent>( ProducingComponent(def.produces, def.baseAmountPerTurn, false));
|
||||
producingComponent->setMaxStorage(def.maxStorage);
|
||||
|
||||
em.addComponent(e, modelStateComponent);
|
||||
em.addComponent(e, producingComponent);
|
||||
|
||||
return e;
|
||||
}
|
||||
|
||||
@ -15,7 +15,8 @@ namespace TemporaryBuildingDefinitionFactory {
|
||||
BuildingType::FOREST_HUT,
|
||||
allowedTileResources,
|
||||
resourceCosts,
|
||||
"cabin"
|
||||
"cabin",
|
||||
20, 1, RessourceType::WOOD
|
||||
};
|
||||
}
|
||||
|
||||
@ -28,7 +29,8 @@ namespace TemporaryBuildingDefinitionFactory {
|
||||
BuildingType::FOREST_HUT,
|
||||
allowedTileResources,
|
||||
resourceCosts,
|
||||
"stoneMason"
|
||||
"stoneMason",
|
||||
20, 1, RessourceType::STONE
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@ -12,7 +12,6 @@
|
||||
#include "../components/ProducingComponent.h"
|
||||
|
||||
void ProducingSystem::onTurnEnded(EntityManager &em) {
|
||||
printf("Updating producing entities...\n");
|
||||
for (const EntityID e : em.getAllEntities()) {
|
||||
const auto prod = em.getComponent<ProducingComponent>(e);
|
||||
const auto modelState = em.getComponent<ModelStateComponent>(e);
|
||||
@ -31,6 +30,5 @@ void ProducingSystem::onTurnEnded(EntityManager &em) {
|
||||
|
||||
float fillRatio = static_cast<float>(prod->getStorage()) / static_cast<float>(prod->getMaxStorage());
|
||||
modelState->params["fillRatio"] = fillRatio;
|
||||
printf("Updated fillRatio: %f\n", fillRatio);
|
||||
}
|
||||
}
|
||||
|
||||