Some code design on the binding agents

I’m trying to take a small break from thrive coding. To do that effectively I’m going to list down some thoughts about the binding agents design / a todo list I have currently in my head.

  • Add binding agents to organelles.json
  • Add a scene for the binding agents, just use a cube for now
  • Add the GUI thing in the editor (NEEDS AN ICON)
  • Check that placing the organelle and saving / loading in game doesn’t cause issues
  • Add property for microbe to check if it has binding agents
  • Add binding agents mode
    • Prevented if no binding agents
    • Cell flashes green or something
    • Consumes a bit of ATP per second
    • Enables extra collision callback
  • When cell hits another with the binding mode on and it is of the same species (and isn’t the player, so no AI can hijack the player) it binds
  • AI and movement is disabled on cells in a colony, except the leader
  • There probably needs to be some properties like PartOfColony, ColonyLeader, list of attached cells
  • The attached cells are parented under the leader cell’s Node
  • I’m a bit undecided but there’s two choices: try to make physics constraints between cells behave nicely or make it so that the extra organelle physics are added to the primary cell physics
  • Colony cells need to share their compounds so that each has the same amount
  • Reproduction probably needs to be blocked while part of a colony
  • The player GUI should probably show the total amount of compounds in their colony
  • Unbind key for ditching all the colony members
  • Once you leave a colony it should behave nicely with the reproduction indicator so you know when to ditch and go to the editor
  • Another thing that needs deciding: how to detect damage? Is it per cell or colony wide. Depending on the physics choice it might be a bit difficult to detect which cell was hit (especially with the godot physics index problem
  • Colonies need to have a movement speed that depends on all the cells in them
  • Saving while in a colony needs to work without problems
  • Agent shooting likely needs changes while in a colony (unless it is a single physics body and the collision ignore works correctly)
  • If dying is separate, the colony owner dying might need special handling.

I hope this goes to show that binding agents is a pretty massive feature with a lot of corner cases to fix.

  • The binding agent is just one hex.
  • The cell that is in binding mode that hits another cell (that is not already part of a colony) becomes the colony leader. In the case of player cell, the player can’t become a colony member, only a leader.
  • Two colonies can’t merge (if this is wanted to be added later then just one of the colony leaders stays the leader and all the new cells just move over to being members of the other colonies)
  • Collisions for attaching with binding agents is done by the normal collision detection between cells
  • AI should not be able to mutate binding agents, at least before the AI knows how to use them
1 Like

One more question: what happens if two cells in binding mode hit each other? Who gets leadership? Random chance?

Random chance, unless one of them is the player, in which case the player is always the colony leader.

Here are some questions that have came up while implementing the Binding Agents

  • I’ve noticed that ATP is a compound in the Microbe’s CompoundBag, but is also a seperate Compound in the Microbe class itself. Why is this the case?
  • How and where is movement speed calculated? I can’t seem to figure it out.
  • Ditching a member should be possible. Pressing U and than clicking on a member was suggested, but how should I detect clicking a cell that works well with chromatic aberration?
  • How should filling the reproduction bars work in a colony? Should the collected ammonia and phosphate be spread among all colony members and each cell puts the compounds towards the editor progress or should the collecting cell add the compounds to his own progress until it is full. When it is full it gives the compounds to the other cells, which can use the compounds to fill the bars. Or should the reproduction progress be shared among the whole colony? Or should I prohibit any resources going towards the reprodutction bars when in a colony?

Which variable are you referring to? I’m pretty sure it is not separate.
The reason why you sometimes see code like atp = SimulationParameters.Instance.GetCompound("atp"); is because those are used to cache the reference to the atp compound. That’s used to reduce the number of compound by name lookups.

Speed is only calculated as an estimate in the editor. Actual movement speed is the result of how much mass a cell has vs how much movement force it applies in Microbe._Process.

I suggested only allowing the entire colony to be disbanded by pressing a button.
If someone fixes this issue: then the math to find the clicked cell mostly will exist.

I think reproduction progress should be frozen while in the colony, but the bars for the player should fill based on their share of the colony compounds. So that if you click the detach from colony button, you’ll receive that fraction of compounds needed to reproduce as indicated as the reproduction bars.