↓Skip to main content

Meat Shields and Calcium Deposits

I did a bunch of art-ing. Turned some ideas from my notebook into assets I can use to explore different gameplay elements. Still very much placeholder art but it’s nice figuring out how to represent things and to play with ideas a bit.

Here’s “meat shield” which I think will just tank hits to give other organs a chance to grow and/or do damage. Or maybe “muscle wall.”

As far as code goes, I have too many steps for adding new organs. I wanna whittle it down so I’ll start by listing them:

  • organ.gd - the model
  • organ_def.tres - common organ parameters
  • organ_view.gd - script for the view
  • organ_view.tscn - the view
  • Add context menu item.
  • Add context menu handler which calls Blob method.
  • Add Blob method.

Eliminated the last two with some light refactoring. Instead of grow_pseudopod() and grow_tentacle() etc. it’s now just grow_organ(type: GDScript).

That last bit was a little tricky to figure out as well. At first I tried passing the class as a Variant but that didn’t work. Next I tried passing the class’ instantiator:

func grow_organ(coord: Vector2i, instantiator: Callable, organ_def: OrganDef) -> void:
	var cost: int = organ_def.biomass_cost
	if _remove_cells_until_available_biomass(cost, coord):
		adjust_available_biomass(-cost)
		var cell: Cell = get_cell(coord)
		cell.organ = instantiator.call(_sim, cell)

# Usage:
grow_organ(coord, PseudopodOrgan.new, PseudopodOrgan.get_organ_def())

But that was redundant, passing in two properties of the same class. Then I found the data type I needed. GDScript!

func grow_organ(coord: Vector2i, type: GDScript) -> void:
	var cost: int = type.call("get_organ_def").biomass_cost
	if _remove_cells_until_available_biomass(cost, coord):
		adjust_available_biomass(-cost)
		var cell: Cell = get_cell(coord)
		cell.organ = type.new(_sim, cell)

# Usage
grow_organ(coord, PseudopodOrgan)

Swute.

Using that newfound knowledge I streamlined the TileContextMenu class as well.

Found one more thing I need to add every time I add a new organ:

func _instantiate_organ_view(organ: Organ) -> OrganView:
	if organ is PseudopodOrgan:
		return _pseudopod_view_scene.instantiate()
	elif ...

I need to tie the view scenes to the organs. An easy way to do this is probably just to put it on the OrganDef resource.

…

And here are the meat shields in play!

Calcium deposits and the new ranged tentacles, too.