4

Well, concerning "The Sims" article you are reffering to that actually could mean a lot of different things. But the core idea as I get it is that each object can expose a list of "functions" that can be applied to it. For example item : ["destroy", "pick up", "eat", "cook"] and then the actor ...


2

With strong typed languages, you can create this functionality broadcast in public interfaces by the way of interfaces. Say: interface IDamageSource {     DamagePoints Damage { get; }     void Consume( DamagePoints points ); } interface IDamageTarget {    void TakeDamage( DamageSource source ); } interface IFixTarget {     FixMaterial[] FixCost();     void ...


1

Entity component systems store data in one of three ways: Centrally allocated arrays, accessable by all systems. Contigious arrays of subsets of components that each system is interested in. Contigious array of "entities" allocated in a centrally located memory buffer. Naughty Dog uses scenario 1. An entity in this context is just a collection of ...


1

Assuming the browser suspends the execution of the code of the page, when the browser gets back go your game you should only run the equivalent of one normal frame. Running a 5 second frame does not make sense when your game is made to run frames 60 times per second. Imagine all the collisions that will be missed. Instead of using a delta-time based like you ...


1

The browser suspends your page to save CPU power during that time. When tabbing back in the physics engine sees 1 frame with a 5 seconds duration so it moves the objects for that entire 5 seconds before processing friction and what not. The first thing is your velocity * friction calculation should be a power function, not a linear factor of time. For ...


1

Those Archetypes are IEnumerable<TComponentKind>, where TComponentKind is what you use to identify components. You can, of course, do better than that. For example, they could be TComponentKind[], or HashSet<TComponentKind>. TComponentKind could be string, Type or even int (and you use bit flags to identify components, in which case the Archetype ...


1

I'd argue you should keep the implementation alongside the definition in this case. It gives you a lot of flexibility. But .. You don't want to be serialising methods, so your players/NPCs should have references to the above via an ID/Key when serialised. [assuming the hotkey is not user-configurable, it's fine there. If it is, that should live elsewhere as ...


1

When you do "ECS by the book", then all logic belongs into systems and all data belongs into components. That means a component should never have a function. What's a rather common architecture in ECS for collision handling is one system which detects collisions and other systems which then react on the collisions detected by the first system. This ...


1

A common pattern in ECS is to add a single-use, disposable tag component after a collision. So you have a collision detection system. If you detect a collision between say a spikes and a zombie, you add a WalkedOnSpikes component to your zombie, and a ZombieWalkedOnMe component to your spike. Then you have separate systems that query for any zombies with the ...


Only top voted, non community-wiki answers of a minimum length are eligible