Best practices for developing advanced blocks + potential new utility #2779
Labels
Category: Doc
Requests, Issues and Changes targeting javadoc and module documentation
Category: Gameplay Content
Requests, Issues and Changes targeting gameplay mechanics and content
Category: Performance
Requests, Issues and Changes targeting performance
Status: Needs Investigation
Requires to be debugged or checked for feasibility, etc.
Topic: Architecture
Requests, Issues and Changes related to software architecture, programming patterns, etc.
Terasology/FunnyBlocks#8 got me thinking a bit about how somebody would naturally approach designing new advanced blocks, and made me realize we don't really have any good guidance for it.
Specifically that PR encounters a few issues we've hit before (like for several GCI tasks) and while I get the feeling they are problematic I am not sure how badly so am curious what others would think.
Possible code smells
BreakingBlock
is persisted so it can be tested. Maybe we could use some new interaction events? See section belowUpdateSubscriberSystem
that could possibly be avoided: theBreakingSystem
checks in the loop for anyBreakingBlock
that may need to "tick" - could this be handled via event or scheduler instead?update()
usage: something that needs to make a change every tick for sure, like a particle system emitter. What might be a good cut-off duration to suggest moving from usingupdate()
to the scheduler instead?entityManager.getEntitiesWith()
to process: in this case blocks actually being in the progress of breaking might be rare, as would be stepping on one. Could new events help trigger processing more selectively?getEntitiesWith
: One-time searches like figuring out an actual count to use in some form of logic, or getting a bunch of entities to transform in some fashionSome of these cases probably need some researching with a profiler in hand to actually test the performance when large quantity effects are in play. Maybe a decent area to write some benchmarking tests for?
New utility
A lot of functionality revolving around blocks will tend to want information for when a player or creature bumps into or steps on specific blocks. Could it make sense to add some outright
WalkedOnEvent
,BumpedIntoEvent
,WalkUnderEvent
etc that are triggered by a single event handler forCharacterMoveInputEvent
rather than have a bunch of modules all implementing their own handler just to see when it matters?At present the specific block under the player's crosshairs will have a temporary event spun up to then test an interaction with (or maybe I'm thinking of when a player starts hitting a block - a temporary entity is spun up to contain the health info). Similar functionality for blocks stepped on, stepped under, or brushed up against could be very useful, and avoid permanent entities for "advanced" blocks that don't need to constantly store unique data (all following the same defaults like a block type but with an entity involved)
@portokaliu added new utility a little while back from the physics system, like when you throw an item against a wall, resulting in a new event to catch. I wonder how many more simple things like that we could add to make new content easier and more performant?
Related
gestalt-entity-system
introduces a way to index entities - but I am not sure about the details or if it would change any related math hereThe text was updated successfully, but these errors were encountered: