commit b228ff7994da8a1d0153836065223a3bc19de50d
parent 7954932e7a00a06197d93a48519f474300b5705f
Author: Erik Letson <hmagellan@hmagellan.com>
Date: Mon, 2 Nov 2020 14:34:50 -0600
Beginning the process of splitting up EntityManager
Diffstat:
3 files changed, 50 insertions(+), 1 deletion(-)
diff --git a/src/piece.py b/src/piece.py
@@ -0,0 +1,19 @@
+import pygame, os
+from . import manager, unit
+from .constants import *
+
+############
+# piece.py #
+############
+
+# This file contains the following:
+# 1. The PieceManager object, which manages pieces on the game board
+# 2. The Piece entity child object, which represents a piece on the game board
+
+######################################
+# Section 1 - The PieceManager class #
+######################################
+
+###############################
+# Section 2 - The Piece class #
+###############################
diff --git a/src/subsystem.py b/src/subsystem.py
@@ -10,6 +10,7 @@ from .constants import *
# 2. The GameInterface class, which handles game events such as keyboard and mouse input
# 3. The ManagerBus class, which is a communication mechanism used by Managers as well as other subsystems and ever game objects
# 4. The GameCamera class, which controls camera-oriented logic and drawing
+# 5. The ObjectOracle class, which keeps track of all VGO objects and can refer to them, but does not manage or draw them
#######################################
# Section 1 - The GameSubsystem class #
@@ -213,3 +214,23 @@ class GameCamera(GameSubsystem):
"""
if surface != None:
surface.blit(self.camera_surface, self.camera_surface_offset)
+
+######################################
+# Section 5 - The ObjectOracle class #
+######################################
+
+class ObjectOracle(GameSubsystem):
+ """
+ ObjectOracle has references to all VGO and VGO-child
+ objects that are created. All managers are supposed to
+ report to the ObjectOracle whenever they make a new
+ VGO-type object. ObjectOracle can fetch info about
+ these objects by ID, name, or other attributes, but
+ does not manage them in any way, nor change their
+ values ever (with the possible exception of ID).
+ """
+
+ def __init__(self, game):
+
+ # Parent init
+ super().__init__(game)
diff --git a/src/vgo.py b/src/vgo.py
@@ -39,7 +39,16 @@ from .constants import *
# already associated with them. Drawing entities is a pan-Manager thing,
# and one of the important distinctions between managers and subsystems.
# The codebase should probably reflect this by doing away with EntityManager
-# entirely and refactoring it into PieceManager.
+# entirely and refactoring it into PieceManager. EntityManager's functionality
+# involving identifying entities by name/id could be moved to a subsystem
+# object called ObjectOracle. This subsystem could be alerted each time
+# a new object is created, and could maintain a list of references to
+# those objects. It could manage ID by itself, and spread it across any
+# VGO, not just Entities. VGOs would know their own ID, and they could be
+# accessed from the oracly by ID by any object with a basic call to
+# game.oracle. It would be excellent for debug as well. It is possible that
+# even the non-VGO objects like the managers should have IDs and be referred
+# to by the oracle.
# This file contains:
# 1. The VisibleGameObject class that defines the abstract parent of all entities and other visible sprites