The Spatials V3 devblog 2016-03-21

Internal development notes, very slightly cleaned up and commented a week later.

TL;DR: Hospital and doctors, showers with soap stocks, bar with drinks and bartenders.

More work on vitals and their systems for this update. There’s been many tweaks and refinements to existing code, specially related to interaction with objects, logistics and job coordination.

- health: hospital objects
	need additional comp to filter out baddies and robots, so they don't have health vital tasks
		medicine-allowed-component
	hospital bed: bed-like comp for medicine-allowed-component entities
	just +delta health for now
		fixed very low one all the time, a bit higher when lying on an hospital bed
	doctor job: secondary hidden ent spawned from bed acts as job center for doctors
	fix: correct task heading for doctor job in hospital bed
	make dispenser work as pallet for meds
	doctor needs meds for medicine job
- child system: add flag to enable angle-relative iso bias position for children
	use in hospital bed, always pass offset for angle 0
	also add flags for angle inherit, both mirror and non

Hurting entities which have been authorized to receive medical care (by adding them a medicine-allowed-component) can now seek an hospital bed and lay on it. This makes them start healing back, albeit very slowly. It also makes a job available near the bed, the Medicine job. If an officer is flagged for this job, and meds are available, they will perform the job in front of the bed and make the rate of healing go much faster.

This system introduced the concept of a proxy child entity for the express purpose of having a secondary task for a single object. The bed is just the health provider, and is not involved with the Medicine job. For this purpose a new entity that has no visuals is created, and it is the holder of the Medicine job. It can monitor the status of its parent entity (the bed) and detect when it is being used, in order to flag the job as available. At the same time the vital system can detect when a doctor is is working in the child entity, and make healing go much faster.

- hygiene with showers
	basic shower system delta+ on vital plus hides actor, like bed
	shower has soap stock
	using the shower removes one soap unit from its stack
	if the stack is zero the shower does not work
Shower with soap

Another vital now has one system to satisfy its needs. When an officer is low on hygiene they can seek an empty shower. As long as the shower has stock of soap, it will be available for use. The stock control works the same as a storage pallet, but it’s limited to soap-like items.

- patch job/stock/vitals SMs to be able to interact with items inside unwalkable tiles
	use ecs-preferred-pos, assume less about tiles
	bug: delivery is dropping at the interaction position, not at the object center
		ItemDepositInRect shows proper center calc
		but the previous warpCenter (with markDirty) over the worker is being notices by ChildSystem
		ChildSystem is processed later, and it overrides the correct position, even if the entity "removed" the ChildComponent
		this is a side effect of the engine delaying entity edits until every system has been run
			instead of doing it after each system plus the dirty list
			---> don't do this for now, I'm sure there's code depending on the current behavior
				in particular UI tool code is bad at this
		fix by -1 the actual parent id/slot in the ChildComponent

You may have noticed in this update and previous ones that objects are now “storing” item stocks inside them, in a visible way. This is done by making them simply be a pallet. Unfortunately the stock control system for pallets assumed the tile occupied by the pallet object is walkable, which is correct for the visual design of a pallet, but not for most other objects. For this reason it has now been made possible to have a pallet based on a tile that is now walkable, while still allowing the item stack to be inside that tile. Entities interacting with this stack now use (ecs-preferred-center) which automatically finds a valid 4-neighbor walkable tile.

This surfaced a hard to find bug. Due to some optimizations in the engine, when a system has modified and entity, the changes to its component structure are not immediately applied. This was making it impossible for entities to drop the item they were carrying anywhere but at their feet (the ChildSystem was overriding the position of the item, even after it had been severed from its parent). For now this particular error has been fixed, but the general issue still persists. Some code depends on this optimization and more work is required to make sure it won’t be a problem again in the future.

- thirst
	simple self service
		existing refreshments counter plus any valid eating table
- thirst at bars
	second SM for thirst: drinking at a bar
		excludes out-of-stock like the shower, and checks additional flag to tell if a bartender is present
		final state consumes drink from stack, like shower
		move focus point to front with correct orientation
	second SM for bar: bartender job
		barman job is like the doctor job for the hospital bed, uses a proxy entity
		sets a flag component on its parent (the bar) to make it known there's a bartender present
Bar, bartender, patron

The final big thing for the week, a complex object that was a synthesis of how both the hospital bed and the shower worked. The bar table is, at the same time:

  • A workplace for the bartender job (via a proxy entity)
  • A storage pallet for any drink-like item category
  • An object that advertises being able to satisfy thirst, only when there’s at least one drink stored inside, and a bartender working on its proxy entity

Each aspect of this behavior is almost independent and decoupled from each other, and reuses the basic state machines of vitals, stock/logistic controls and jobs. It’s, in a way, an advanced test of the design of the V3 ECS engine, and it works!