def __init__( self, config: Config, simulation: Simulation, process_manager: ProcessManager = None, ): # TODO: reproduire le mechanisme d'index de behaviour/etc pour simulation self.config = config self.logger = get_logger('Cycle', config) self.simulation = simulation self.current_cycle = -1 self.first_cycle = True # TODO NOW: Les processes devront maintenir une liste des subjects qui sont nouveaux.ne connaissent pas # Attention a ce qu'in ne soient pas "expose" quand on créer ces subjects au sein du process. # Ces subjects ont vocation à adopter l'id du vrau subject tout de suite après leur instanciation if process_manager is None: process_manager = ProcessManager( config=config, # TODO: Changer de config de merde (core.use_x_cores) process_count=config.get('core', {}).get('use_x_cores', multiprocessing.cpu_count()), job=self.job, ) self.process_manager = process_manager
def __init__( self, config: Config, schema_file_path: str, ) -> None: self._config = config self._logger = get_logger('XmlValidator', config) self._schema_file_path = schema_file_path
def __init__( self, config: Config, simulation: TileStrategySimulation, ) -> None: self._logger = get_logger('TroopConstructorBuilder', config) self._config = config self._simulation = simulation
def __init__( self, config: Config, master: Tk, ) -> None: self._config = config self._logger = get_logger(self.__class__.__name__, config) self._master = master
def __init__( self, config: Config, map_dir_path: str, ) -> None: self.config = config self.logger = get_logger(self.__class__.__name__, config) self.map_dir_path = map_dir_path self.tmx = None
def __init__( self, config: Config, terminal: Terminal, ) -> None: self.config = config self.logger = get_logger('InteractionManager', config) self.terminal = terminal self.interactions = []
def __init__( self, config: Config, terminals: [Terminal] ): self.config = config self.logger = get_logger('TerminalManager', config) self.terminals = terminals self.outputs_queues = {} self.inputs_queues = {}
def __init__( self, config: Config, terminal: Terminal, layer_manager: LayerManager, ) -> None: self.config = config self.logger = get_logger(self.__class__.__name__, config) self.terminal = terminal self.layer_manager = layer_manager
def __init__( self, config: Config, terminal: Terminal, physics: Physics, read_queue_interval: float = 1 / 60.0, ): self.config = config self.logger = get_logger('Gui', config) self.physics = physics self._read_queue_interval = read_queue_interval self.terminal = terminal self.cycle_duration = self.config.resolve('core.cycle_duration') # Manager cache directory cache_dir_path = self.config.resolve('global.cache_dir_path') if not cache_dir_path: raise SynergineException( 'This code require the "global.cache_dir_path" config', ) ensure_dir_exist(cache_dir_path) cocos.director.director.init(width=640, height=480, vsync=True, resizable=False) mixer.init() self.interaction_manager = InteractionManager( config=self.config, terminal=self.terminal, ) self.layer_manager = self.layer_manager_class( self.config, middleware=self.get_layer_middleware(), interaction_manager=self.interaction_manager, gui=self, ) self.layer_manager.init() self.layer_manager.connect_layers() self.layer_manager.center() # Enable blending pyglet.gl.glEnable(pyglet.gl.GL_BLEND) pyglet.gl.glBlendFunc(pyglet.gl.GL_SRC_ALPHA, pyglet.gl.GL_ONE_MINUS_SRC_ALPHA) # Enable transparency pyglet.gl.glEnable(pyglet.gl.GL_ALPHA_TEST) pyglet.gl.glAlphaFunc(pyglet.gl.GL_GREATER, .1) self.subject_mapper_factory = SubjectMapperFactory()
def __init__( self, config: Config, asynchronous: bool=True, ): self.config = config self.logger = get_logger(self.__class__.__name__, config) self._input_queue = None self._output_queue = None self._stop_required = False self.subjects = {} self.cycle_events = [] self.event_handlers = collections.defaultdict(list) self.asynchronous = asynchronous self.core_process = None # type: Process
def __init__( self, config: Config, simulation: Simulation, cycle_manager: CycleManager, terminal_manager: TerminalManager=None, cycles_per_seconds: float=1.0, ): self.config = config self.logger = get_logger('Core', config) self.simulation = simulation self.cycle_manager = cycle_manager self.terminal_manager = terminal_manager or TerminalManager(config, []) self._loop_delta = 1./cycles_per_seconds self._current_cycle_start_time = None self._continue = True self.main_process_terminal = None # type: Terminal
def __init__( self, config: Config, simulation: TileStrategySimulation, ) -> None: self._logger = get_logger('TroopLoader', config) self._config = config self._simulation = simulation schema_file_path = self._config.get( 'global.troop_schema', 'opencombat/strategy/troops.xsd', ) self._xml_validator = XmlValidator( config, schema_file_path, )
def __init__( self, config: Config, units_file_path: str, teams_file_path: str, ) -> None: self._config = config self._logger = get_logger('TroopManager', config) self._builder = TroopClassBuilder(config) self._unit_stash = self._builder.get_unit_stash( units_file_path, ) self._team_stash = self._builder.get_team_stash( units_file_path, teams_file_path, )
def __init__(self, image_path: str, subject: Subject, position=(0, 0), rotation=0, scale=1, opacity=255, color=(255, 255, 255), anchor=None, properties: dict = None, config: Config = None, **kwargs): # Note: Parameter required, but we want to modify little as possible parent init assert config, "Config is a required parameter" self.config = config self.path_manager = PathManager( config.resolve('global.include_path.graphics')) self.animation_images = { } # type: typing.Dict[str, typing.List[pyglet.image.TextureRegion]] # nopep8 default_texture = self._get_default_image_texture() super().__init__(default_texture, position, rotation, scale, opacity, color, anchor, **kwargs) self.logger = get_logger('Actor', config) self.subject = subject self.cshape = None # type: collision_model.AARectShape self.update_cshape() self.default_texture = default_texture self.need_update_cshape = False self.properties = properties or {} self._freeze = False self.animation_textures_cache = { } # type: typing.Dict[str, typing.List[pyglet.image.TextureRegion]] # nopep8 self.mode_texture_cache = { } # type: typing.Dict[str, pyglet.image.TextureRegion] # nopep8 self.default_image_path = image_path self.image_cache_manager = self.get_image_cache_manager() self.image_cache_manager.build() self.build_textures_cache()
def __init__( self, config: Config, simulation: TileStrategySimulation, ) -> None: self._logger = get_logger('StateDumper', config) self._config = config self._simulation = simulation state_template = self._config.resolve( 'global.state_template', 'opencombat/state_template.xml', ) with open(state_template, 'r') as xml_file: template_str = xml_file.read() parser = etree.XMLParser(remove_blank_text=True) self._state_root = etree.fromstring( template_str.encode('utf-8'), parser, ) self._state_root_filled = False
def __init__( self, config: Config, middleware: MapMiddleware, interaction_manager: 'InteractionManager', gui: 'Gui', ) -> None: self.config = config self.logger = get_logger('LayerManager', config) self.middleware = middleware self.interaction_manager = interaction_manager self.gui = gui self.grid_manager = None # type: GridManager self.scrolling_manager = None # type: ScrollingManager self.main_scene = None # type: cocos.scene.Scene self.main_layer = None # type: cocos.layer.Layer self.edit_layer = None # TODO type self.subject_layer = None # type: SubjectLayer from synergine2_cocos2d.gui import EditLayer self.edit_layer_class = self.edit_layer_class or EditLayer self.debug = self.config.resolve('global.debug', False)
def __init__( self, config: Config, ) -> None: self._config = config self._logger = get_logger('TroopDumper', config)
def __init__( self, config: Config, layer_manager: LayerManager, grid_manager: GridManager, worldview, bindings=None, fastness=None, autoscroll_border=10, autoscroll_fastness=None, wheel_multiplier=None, zoom_min=None, zoom_max=None, zoom_fastness=None, mod_modify_selection=None, mod_restricted_mov=None, ): # TODO: Clean init params super().__init__() self.config = config self.logger = get_logger('EditLayer', config) self.layer_manager = layer_manager self.grid_manager = grid_manager self.bindings = bindings buttons = {} modifiers = {} for k in bindings: buttons[bindings[k]] = 0 modifiers[bindings[k]] = 0 self.buttons = buttons self.modifiers = modifiers self.fastness = fastness self.autoscroll_border = autoscroll_border self.autoscroll_fastness = autoscroll_fastness self.wheel_multiplier = wheel_multiplier self.zoom_min = zoom_min self.zoom_max = zoom_max self.zoom_fastness = zoom_fastness self.mod_modify_selection = mod_modify_selection self.mod_restricted_mov = mod_restricted_mov self.weak_scroller = weakref.ref(self.layer_manager.scrolling_manager) self.weak_worldview = weakref.ref(worldview) self.wwidth = worldview.width self.wheight = worldview.height self.autoscrolling = False self.drag_selecting = False self.drag_moving = False self.restricted_mov = False self.wheel = 0 self.dragging = False self.keyscrolling = False self.keyscrolling_descriptor = (0, 0) self.wdrag_start_point = (0, 0) self.elastic_box = None # type: MinMaxRect self.elastic_box_wminmax = 0, 0, 0, 0 self.selection = {} # type: typing.Dict[Actor, AARectShape] self.screen_mouse = (0, 0) self.world_mouse = (0, 0) self.sleft = None self.sright = None self.sbottom = None self.s_top = None self.user_action_pending = None # type: UserAction # opers that change cshape must ensure it goes to False, # selection opers must ensure it goes to True self.selection_in_collman = True # TODO: Hardcoded here, should be obtained from level properties or calc # from available actors or current actors in worldview gsize = 32 * 1.25 self.collision_manager = collision_model.CollisionManagerGrid( -gsize, self.wwidth + gsize, -gsize, self.wheight + gsize, gsize, gsize, ) self.schedule(self.update) self.selectable_actors = [] self.callbacks = [] # type: typing.List[Callback]
def __init__( self, config: Config, ) -> None: self._logger = get_logger('TroopManagerBuilder', config) self._config = config