diff --git a/scripts/microbe_stage/setup.as b/scripts/microbe_stage/setup.as index 07497ab9c52..1f0dca2a921 100644 --- a/scripts/microbe_stage/setup.as +++ b/scripts/microbe_stage/setup.as @@ -616,7 +616,7 @@ ObjectID createToxin(CellStageWorld@ world, Float3 pos) ObjectID createIron(CellStageWorld@ world, Float3 pos) { - // Chloroplasts + // Iron ObjectID ironEntity = world.CreateEntity(); auto position = world.Create_Position(ironEntity, pos, @@ -654,8 +654,8 @@ ObjectID createIron(CellStageWorld@ world, Float3 pos) } - world.GetCompoundCloudSystem().addCloud(SimulationParameters::compoundRegistry().getTypeId("iron"), 325000, Float3(pos.X, 0, pos.Z)); - + world.Create_CompoundVenterComponent(ironEntity); + world.Create_CompoundBagComponent(ironEntity); auto model = world.Create_Model(ironEntity, renderNode.Node, mesh); // Need to set the tint model.GraphicalObject.setCustomParameter(1, Ogre::Vector4(1, 1, 1, 1)); diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 94a66c626f0..5318108af09 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -51,6 +51,8 @@ set(GROUP_MICROBE_STAGE "microbe_stage/microbe_camera_system.h" "microbe_stage/process_system.cpp" "microbe_stage/process_system.h" + "microbe_stage/compound_venter_system.cpp" + "microbe_stage/compound_venter_system.h" "microbe_stage/simulation_parameters.cpp" "microbe_stage/simulation_parameters.h" "microbe_stage/spawn_system.cpp" diff --git a/src/microbe_stage/compound_venter_system.cpp b/src/microbe_stage/compound_venter_system.cpp index 1fe8dd05277..2c7e4d4baa8 100644 --- a/src/microbe_stage/compound_venter_system.cpp +++ b/src/microbe_stage/compound_venter_system.cpp @@ -16,28 +16,40 @@ using namespace thrive; + +// ------------------------------------ // +// CompoundVenterComponent +CompoundVenterComponent::CompoundVenterComponent() : Leviathan::Component(TYPE) +{} + void CompoundVenterSystem::Run(CellStageWorld& world) { if(!world.GetNetworkSettings().IsAuthoritative) return; - for(auto& value : CachedComponents.GetIndex()) { - - CompoundBagComponent& bag = std::get<0>(*value.second); - CompoundVenterComponent& venter = std::get<1>(*value.second); - Leviathan::Position& position = std::get<2>(*value.second); - - venter.ventCompound(position, - SimulationParameters::compoundRegistry.getTypeId("iron"), world); + const auto logicTime = Leviathan::TICKSPEED; + + timeSinceLastCycle++; + while(timeSinceLastCycle > TIME_SCALING_FACTOR) { + timeSinceLastCycle -= TIME_SCALING_FACTOR; + for(auto& value : CachedComponents.GetIndex()) { + CompoundBagComponent& bag = std::get<0>(*value.second); + CompoundVenterComponent& venter = std::get<1>(*value.second); + Leviathan::Position& position = std::get<2>(*value.second); + venter.ventCompound(position, + SimulationParameters::compoundRegistry.getTypeId("iron"), 5, + world); + } } } void CompoundVenterComponent::ventCompound(Leviathan::Position& pos, CompoundId compound, + double amount, CellStageWorld& world) { world.GetCompoundCloudSystem().addCloud( - compound, 15000, pos.Members._Position); + compound, amount * 1000, pos.Members._Position); } \ No newline at end of file diff --git a/src/microbe_stage/compound_venter_system.h b/src/microbe_stage/compound_venter_system.h index 90f65695b7f..30430a61f61 100644 --- a/src/microbe_stage/compound_venter_system.h +++ b/src/microbe_stage/compound_venter_system.h @@ -20,8 +20,6 @@ class CompoundVenterComponent : public Leviathan::Component { public: CompoundVenterComponent(); - double storageSpace; - double storageSpaceOccupied; float x, y; REFERENCE_HANDLE_UNCOUNTED_TYPE(CompoundVenterComponent); @@ -32,6 +30,7 @@ class CompoundVenterComponent : public Leviathan::Component { void ventCompound(Leviathan::Position& pos, CompoundId ourCompound, + double amount, CellStageWorld& world); }; @@ -79,6 +78,7 @@ class CompoundVenterSystem protected: private: - static constexpr double TIME_SCALING_FACTOR = 1000; + static constexpr double TIME_SCALING_FACTOR = 20; + int timeSinceLastCycle = 0; }; } // namespace thrive \ No newline at end of file diff --git a/src/microbe_stage/generate_cell_stage_world.rb b/src/microbe_stage/generate_cell_stage_world.rb index 2c8a0558420..db1e4defb63 100644 --- a/src/microbe_stage/generate_cell_stage_world.rb +++ b/src/microbe_stage/generate_cell_stage_world.rb @@ -21,6 +21,7 @@ generator.addInclude "microbe_stage/membrane_system.h" generator.addInclude "microbe_stage/compound_cloud_system.h" generator.addInclude "microbe_stage/process_system.h" +generator.addInclude "microbe_stage/compound_venter_system.h" generator.addInclude "microbe_stage/species_component.h" generator.addInclude "microbe_stage/spawn_system.h" generator.addInclude "microbe_stage/agent_cloud_system.h" @@ -36,6 +37,7 @@ "CellStageWorld", componentTypes: [ EntityComponent.new("ProcessorComponent", [ConstructorInfo.new([])]), EntityComponent.new("CompoundBagComponent", [ConstructorInfo.new([])]), + EntityComponent.new("CompoundVenterComponent", [ConstructorInfo.new([])]), EntityComponent.new("SpeciesComponent", [ConstructorInfo.new([ Variable.new("name", "std::string", memberaccess: "name", @@ -150,6 +152,8 @@ EntitySystem.new("ProcessSystem", ["CompoundBagComponent", "ProcessorComponent"], runtick: {group: 10, parameters: []}, visibletoscripts: true), + EntitySystem.new("CompoundVenterSystem", ["CompoundBagComponent", "CompoundVenterComponent", "Position"], + runtick: {group: 11, parameters: []}), EntitySystem.new("TimedLifeSystem", [], runtick: {group: 45, parameters: [ "ComponentTimedLifeComponent.GetIndex()" diff --git a/src/scripting/script_initializer.cpp b/src/scripting/script_initializer.cpp index 6b816a227fb..1d18c0db86b 100644 --- a/src/scripting/script_initializer.cpp +++ b/src/scripting/script_initializer.cpp @@ -431,6 +431,8 @@ bool static uint16_t ProcessorComponentTYPEProxy = static_cast(ProcessorComponent::TYPE); +static uint16_t CompoundVenterTYPEProxy = + static_cast(CompoundVenterComponent::TYPE); static uint16_t SpawnedComponentTYPEProxy = static_cast(SpawnedComponent::TYPE); static uint16_t AgentCloudComponentTYPEProxy = @@ -504,6 +506,15 @@ bool asMETHOD(ProcessorComponent, getCapacity), asCALL_THISCALL) < 0) { ANGELSCRIPT_REGISTERFAIL; } + // ------------------------------------ // + if(engine->RegisterObjectType( + "CompoundVenterComponent", 0, asOBJ_REF | asOBJ_NOCOUNT) < 0) { + ANGELSCRIPT_REGISTERFAIL; + } + + if(!bindComponentTypeId( + engine, "CompoundVenterComponent", &CompoundVenterTYPEProxy)) + return false; // ------------------------------------ // if(engine->RegisterObjectType(