SlideShare a Scribd company logo
1 of 30
Download to read offline
Entity Component System
Lunch & Learn 2015-01-21
What is ECS?
ECS is a pattern that makes a distinction between
entities, components and systems.
An entity is a discrete object representing an actor in a
simulated space. Realize first that we are simulating a
universe - the game’s universe. All the visible, tangible
‘things’ in the universe can be represented as entities.
Entity
Characters
Items
Interactive objects
Static objects
Can you think of some more examples?
Light source?
Particles?
A component describes a singular behavior ascribed to an
entity. The name of a component should ideally communicate
what behavior the entity will exhibit, even to someone who
isn’t familiar with the implementation.
Component
Component Behavior
Transform Transforms the entities position, rotation and scale (from the origin).
Health
Attributes a health value, which can be increased or decreased by receiving
‘heal’ or ‘damage’ messages. At zero, it fires the message ‘died’.
Collider
Entity can collide with others. The implementation will depend on the physics
system, but this could be an abstract base component.
DamageOnCollision
Will send a ‘damage’ message with a data-defined value to any entities it
collides with. Requires its entity to have a Collider component.
ParticleEmitter
The entity will emit particles, the nature of which depends on data-defined
values.
Systems iterate over lists of components to perform low level
functions such as rendering graphics, performing physics
calculations, or pathfinding. Not every component needs to
be managed by a system. Components should use systems
to offload computationally difficult or shared workloads.
System
If a system is totally unrelated to gameplay it
might actually be a service.
Renderer
Finder
Parser
Builder
Loader
Calculator
Publisher
Manager
Verb suffixes
Why are we using ECS?
Inheritance
Composition
Classical Inheritance Entity Component
Pros
● Sub-classing can feel
intuitive
● Lots of existing research
● Shorter, less complex code
● Promotes thinking in terms
of behaviors
● Very flexible
● Emergent behavior
● Enables scripting of
behavior by non-techies
Cons
● Leads to highly complex
code
● Less flexible
● Difficult to apply correctly,
easy to mis-use
● Good components require
more thinking about design
Disclaimer
ECS is not the be-all end-all solution to game
programming.
How should we use ECS?
Components
● Should be generic and re-usable.
● Configure via parameters from data, or from a system.
● Should describe a singular behavior.
● Avoid depending on other components too much.
● Try to avoid writing very large or complex components. It’s
usually a sign you could split up your code further.
Think in terms of behavior
What do I want my entity to do? What is that
behavior called? Can I simplify it?
Generic versus Specific
Exercise: Components
● Think about the game you’re currently working on.
● As a group, brainstorm components that the game
currently uses, or new ones that you could write for it.
● Write them down on post it notes.
● Try organizing them a bit, are there similarities or overlaps
in functionality?
● Do the component names make it obvious what they do?
Decouple components
using messages
Messages
● Should be generic and re-usable.
● Pass useful information as parameters.
● Whenever you need to react to an event, first look if a
suitable message is being sent.
● Don’t use messages if a component has a hard
dependency that can only be solved by one specific kind
of component, just use a reference in that case.
Generic versus Specific
Exercise: Messages
● Brainstorm messages that your components might send
or receive.
● Write them down on post it notes.
● Can you show which components send which messages?
● Are all messages sent by components?
● Do the message names make it obvious what data or
event they are conveying?
Always remember the SRP
Single Responsibility Principle
Thanks for listening!
Questions?

More Related Content

Similar to Entity Component System

Knowledge-Based Agent in Artificial intelligence.pptx
Knowledge-Based Agent in Artificial intelligence.pptxKnowledge-Based Agent in Artificial intelligence.pptx
Knowledge-Based Agent in Artificial intelligence.pptx
suchita74
 
Object Oriented Analysis And Design
Object Oriented Analysis And DesignObject Oriented Analysis And Design
Object Oriented Analysis And Design
Sahil Mahajan
 
The delineation principle A functional specification is not necessaril.docx
The delineation principle A functional specification is not necessaril.docxThe delineation principle A functional specification is not necessaril.docx
The delineation principle A functional specification is not necessaril.docx
chrisflorence13710
 
Threading Successes 05 Smoke
Threading Successes 05   SmokeThreading Successes 05   Smoke
Threading Successes 05 Smoke
guest40fc7cd
 
OGDC 2014: Component based entity system mobile game development
OGDC 2014: Component based entity system mobile game developmentOGDC 2014: Component based entity system mobile game development
OGDC 2014: Component based entity system mobile game development
GameLandVN
 

Similar to Entity Component System (20)

Grasp patterns and its types
Grasp patterns and its typesGrasp patterns and its types
Grasp patterns and its types
 
Causal emergence and artificial intelligence.pdf
Causal emergence and artificial intelligence.pdfCausal emergence and artificial intelligence.pdf
Causal emergence and artificial intelligence.pdf
 
Entity Component Systems
Entity Component SystemsEntity Component Systems
Entity Component Systems
 
The Cost of Complexity
The Cost of ComplexityThe Cost of Complexity
The Cost of Complexity
 
Knowledge-Based Agent in Artificial intelligence.pptx
Knowledge-Based Agent in Artificial intelligence.pptxKnowledge-Based Agent in Artificial intelligence.pptx
Knowledge-Based Agent in Artificial intelligence.pptx
 
Nn kb
Nn kbNn kb
Nn kb
 
Automatic Assessment of Failure Recovery in Erlang Applications
Automatic Assessment of Failure Recovery in Erlang ApplicationsAutomatic Assessment of Failure Recovery in Erlang Applications
Automatic Assessment of Failure Recovery in Erlang Applications
 
Neural Network in Knowledge Bases
Neural Network in Knowledge BasesNeural Network in Knowledge Bases
Neural Network in Knowledge Bases
 
Object Oriented Analysis And Design
Object Oriented Analysis And DesignObject Oriented Analysis And Design
Object Oriented Analysis And Design
 
Week Five, Game Design
Week Five, Game DesignWeek Five, Game Design
Week Five, Game Design
 
Better Game Design with Object-Oriented User Experience (OOUX)
Better Game Design with Object-Oriented User Experience (OOUX)Better Game Design with Object-Oriented User Experience (OOUX)
Better Game Design with Object-Oriented User Experience (OOUX)
 
The delineation principle A functional specification is not necessaril.docx
The delineation principle A functional specification is not necessaril.docxThe delineation principle A functional specification is not necessaril.docx
The delineation principle A functional specification is not necessaril.docx
 
Get into Functional Programming with Clojure
Get into Functional Programming with ClojureGet into Functional Programming with Clojure
Get into Functional Programming with Clojure
 
Think components. March 2017
Think components. March 2017Think components. March 2017
Think components. March 2017
 
Fun with Functional Programming in Clojure
Fun with Functional Programming in ClojureFun with Functional Programming in Clojure
Fun with Functional Programming in Clojure
 
systems_descriptions.pdf
systems_descriptions.pdfsystems_descriptions.pdf
systems_descriptions.pdf
 
Fun with Functional Programming in Clojure - John Stevenson - Codemotion Amst...
Fun with Functional Programming in Clojure - John Stevenson - Codemotion Amst...Fun with Functional Programming in Clojure - John Stevenson - Codemotion Amst...
Fun with Functional Programming in Clojure - John Stevenson - Codemotion Amst...
 
Threading Successes 05 Smoke
Threading Successes 05   SmokeThreading Successes 05   Smoke
Threading Successes 05 Smoke
 
OGDC 2014: Component based entity system mobile game development
OGDC 2014: Component based entity system mobile game developmentOGDC 2014: Component based entity system mobile game development
OGDC 2014: Component based entity system mobile game development
 
R1x g02 enterprise architecture i
R1x g02 enterprise architecture iR1x g02 enterprise architecture i
R1x g02 enterprise architecture i
 

Recently uploaded

JustNaik Solution Deck (stage bus sector)
JustNaik Solution Deck (stage bus sector)JustNaik Solution Deck (stage bus sector)
JustNaik Solution Deck (stage bus sector)
Max Lee
 
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
Alluxio, Inc.
 

Recently uploaded (20)

CompTIA Security+ (Study Notes) for cs.pdf
CompTIA Security+ (Study Notes) for cs.pdfCompTIA Security+ (Study Notes) for cs.pdf
CompTIA Security+ (Study Notes) for cs.pdf
 
JustNaik Solution Deck (stage bus sector)
JustNaik Solution Deck (stage bus sector)JustNaik Solution Deck (stage bus sector)
JustNaik Solution Deck (stage bus sector)
 
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...
 
AI/ML Infra Meetup | ML explainability in Michelangelo
AI/ML Infra Meetup | ML explainability in MichelangeloAI/ML Infra Meetup | ML explainability in Michelangelo
AI/ML Infra Meetup | ML explainability in Michelangelo
 
Microsoft 365 Copilot; An AI tool changing the world of work _PDF.pdf
Microsoft 365 Copilot; An AI tool changing the world of work _PDF.pdfMicrosoft 365 Copilot; An AI tool changing the world of work _PDF.pdf
Microsoft 365 Copilot; An AI tool changing the world of work _PDF.pdf
 
Crafting the Perfect Measurement Sheet with PLM Integration
Crafting the Perfect Measurement Sheet with PLM IntegrationCrafting the Perfect Measurement Sheet with PLM Integration
Crafting the Perfect Measurement Sheet with PLM Integration
 
Advanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should KnowAdvanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should Know
 
5 Reasons Driving Warehouse Management Systems Demand
5 Reasons Driving Warehouse Management Systems Demand5 Reasons Driving Warehouse Management Systems Demand
5 Reasons Driving Warehouse Management Systems Demand
 
Workforce Efficiency with Employee Time Tracking Software.pdf
Workforce Efficiency with Employee Time Tracking Software.pdfWorkforce Efficiency with Employee Time Tracking Software.pdf
Workforce Efficiency with Employee Time Tracking Software.pdf
 
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
 
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
 
A Guideline to Zendesk to Re:amaze Data Migration
A Guideline to Zendesk to Re:amaze Data MigrationA Guideline to Zendesk to Re:amaze Data Migration
A Guideline to Zendesk to Re:amaze Data Migration
 
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAGAI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
 
KLARNA - Language Models and Knowledge Graphs: A Systems Approach
KLARNA -  Language Models and Knowledge Graphs: A Systems ApproachKLARNA -  Language Models and Knowledge Graphs: A Systems Approach
KLARNA - Language Models and Knowledge Graphs: A Systems Approach
 
INGKA DIGITAL: Linked Metadata by Design
INGKA DIGITAL: Linked Metadata by DesignINGKA DIGITAL: Linked Metadata by Design
INGKA DIGITAL: Linked Metadata by Design
 
how-to-download-files-safely-from-the-internet.pdf
how-to-download-files-safely-from-the-internet.pdfhow-to-download-files-safely-from-the-internet.pdf
how-to-download-files-safely-from-the-internet.pdf
 
Secure Software Ecosystem Teqnation 2024
Secure Software Ecosystem Teqnation 2024Secure Software Ecosystem Teqnation 2024
Secure Software Ecosystem Teqnation 2024
 
A Comprehensive Appium Guide for Hybrid App Automation Testing.pdf
A Comprehensive Appium Guide for Hybrid App Automation Testing.pdfA Comprehensive Appium Guide for Hybrid App Automation Testing.pdf
A Comprehensive Appium Guide for Hybrid App Automation Testing.pdf
 
Agnieszka Andrzejewska - BIM School Course in Kraków
Agnieszka Andrzejewska - BIM School Course in KrakówAgnieszka Andrzejewska - BIM School Course in Kraków
Agnieszka Andrzejewska - BIM School Course in Kraków
 
10 Essential Software Testing Tools You Need to Know About.pdf
10 Essential Software Testing Tools You Need to Know About.pdf10 Essential Software Testing Tools You Need to Know About.pdf
10 Essential Software Testing Tools You Need to Know About.pdf
 

Entity Component System

  • 1. Entity Component System Lunch & Learn 2015-01-21
  • 3. ECS is a pattern that makes a distinction between entities, components and systems.
  • 4. An entity is a discrete object representing an actor in a simulated space. Realize first that we are simulating a universe - the game’s universe. All the visible, tangible ‘things’ in the universe can be represented as entities. Entity
  • 6. Can you think of some more examples?
  • 9. A component describes a singular behavior ascribed to an entity. The name of a component should ideally communicate what behavior the entity will exhibit, even to someone who isn’t familiar with the implementation. Component
  • 10. Component Behavior Transform Transforms the entities position, rotation and scale (from the origin). Health Attributes a health value, which can be increased or decreased by receiving ‘heal’ or ‘damage’ messages. At zero, it fires the message ‘died’. Collider Entity can collide with others. The implementation will depend on the physics system, but this could be an abstract base component. DamageOnCollision Will send a ‘damage’ message with a data-defined value to any entities it collides with. Requires its entity to have a Collider component. ParticleEmitter The entity will emit particles, the nature of which depends on data-defined values.
  • 11. Systems iterate over lists of components to perform low level functions such as rendering graphics, performing physics calculations, or pathfinding. Not every component needs to be managed by a system. Components should use systems to offload computationally difficult or shared workloads. System
  • 12. If a system is totally unrelated to gameplay it might actually be a service.
  • 14. Why are we using ECS?
  • 17. Classical Inheritance Entity Component Pros ● Sub-classing can feel intuitive ● Lots of existing research ● Shorter, less complex code ● Promotes thinking in terms of behaviors ● Very flexible ● Emergent behavior ● Enables scripting of behavior by non-techies Cons ● Leads to highly complex code ● Less flexible ● Difficult to apply correctly, easy to mis-use ● Good components require more thinking about design
  • 18. Disclaimer ECS is not the be-all end-all solution to game programming.
  • 19. How should we use ECS?
  • 20. Components ● Should be generic and re-usable. ● Configure via parameters from data, or from a system. ● Should describe a singular behavior. ● Avoid depending on other components too much. ● Try to avoid writing very large or complex components. It’s usually a sign you could split up your code further.
  • 21. Think in terms of behavior What do I want my entity to do? What is that behavior called? Can I simplify it?
  • 23. Exercise: Components ● Think about the game you’re currently working on. ● As a group, brainstorm components that the game currently uses, or new ones that you could write for it. ● Write them down on post it notes. ● Try organizing them a bit, are there similarities or overlaps in functionality? ● Do the component names make it obvious what they do?
  • 25. Messages ● Should be generic and re-usable. ● Pass useful information as parameters. ● Whenever you need to react to an event, first look if a suitable message is being sent. ● Don’t use messages if a component has a hard dependency that can only be solved by one specific kind of component, just use a reference in that case.
  • 27. Exercise: Messages ● Brainstorm messages that your components might send or receive. ● Write them down on post it notes. ● Can you show which components send which messages? ● Are all messages sent by components? ● Do the message names make it obvious what data or event they are conveying?
  • 28. Always remember the SRP Single Responsibility Principle