What design pattern should I use for my Game engine

Design Patterns

Builder Pattern

Bevy uses a Builder Pattern for configuring and initializing the app. A design pattern that allows developers to add various components. Components include systems or functions that operate on entities and their components, resources or any global data that is shared across systems, and plugins or added functionally to the engine itself. Plugins are a form of dependency injection. Furthermore, the app manages the lifecycles of said components. All while running in parallel.

Note

This is the current design pattern that my game engine uses as I appreciate the modularity. But there is definitely some flaws with this design. One such flaw shown below being giving plugins a reference when built. This not only allows that plugin to add more plugins to the app but also rerun the app. Both being functionality we don't want.

pub triat Plugin {
    fn build(&self, app: &mut App);
}

The fix to this issue is actually pretty simple instead of giving plugins a reference to the app we only give it a reference to the task last. However after learning about this flaw I started to wonder if this is the correct way to go about developing my game engine. So my question to you the reader is should I keep going down the current path I'm on? And if not what other design patterns should I explore?

TLDR; What other design patterns should I explore

This looks like a continuation of an earlier topic so I'm linking to a post there where @parasyte gives recommendations.

2 Likes