def checkAll(self): self.engineInstance = Engine() Engine() setupEngine() self.engineInstance.newEntity() \ .newComponent(Coordinate([0, 0, 0])) \ .newComponent(Movable(friction=0.97)) \ .newComponent(Destination(pos=[1, 0, 0], speed=0.08)) \ .newComponent(Render("Model1")) \ .newComponent(Health()) \ .newComponent(Collision()) self.engineInstance.newEntity() \ .newComponent(Coordinate([0, 0, 0])) \ .newComponent(Render("Model2")) \ .newComponent(Movable()) \ .newComponent(Destination(pos=[1, 0, 0])) self.engineInstance.serializeWorld() self.assertEqual( len(self.engineInstance.gameState.entities[2].components[Destination.__name__].destinationQueue), 1) self.assertEqual(len(self.engineInstance.gameState.entities), 2) self.assertEqual(len(self.engineInstance.gameState.tagToComponentId), 6) self.engineInstance.loopLogic() self.assertEqual(len(self.engineInstance.gameState.entities), 2) self.engineInstance.gameState.entities[1].getComponent(Health).changeHealthBy(-100) self.engineInstance.loopLogic() self.assertEqual(len(self.engineInstance.gameState.entities), 1) self.assertEqual( len(self.engineInstance.gameState.entities[2].components[Destination.__name__].destinationQueue), 0) self.assertEqual(len(self.engineInstance.gameState.tagToComponentId[Coordinate.__name__]), 1) self.assertEqual(len(self.engineInstance.gameState.tagToComponentId[Movable.__name__]), 1) self.assertEqual(len(self.engineInstance.gameState.tagToComponentId[Destination.__name__]), 1) self.assertEqual(len(self.engineInstance.gameState.tagToComponentId[Render.__name__]), 1) self.assertEqual(len(self.engineInstance.gameState.tagToComponentId[Health.__name__]), 0) self.assertEqual(len(self.engineInstance.gameState.tagToComponentId[Collision.__name__]), 0) self.engineInstance.deSerializeWorld() self.assertEqual(len(self.engineInstance.gameState.entities), 2) self.assertEqual( len(self.engineInstance.gameState.entities[2].components[Destination.__name__].destinationQueue), 1) self.assertEqual(len(self.engineInstance.gameState.tagToComponentId[Coordinate.__name__]), 2) self.assertEqual(len(self.engineInstance.gameState.tagToComponentId[Movable.__name__]), 2) self.assertEqual(len(self.engineInstance.gameState.tagToComponentId[Destination.__name__]), 2) self.assertEqual(len(self.engineInstance.gameState.tagToComponentId[Render.__name__]), 2) self.assertEqual(len(self.engineInstance.gameState.tagToComponentId[Health.__name__]), 1) self.assertEqual(len(self.engineInstance.gameState.tagToComponentId[Collision.__name__]), 1)
from src.Core import coreInstance from src.Core.AssetManage.SetupEngine import setupEngine if __name__ == '__main__': setupEngine() from src.Core.Device.Window import DeviceWindow, TemplateGlutSystem from src.Core.ECS.System.sysRendering import Rendering # noinspection PyUnresolvedReferences import Custom.CustomChooser params = TemplateGlutSystem(update=coreInstance.processLogicEvents, display=Rendering) DeviceWindow.initAndRunDevice(params)