Skip to content

Commit

Permalink
Added the new system and components to ruby, and made sure it runs.
Browse files Browse the repository at this point in the history
venter component is now initialized properly, system is no longer visible to scripts, and ventcompound now takes in an amount.

Iron now vents iron ions, however theres still alot of work left (eg, make it actually grab from the compondBagComponet when emitting, and only emit once a second or something like that)

They now vent every second, and a smaller amount, so they look like they are dissolving now

reudced scaling factor by 3 times in venter system

removed silly  log that i somehow placed there
  • Loading branch information
Untrustedlife authored and hhyyrylainen committed Feb 15, 2019
1 parent b435c73 commit e05e5a2
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 15 deletions.
6 changes: 3 additions & 3 deletions scripts/microbe_stage/setup.as
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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));
Expand Down
2 changes: 2 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
30 changes: 21 additions & 9 deletions src/microbe_stage/compound_venter_system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
6 changes: 3 additions & 3 deletions src/microbe_stage/compound_venter_system.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ class CompoundVenterComponent : public Leviathan::Component {
public:
CompoundVenterComponent();

double storageSpace;
double storageSpaceOccupied;
float x, y;

REFERENCE_HANDLE_UNCOUNTED_TYPE(CompoundVenterComponent);
Expand All @@ -32,6 +30,7 @@ class CompoundVenterComponent : public Leviathan::Component {
void
ventCompound(Leviathan::Position& pos,
CompoundId ourCompound,
double amount,
CellStageWorld& world);
};

Expand Down Expand Up @@ -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
4 changes: 4 additions & 0 deletions src/microbe_stage/generate_cell_stage_world.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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",
Expand Down Expand Up @@ -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()"
Expand Down
11 changes: 11 additions & 0 deletions src/scripting/script_initializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,8 @@ bool

static uint16_t ProcessorComponentTYPEProxy =
static_cast<uint16_t>(ProcessorComponent::TYPE);
static uint16_t CompoundVenterTYPEProxy =
static_cast<uint16_t>(CompoundVenterComponent::TYPE);
static uint16_t SpawnedComponentTYPEProxy =
static_cast<uint16_t>(SpawnedComponent::TYPE);
static uint16_t AgentCloudComponentTYPEProxy =
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit e05e5a2

Please sign in to comment.