My thoughts about Game Design Patterns using Unreal Engine
I have just finished reading the excellent book “Game Programming Patterns”, which you can read for free at http://gameprogrammingpatterns.com/contents.html
The book gives several Unity examples. As a learning exercise I thought I would apply the content of the book to Unreal engine.
Let me start with a very brief summary of the patterns covered by the book:
1.Design patterns revisited
Command Express actions for actors as classes.
Flyweight Separate intrinsic (context-free) and extrinsic (unique to this instance) data to optimize memory.
Observer An object, called the subject, maintains a list of its dependents, called observers, and notifies them automatically of any state changes.
Prototype Ability to clone objects.
Singleton Singletons harm the code because they are global, making harder to follow the code, encouraging coupling, no concurrent-friendly implementations.
State Finite State Machines
2. Sequencing patterns
Double buffer Cause a series of sequential operations to appear instantaneous or simultaneous.
Game loop Decouple progression of game from user input and processor speed.
Update Method Simulate a collection of independent objects by telling each other to process one frame of behavior at a time.
3. Behavioural patterns
Bytecode Give behavior the flexibility of data by encoding it as instructions for a virtual machine.
Subclass Sandbox Define behavior in a subclass using a set of operations provided by its base class.
Type Object Allow the flexible creation of new “classes” by creating a single class, each instance of which represents a different type of object.
4. Decoupling Patterns
Component Allow a single entity to span multiple domains without coupling the domains to each other.
Event queue Decouple when a message or event is sent from when it is processed.
Service Locator Provide a global point of access to a service without coupling users to the concrete class that implements it.
5. Optimization Patterns
Data Locality Accelerate memory access by arranging data to take advantage of CPU caching.
Dirty flag Avoid unnecessary work by deferring it until the result is needed.
Object Pool Improve performance and memory use by reusing objects from a fixed pool instead of allocating and freeing them individually.
Spatial partitions Efficiently locate objects by storing them in a data structure organized by their positions.
I have identified the following Unreal tools to implement design patterns: TFunctions, delegates, TSubclassOf, Actor and ActorComponents, Blueprints.
What have I missed?
Thanks for reading, let me know your thoughts!
asked Oct 28 '18 at 11:10 AM in C++ Programming
Follow this question
Once you sign in you will be able to subscribe for any updates here