The Spatials V3 devblog 2016-04-11
Internal development notes, very slightly cleaned up and commented a week later.
TL;DR: Officer death is now possible; visitors have been implemented using the docks as a test spawner, along with basic timer and shopping systems; a new way to run game logic that smooths out CPU usage over more frames; implement more existing systems for V2 objects.
- officer death from health vital
- fix: entity destroy is not clearing the info panel
GUIObserver stops all painting/callback when it receives a destroy notification
there's no higher-level observer over any bit of state that can paint on such a destroy
--> for now removeAllChildren() and move on
add alertlog for officer death
- fix ugly info panel display for officers
separate portrait area handled by info tool, fixed small panels shifted to right
- add names to corpses
Triggering entity removal when reaching 0 health points was already done in vulnerable-system
but it was disabled for officer entities. Officers have game model references from outside the ECS world so they need special handling when dying. This is now implemented, along with fixing the bugs that surfaced.
- visitors
dock as spawner
all docks just count number for current spawns until a limit, for now (no ship/travel logic)
timed feeling to indicate countdown
on countdown they go back to their dock/any dock/teleport away
use small SM for this
- fix: visitors are not chatting, visitors do not get attacked by hostiles
the "enemy matcher" used defaults to hardcoding only civ_spatials when passed civ is not spatials
-> actually build aggressors vs not aspect
Visitors are again implemented in the game. For now there’s no visitor space ships and the docks act as a random spawner. Visitors cherry pick some of the existing systems implemented for officers. For now they have the full compliment of vitals.
The visitor timer is also done, directing them to their original dock when it runs out (or any nearby dock in case it was destroyed, or just teleport out in case none exists). The timer is just a feeling in the mind of the visitor, and is handled and displayed as such. Its associated system is high priority and can only be interrupted by critical systems (being attacked, suffering from low vitals, etc).
- full 60fps per-frame logic tick
some logic gets a new fineTick at the full 60fps, in particular World::process
World::proces automatically converts step to 0 or 6*step
World::proces automatically converts phase to 6*phase
game tick units are still 0.1s
per-entity entropy allows to update on any sub-0.1s frame, all the frames
game is now smoother with very full worlds
fix some active pause bugs related to this
- fix: ugly z fight for held items, caused by new fine ticks feature
child system (which updates child pos) is lagging behind parent
since they can run at a diff subtick
-> run all phase 0 systems on the same subtick
Internally The Spatials has always been limited to 10 FPS, with the UI interpolating to whatever FPS the device is capable. Unfortunately as the game grows in complexity this was making the frames that run logic to last much more than the pure interpolation frames. This was a dumb way to distribute CPU usage.
Starting this week this has been changed to exploit a trick based on the system phase. In the V3 ECS engine a system can set a phase value that tells at which rate it is supposed to run. Many systems don’t need to run at every frame. Indeed a majority of the systems run just fine at phases of once every 2 or 3 seconds. The trick is that they are actually running at every frame, but use the phase as:
if ((currentTick + entity.entropy) % phase == 0) {
process(entity);
}
entropy
is a random 32 bit value in every entity. This way entity processing is spaced over all frames. Indeed every frame is running the system logic for a subset of the entities, even if the system phase indicates it to be run once every 3 seconds.
This was still bunching up processing in a few frames, since up until last week, the “frames” I mentioned earlier were the logic frames, running at a fixed rate of 10 FPS. This has been changed to run on every display frame, for a full 60 FPS, while still keeping the length of a logic frame at 0.1s. The game logic now keeps two counters, tick
and fineTick
, and uses fineTick
for the phase calculation. This has distributed CPU load over all possible frames, very noticeably smoothing out the simulation for busy stations.
- shopping AI for visitors
identify all pure shopping objects/products in current content
tag resources and introduce apt makers for objects
existing shop-component, product-component
make-pallet-station accepts extra object model keys for product filter and fixed product list
add "shopping list" AI for visitors
list of random products (for now)
at a lower-than vital prio, makes them busy to go and "buy" them from shops
this is plain consumption for now, like vitals
the SM must extend find-reqs in order to check for the right stock
add info panel with shopping list and tracking already bought products
Visitors now have a unique vital: shopping. Unlike other vitals this one is non-critical for the entity. It keeps a list of purely consumerist products to purchase. There’s still no credits transactions but the basic system is in place to support them now.
- add mechanics to more v2 objects
Some V2 objects are still orphaned for the game logic in V3. This week more of them were updated for the V3 systems, which is just adding the correct components to them. In some cases they have also been reworked to make use the new V3 capabilities, like layered objects: