This project is read-only.

How the Engine Works

Framework Services Overview

ZOE leverages XNA's game service framework to provide components with access to critical, globally relevant features that could not otherwise be encapsulated into a specialized component or set of components. The engine refers to them as services, both because it is a rather accurate description of their function and because this is the term that XNA uses to describe them as well. These services are registered from within your Game's constructor in the following manner: 

// Set up services.
            Components.Add(new SceneProvider(this));
            Components.Add(new ContentProvider(this));
            Components.Add(new InputProvider(this));

And may be accessed from within the Game class at any point thereafter like this:

// Get reference while also making sure services were properly installed.
            scene = Services.GetService(typeof(ISceneService)) as ISceneService;
            content = Services.GetService(typeof(IContentService)) as IContentService;

The services are registered directly with the Game class, but are recalled by way of the interface they implement. In this sample, it is also important to note the naming conventions in use. The interfaces that expose access to these features take a name ending in "service" (IContentService, ISceneService, etc) while the concrete implementations of these services are referred to as providers. It is important to differentiate between these two when implementing your own services. The way in which the various services interact with the core framework is illustrated below:

Services exist solely to facilitate the flow of external data (storage, input, external libraries, etc) into and out of the framework. Though you may create entirely new services and providers for your specific needs, you should first exhaust every possible implementation that allows your new feature to exist within the component framework as we pay a high cost for each additional service. To learn more about each service, click on the respective icon below.

 

Entities

Entities are the standard unit of measure for game objects in the ZOE engine. They have no inherent function other than to serve as a container for a set of components and facilitate their communication with each other and with the components of other entities, if necessary. Entities are collections of components that may be added to, subtracted from and iterated over. An entity is described by the components that comprise it, and is completely ignorant to the type of components it contains and their various functions. For example, an entity that represents the player in a 2D side-scrolling game may look something like the image below.

In this obviously simplified example, the SpriteSheetComponent enables the entity to have a visual presence in the game. It is told every frame, by the scene manager, to draw the visual representation of the entity appropriate for its current state. To do so, the SpriteSheetComponent needs to know where the entity resides in 2D space. For this, it refers to the SpatialComponent, which keeps track of the entity's position, rotation, velocity, etc. In order for the SpriteSheetComponent to retrieve this data from the SpatialComponent, it requests a reference to the component from the parent Entity. 

The exact mechanics of this request are covered in the tutorials and elaborated upon in the documentation section concerning components themselves, but this example serves to demonstrate the objects-as-containers mindset with which this engine was built. 

Last edited Feb 10, 2012 at 1:13 AM by heliondevelopment, version 20

Comments

No comments yet.