Skip to content

Model View Controller and Entity Controller System

Dan Royer edited this page Apr 28, 2023 · 1 revision

Model-View-Controller (MVC)

In the Model-View-Controller (MVC) paradigm, the responsibilities of each component are as follows:

  • Model: Represents the data and the business logic of the application. It handles data manipulation, storage, and retrieval. The model does not directly create or manage views.
  • View: Represents the user interface and is responsible for displaying the data from the model. The view does not interact with the model directly but receives updates through the controller.
  • Controller: Acts as an intermediary between the model and the view. It receives user input from the view, processes it, and updates the model accordingly. Then, it updates the view to reflect the changes in the model.

Entity-Component-System (ECS)

Entity-Component-System (ECS) is an architectural pattern commonly used in game development and other complex systems. It promotes flexibility, modularity, and maintainability by decoupling logic and data. The three main components of the ECS pattern are:

  • Entity: An entity is a unique identifier or a container for components. It does not contain any logic or behavior itself but serves as a way to aggregate and manage components. In a game, entities could represent game objects like characters, items, or terrain.
  • Component: Components are simple data structures that hold specific attributes or properties. They do not contain any logic or behavior. Components are attached to entities to give them characteristics, such as position, velocity, health, or rendering information. By adding or removing components, you can easily change the properties of an entity without modifying the underlying code.
  • System: Systems are responsible for the logic and behavior of the application. They process and manipulate components based on their data. Systems work on groups of entities that have specific sets of components, performing operations on the component data to achieve the desired behavior. For example, a PhysicsSystem might be responsible for updating the position and velocity of entities with Position and Velocity components.

Robot Overlord

in RobotOverlord,

  • the Model is Scene, which contains a tree of Entities. Entities have Components.
  • The Controller is a set of Systems that manipulate the Entities and Components.
  • The View(s) are provided by the Systems to the user.
  • Entities cannot create Views.
  • Components cannot create Views.
  • Views ask the Systems to modify the Scene.