Commits

rkruppe committed 83021da

Use ECS, kill dead code

Comments (0)

Files changed (2)

         sys.exit(3)
     init_display(gsc)
     gsc.call_gameset_entry_point()
+    #TODO fix our timestep
+    pyglet.clock.schedule_interval(lambda _: gsc.universe.step(), 0.1)
     pyglet.app.run()
     exit(gsc)
 

ttgx/model/gamestate.py

 import ttgx.toolutil
 import ttgx.assets
 import ttgx.util
+import ttgx.dodecs
 
 from .date import Date
 from .gameset import GameSet
         self.gameset, self.gameset_assets = _load_gameset(gameset_name)
         self.gameset_name = gameset_name
         self.gui_driver = None
+        self.universe = ttgx.dodecs.Universe()
 
     def call_gameset_entry_point(self):
         entry_point_name = self.gameset.entry_point
         self._call_script(entry_point)
 
     def _call_script(self, resource):
-        ec = ttgx.util.script.ExecutionContext(GSC=self)
+        ec = ttgx.util.script.ExecutionContext(GSC=self, U=self.universe)
         se = ttgx.util.script.ScriptExecution(resource, ec)
         _, err = se.run()
         if err:
             exc_info = (type(err), err, err.__traceback__)
             log.error('Error in gameset entry point', exc_info=exc_info)
 
+    def ecs_step(self):
+        pass
+
     def savegame_path(self, name):
         """
         Return the path to savegame (a directory) called ``name``.
 
     @property
     def game_active(self):
-        return self._state is not None
-
-    def load(self, name):
-        path = self.savegame_path(name)
-        #TODO rework error handling, it's incomplete and a mess
-        try:
-            [new_state] = ttgx.toolutil.load(GameState, path)
-        except IOError as e:
-            raise LoadingError(e)
-        if new_state is None:
-            raise ValidationFailure("Validation failed", errors)
-        if new_state.gameset != self.gameset_name:
-            raise ValidationFailure("Wrong gameset")
-        self._state = new_state
-        self.StateReset.trigger()
-
-    def save(self, name):
-        path = self.savegame_path(name)
-        GameState.save_to_path([self._state], path)
+        return False
 
 
 def _load_gameset(name):