From cbcc95d75625a233f46c01832a7a885807698499 Mon Sep 17 00:00:00 2001 From: Theolaos <92591390+theolaos@users.noreply.github.com> Date: Fri, 20 Dec 2024 20:08:28 +0200 Subject: [PATCH] License and state experimental support --- src/tleng2/components/camera.py | 24 ++++ src/tleng2/components/engine.py | 24 ++++ src/tleng2/components/events.py | 24 ++++ src/tleng2/components/map.py | 24 ++++ src/tleng2/components/renderable.py | 24 ++++ src/tleng2/components/scene.py | 24 ++++ src/tleng2/ecs/README.md | 2 +- src/tleng2/ecs/__init__.py | 24 ++++ src/tleng2/ecs/commands.py | 53 +++++++ src/tleng2/ecs/ecs_scene.py | 24 ++++ src/tleng2/ecs/events.py | 24 ++++ src/tleng2/ecs/scenes_manager.py | 26 +++- src/tleng2/ecs/schedule.py | 198 ++++++++++++++++++++++----- src/tleng2/ecs/system.py | 24 ++++ src/tleng2/ecs/world.py | 24 ++++ src/tleng2/engine/app.py | 24 ++++ src/tleng2/engine/methods.py | 24 ++++ src/tleng2/engine/properties.py | 30 +++- src/tleng2/engine/renderer.py | 24 ++++ src/tleng2/engine/scene_manager.py | 24 ++++ src/tleng2/engine/settings.py | 24 ++++ src/tleng2/object/area.py | 24 ++++ src/tleng2/object/point.py | 24 ++++ src/tleng2/object/sprite.py | 24 ++++ src/tleng2/systems/engine_systems.py | 24 ++++ src/tleng2/systems/renderer.py | 24 ++++ src/tleng2/utils/annotations.py | 24 ++++ src/tleng2/utils/colors.py | 24 ++++ src/tleng2/utils/debug.py | 24 ++++ src/tleng2/utils/utils.py | 24 ++++ unit_tests/test_scenes.py | 2 + 31 files changed, 872 insertions(+), 39 deletions(-) diff --git a/src/tleng2/components/camera.py b/src/tleng2/components/camera.py index 287d614..2754104 100755 --- a/src/tleng2/components/camera.py +++ b/src/tleng2/components/camera.py @@ -1,3 +1,27 @@ +# Copyright (c) 2023 Theolaos + +# Permission is hereby granted, free of charge, to any person +# obtaining a copy of this software and associated +# documentation files (the "Software"), to deal in the Software +# without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to +# whom the Software is furnished to do so, subject to the +# following conditions: + +# The above copyright notice and this permission notice shall +# be included in all copies or substantial portions of the +# Software. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +# PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + import pygame from dataclasses import dataclass diff --git a/src/tleng2/components/engine.py b/src/tleng2/components/engine.py index 50b3755..997af2b 100644 --- a/src/tleng2/components/engine.py +++ b/src/tleng2/components/engine.py @@ -1,3 +1,27 @@ +# Copyright (c) 2023 Theolaos + +# Permission is hereby granted, free of charge, to any person +# obtaining a copy of this software and associated +# documentation files (the "Software"), to deal in the Software +# without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to +# whom the Software is furnished to do so, subject to the +# following conditions: + +# The above copyright notice and this permission notice shall +# be included in all copies or substantial portions of the +# Software. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +# PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + from dataclasses import dataclass from ..ecs import * diff --git a/src/tleng2/components/events.py b/src/tleng2/components/events.py index 80871b1..0d98cfa 100644 --- a/src/tleng2/components/events.py +++ b/src/tleng2/components/events.py @@ -1,3 +1,27 @@ +# Copyright (c) 2023 Theolaos + +# Permission is hereby granted, free of charge, to any person +# obtaining a copy of this software and associated +# documentation files (the "Software"), to deal in the Software +# without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to +# whom the Software is furnished to do so, subject to the +# following conditions: + +# The above copyright notice and this permission notice shall +# be included in all copies or substantial portions of the +# Software. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +# PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + """ All the Events that tleng2 uses """ diff --git a/src/tleng2/components/map.py b/src/tleng2/components/map.py index 349a0d8..6320932 100644 --- a/src/tleng2/components/map.py +++ b/src/tleng2/components/map.py @@ -1,3 +1,27 @@ +# Copyright (c) 2023 Theolaos + +# Permission is hereby granted, free of charge, to any person +# obtaining a copy of this software and associated +# documentation files (the "Software"), to deal in the Software +# without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to +# whom the Software is furnished to do so, subject to the +# following conditions: + +# The above copyright notice and this permission notice shall +# be included in all copies or substantial portions of the +# Software. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +# PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + # Tilemap used for a map from ..services.tilemap import TileMap diff --git a/src/tleng2/components/renderable.py b/src/tleng2/components/renderable.py index 8bf711d..7106d19 100644 --- a/src/tleng2/components/renderable.py +++ b/src/tleng2/components/renderable.py @@ -1,3 +1,27 @@ +# Copyright (c) 2023 Theolaos + +# Permission is hereby granted, free of charge, to any person +# obtaining a copy of this software and associated +# documentation files (the "Software"), to deal in the Software +# without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to +# whom the Software is furnished to do so, subject to the +# following conditions: + +# The above copyright notice and this permission notice shall +# be included in all copies or substantial portions of the +# Software. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +# PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + import pygame from dataclasses import dataclass, field diff --git a/src/tleng2/components/scene.py b/src/tleng2/components/scene.py index 0be04d1..e820f74 100755 --- a/src/tleng2/components/scene.py +++ b/src/tleng2/components/scene.py @@ -1,3 +1,27 @@ +# Copyright (c) 2023 Theolaos + +# Permission is hereby granted, free of charge, to any person +# obtaining a copy of this software and associated +# documentation files (the "Software"), to deal in the Software +# without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to +# whom the Software is furnished to do so, subject to the +# following conditions: + +# The above copyright notice and this permission notice shall +# be included in all copies or substantial portions of the +# Software. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +# PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + from abc import ABC, abstractmethod from dataclasses import dataclass diff --git a/src/tleng2/ecs/README.md b/src/tleng2/ecs/README.md index 422d9ff..59be7de 100644 --- a/src/tleng2/ecs/README.md +++ b/src/tleng2/ecs/README.md @@ -1,6 +1,6 @@ # tleng2.ecs -This is an ECS architecture implementation for the Game Engine TLeng. +This is an ECS architecture implementation for the Game Engine TLeng2. Check the `tleng2.ecs` Documentation in [here](https://github.com/tl-ecosystem/tleng/wiki). diff --git a/src/tleng2/ecs/__init__.py b/src/tleng2/ecs/__init__.py index b15961f..c7ba222 100644 --- a/src/tleng2/ecs/__init__.py +++ b/src/tleng2/ecs/__init__.py @@ -1,3 +1,27 @@ +# Copyright (c) 2023 Theolaos + +# Permission is hereby granted, free of charge, to any person +# obtaining a copy of this software and associated +# documentation files (the "Software"), to deal in the Software +# without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to +# whom the Software is furnished to do so, subject to the +# following conditions: + +# The above copyright notice and this permission notice shall +# be included in all copies or substantial portions of the +# Software. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +# PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + # ECS implementation inspired from Esper ECS : https://github.com/benmoran56/esper # Naming schemes inspired from Bevy ECS : https://docs.rs/bevy_ecs/latest/bevy_ecs/ diff --git a/src/tleng2/ecs/commands.py b/src/tleng2/ecs/commands.py index e657aa2..4bf543a 100644 --- a/src/tleng2/ecs/commands.py +++ b/src/tleng2/ecs/commands.py @@ -1,3 +1,27 @@ +# Copyright (c) 2023 Theolaos + +# Permission is hereby granted, free of charge, to any person +# obtaining a copy of this software and associated +# documentation files (the "Software"), to deal in the Software +# without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to +# whom the Software is furnished to do so, subject to the +# following conditions: + +# The above copyright notice and this permission notice shall +# be included in all copies or substantial portions of the +# Software. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +# PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + from .world import World class Commands: @@ -32,6 +56,35 @@ def qdespawn(self, entity_id) -> None: def despawn(self, entity, immediate) -> None: self.__world.despawn(entity=entity, immediate=immediate) + + def enable_state(self, state_name: str) -> None: + """ + Enables a specific state. + """ + ... + + + def disable_state(self, state_name: str) -> None: + """ + Disables a specific state that isn't one of the default states: + ['First', 'PreUpdate', 'Update', 'PostUpdate', 'PreRenderer', 'Renderer', 'Last'] + """ + ... + + + def change_state(self, state_group: str, state_name: str) -> None: + """ + From the passed state group, it changes the state to the one passed. + Frees the programmer from constantly checking to disable the other active state from + the state group. + + Example: + 'MyPausedState' = ['Paused', 'Running'] + current_state = 'Paused' + # with change_state you can change 'Paused' to 'running' + """ + ... + def update(self): command_queue = self.__command_queue diff --git a/src/tleng2/ecs/ecs_scene.py b/src/tleng2/ecs/ecs_scene.py index 18cd912..54bf00a 100644 --- a/src/tleng2/ecs/ecs_scene.py +++ b/src/tleng2/ecs/ecs_scene.py @@ -1,3 +1,27 @@ +# Copyright (c) 2023 Theolaos + +# Permission is hereby granted, free of charge, to any person +# obtaining a copy of this software and associated +# documentation files (the "Software"), to deal in the Software +# without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to +# whom the Software is furnished to do so, subject to the +# following conditions: + +# The above copyright notice and this permission notice shall +# be included in all copies or substantial portions of the +# Software. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +# PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + from dataclasses import dataclass from .world import WorldComp diff --git a/src/tleng2/ecs/events.py b/src/tleng2/ecs/events.py index bd4b6ca..b467ae5 100644 --- a/src/tleng2/ecs/events.py +++ b/src/tleng2/ecs/events.py @@ -1,3 +1,27 @@ +# Copyright (c) 2023 Theolaos + +# Permission is hereby granted, free of charge, to any person +# obtaining a copy of this software and associated +# documentation files (the "Software"), to deal in the Software +# without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to +# whom the Software is furnished to do so, subject to the +# following conditions: + +# The above copyright notice and this permission notice shall +# be included in all copies or substantial portions of the +# Software. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +# PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + from .system import System from .world import World diff --git a/src/tleng2/ecs/scenes_manager.py b/src/tleng2/ecs/scenes_manager.py index 01d37bf..11bd1ac 100644 --- a/src/tleng2/ecs/scenes_manager.py +++ b/src/tleng2/ecs/scenes_manager.py @@ -1,6 +1,26 @@ -""" -Stores a dictionary of "name_of_scene" and -""" +# Copyright (c) 2023 Theolaos + +# Permission is hereby granted, free of charge, to any person +# obtaining a copy of this software and associated +# documentation files (the "Software"), to deal in the Software +# without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to +# whom the Software is furnished to do so, subject to the +# following conditions: + +# The above copyright notice and this permission notice shall +# be included in all copies or substantial portions of the +# Software. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +# PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. from .schedule import Schedule from .ecs_scene import SceneComp diff --git a/src/tleng2/ecs/schedule.py b/src/tleng2/ecs/schedule.py index 9a04929..9c5cf41 100644 --- a/src/tleng2/ecs/schedule.py +++ b/src/tleng2/ecs/schedule.py @@ -1,3 +1,27 @@ +# Copyright (c) 2023 Theolaos + +# Permission is hereby granted, free of charge, to any person +# obtaining a copy of this software and associated +# documentation files (the "Software"), to deal in the Software +# without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to +# whom the Software is furnished to do so, subject to the +# following conditions: + +# The above copyright notice and this permission notice shall +# be included in all copies or substantial portions of the +# Software. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +# PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + from inspect import signature from typing import get_args from dataclasses import dataclass, field @@ -15,13 +39,13 @@ class SceneComp: SEQUENCE_TYPES = _Literal[ - 'StateTransition', 'SceneTransition' 'First', 'PreUpdate', 'Update', 'PostUpdate', - 'Last', 'PreRenderer', 'Renderer', + 'Last', + 'StateTransition', 'SceneTransition' 'PreStartup', 'Startup', 'PostStartup' @@ -41,8 +65,8 @@ class SceneComp: ] -update_order: list[str] = ['First', 'PreUpdate', 'Update', 'PostUpdate', 'PreRenderer', 'Renderer', 'Last'] -startup_order: list[str] = ['PreStartUp', 'Startup'] +UPDATE_ORDER: list[str] = ['First', 'PreUpdate', 'Update', 'PostUpdate', 'PreRenderer', 'Renderer', 'Last'] +STARTUP_ORDER: list[str] = ['PreStartUp', 'Startup'] # scene_transition_order_enter: list[str] = ['OnSceneEnter'] # scene_transition_order_exit: list[str] = ['OnSceneExit'] @@ -56,7 +80,7 @@ class SceneComp: # The other more brutal idea is to just a good data structure (or use an existing one like hashmaps) that supports fast looksup for systems and # every time we switch state some systems are enabled some other are disabled. # -# Best of both worlds: Use both :) +# Best of both worlds: Use both :) nope def _ScheduleComp_default_factory() -> dict[SEQUENCE_TYPES, list[System]]: @@ -66,9 +90,9 @@ def _ScheduleComp_default_factory() -> dict[SEQUENCE_TYPES, list[System]]: @dataclass class ScheduleComp: system_schedule: dict[SEQUENCE_TYPES, list[System]] = field(default_factory=_ScheduleComp_default_factory) - cached_system_schedule: dict[SEQUENCE_TYPES, list[System]] = field(default_factory=_ScheduleComp_default_factory) cached_system_sequence_types: set[SEQUENCE_TYPES] = field(default_factory=set) - current_order: str = field(default_factory=str) + + system_state_order: list[str] = field(default_factory=list) class Schedule: @@ -76,40 +100,153 @@ class Schedule: Something like a system manager. """ def __init__(self) -> None: - # self.world = None # current running scheduling for systems - self.system_schedule: dict[SEQUENCE_TYPES, list[System]] = {key: [] for key in sequence_types} + self.system_schedule: dict[str, list[System]] = {key: [] for key in sequence_types} self.cached_system_sequence_types: list[SEQUENCE_TYPES] = [] + self.system_state_order: list[str] = UPDATE_ORDER + self.state_groups: dict[str, str] = {} - #TODO: can be used as the cached active systems, better if the lists change to sets. - self.cached_system_schedule: dict[SEQUENCE_TYPES, list[System]] = {key: [] for key in sequence_types} - self.current_order: SEQUENCE_TYPES = 'Update' - # self.cached_queue: list = [] + self.state_changed = False + self.temp_system_state_order: list[str] = UPDATE_ORDER + self.temp_state_groups: dict[str, str] = {} - - def _add_cached_system_sequence(self, *new_sequence_type: SEQUENCE_TYPES) -> None: + + def _add_cached_system_sequence(self, *new_sequence_type: SEQUENCE_TYPES, order: list[str] = UPDATE_ORDER) -> None: """ Appends the new_sequence_type to the cached_system_sequence_types, and then it sorts it out. """ self.cached_system_sequence_types.extend(new_sequence_type) - # print(new_sequence_type) - # print(self.cached_system_sequence_types) - # print(type(self.cached_system_sequence_types)) - self.cached_system_sequence_types = sorted( self.cached_system_sequence_types, - key=lambda x: update_order.index(x) + key = lambda x: order.index(x) ) + def add_state(self, state_name: str, *systems: System) -> None: + """ + Adds a state after Update (or every other state that is after Update) + """ + assert state_name not in UPDATE_ORDER + + self.system_schedule[state_name] = systems + self.system_state_order.insert(self.system_state_order.index('Update') + 1, state_name) + + + def create_state_group(self, state_group_name: str, start_with:str, *state_names: str) -> None: + """ + Creates a state group from all the created states. + + :state_group_name: The state group name + :start_with: With which state from the state group should it start + :*state_names: Include all the states that the state group should have (even the one starting with) + """ + assert state_group_name not in UPDATE_ORDER + + self.state_groups[state_group_name] = [start_with, state_names] + self.enable(start_with) + + + def move_state(self, + state_name: str, + before_position: str = "", + after_position: str = "", + ) -> None: + """ + Moves a specified state to another place after or before, another state. + + There are 7 default states, that always exist: + ['First', 'PreUpdate', 'Update', 'PostUpdate', 'PreRenderer', 'Renderer', 'Last'] + + :state_name: the name of the state you want to move. + :before_position: pass here the name of your selected state to be before (exaple ['selected_state','passed_state']) + :after_position: pass here the name of your selected state to be after (exaple ['passed_state', 'selected_state']) + :return: Returns mothing. + + WARNING: Don't input both `before_position` and `after_position` arguments, or else an error will be thrown. + You must only provide one of the two arguments, with the ability to provide a default as well + """ + assert before_position and after_position + + try: + if before_position: + self.system_state_order.insert(self.system_state_order.index(before_position), state_name) + elif after_position: + self.system_state_order.insert(self.system_state_order.index(after_position) + 1, state_name) + + except ValueError as e: + print('Caught ValueError:', e, 'is not in the system_state_order. Make sure that you have created the state in this schedule') + + + def move_state_group(self, + state_group_name: str, + before_position: str = "", + after_position: str = "", + ) -> None: + """ + Experimental! + + Moves a state group to another place after or before, another default state. + + There are 7 default states, that always exist: + ['First', 'PreUpdate', 'Update', 'PostUpdate', 'PreRenderer', 'Renderer', 'Last'] + + :state_group_name: the name of the state group you want to move. + :before_position: pass here the name of your selected state to be before (exaple ['selected_state','passed_state']) + :after_position: pass here the name of your selected state to be after (exaple ['passed_state', 'selected_state']) + :return: Returns mothing. + + WARNING: Don't input both `before_position` and `after_position` arguments. + You must only provide one of the two arguments, with the ability to provide a default as well + """ + ... + + + def enable_state(self, state_name: str) -> None: + """ + Enables a specific state. + """ + self._add_cached_system_sequence(state_name, self.system_state_order) + + + def disable_state(self, state_name: str) -> None: + """ + Disables a specific state that isn't one of the default states: + ['First', 'PreUpdate', 'Update', 'PostUpdate', 'PreRenderer', 'Renderer', 'Last'] + """ + assert state_name not in UPDATE_ORDER + + self.cached_system_sequence_types.remove(state_name) + + + def change_state(self, state_group: str, state_name: str) -> None: + """ + From the passed state group, it changes the state to the one passed. + Frees the programmer from constantly checking to disable the other active state from + the state group. + + Example: + ``` + 'MyPausedState' = ['Paused', 'Running'] + current_state = 'Paused' + # with change_state you can change 'Paused' to 'running' + ``` + """ + assert state_name in self.state_groups[state_group][1] + + self.disable_state(self.state_groups[state_group][0]) + self.enable_state(state_name) + # Assigning the new state_name as the running state of the state group + self.state_groups[state_group][0] = state_name + + def add_systems(self, sequence_type: SEQUENCE_TYPES, *systems) -> None: """ Add systems in the scheduler. - :Returns: Nothing + :return: Nothing """ # I am not sure if the line below is slow self.system_schedule[sequence_type] += systems @@ -157,15 +294,17 @@ def init(self, parameters: dict[type, _Any]) -> None: def update(self) -> None: """ According to what the resources say the right systems will run. - """ - # for state in self.cached_state_sequence: - # for system in state: - # + """ for key in self.cached_system_sequence_types: for system in self.system_schedule.setdefault(key,[]): if system.enabled: system.update() # by design (not a bug, it's a feature!) + # TODO Change the state, if it was changed here. + if self.state_changed: + self.state_groups = self.temp_state_groups + self.system_state_order = self.temp_system_state_order + # for this to be done efficiently (from the schedule) we need to use sets def disable_system(self,) -> None: @@ -185,13 +324,11 @@ def return_schedule_component(self) -> ScheduleComp: """ return ScheduleComp( self.system_schedule, - self.cached_system_schedule, - self.cached_system_sequence_types, - self.current_order + self.cached_system_sequence_types, ) - def load_schedule_component(self, schedule_component: ScheduleComp | _Any) -> None: + def load_schedule_component(self, schedule_component: ScheduleComp) -> None: """ Used from the scenes_manager to change scenes @@ -199,9 +336,7 @@ def load_schedule_component(self, schedule_component: ScheduleComp | _Any) -> No :returns: Nothing """ self.system_schedule = schedule_component.system_schedule - self.cached_system_schedule = schedule_component.cached_system_schedule self.cached_system_sequence_types = schedule_component.cached_system_sequence_types - self.current_order = schedule_component.current_order def _merge_to_scene_schedulers(scene_comp_list: list[SceneComp], scheduler: Schedule) -> None: @@ -224,7 +359,6 @@ def _merge_to_scene_schedulers(scene_comp_list: list[SceneComp], scheduler: Sche key=lambda syst: syst.priority, reverse=True ) - scene.schedule.cached_system_schedule.update(scheduler.cached_system_schedule) scene.schedule._add_cached_system_sequence(*scheduler.cached_system_sequence_types) diff --git a/src/tleng2/ecs/system.py b/src/tleng2/ecs/system.py index d017d5f..6016fbd 100644 --- a/src/tleng2/ecs/system.py +++ b/src/tleng2/ecs/system.py @@ -1,3 +1,27 @@ +# Copyright (c) 2023 Theolaos + +# Permission is hereby granted, free of charge, to any person +# obtaining a copy of this software and associated +# documentation files (the "Software"), to deal in the Software +# without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to +# whom the Software is furnished to do so, subject to the +# following conditions: + +# The above copyright notice and this permission notice shall +# be included in all copies or substantial portions of the +# Software. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +# PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + from abc import abstractmethod diff --git a/src/tleng2/ecs/world.py b/src/tleng2/ecs/world.py index e6b5336..878f149 100644 --- a/src/tleng2/ecs/world.py +++ b/src/tleng2/ecs/world.py @@ -1,3 +1,27 @@ +# Copyright (c) 2023 Theolaos + +# Permission is hereby granted, free of charge, to any person +# obtaining a copy of this software and associated +# documentation files (the "Software"), to deal in the Software +# without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to +# whom the Software is furnished to do so, subject to the +# following conditions: + +# The above copyright notice and this permission notice shall +# be included in all copies or substantial portions of the +# Software. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +# PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + from dataclasses import dataclass, field from itertools import count diff --git a/src/tleng2/engine/app.py b/src/tleng2/engine/app.py index 84f104e..76f5ba5 100755 --- a/src/tleng2/engine/app.py +++ b/src/tleng2/engine/app.py @@ -1,3 +1,27 @@ +# Copyright (c) 2023 Theolaos + +# Permission is hereby granted, free of charge, to any person +# obtaining a copy of this software and associated +# documentation files (the "Software"), to deal in the Software +# without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to +# whom the Software is furnished to do so, subject to the +# following conditions: + +# The above copyright notice and this permission notice shall +# be included in all copies or substantial portions of the +# Software. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +# PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + import sys import pygame import warnings diff --git a/src/tleng2/engine/methods.py b/src/tleng2/engine/methods.py index 51f2d7b..8641049 100644 --- a/src/tleng2/engine/methods.py +++ b/src/tleng2/engine/methods.py @@ -1,3 +1,27 @@ +# Copyright (c) 2023 Theolaos + +# Permission is hereby granted, free of charge, to any person +# obtaining a copy of this software and associated +# documentation files (the "Software"), to deal in the Software +# without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to +# whom the Software is furnished to do so, subject to the +# following conditions: + +# The above copyright notice and this permission notice shall +# be included in all copies or substantial portions of the +# Software. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +# PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + import pygame from .properties import EngineProperties, SceneManagerProperties, RendererProperties diff --git a/src/tleng2/engine/properties.py b/src/tleng2/engine/properties.py index f344fc7..0c1475d 100644 --- a/src/tleng2/engine/properties.py +++ b/src/tleng2/engine/properties.py @@ -1,6 +1,30 @@ -""" -Every variable that is not related as a setting is here -""" +# Copyright (c) 2023 Theolaos + +# Permission is hereby granted, free of charge, to any person +# obtaining a copy of this software and associated +# documentation files (the "Software"), to deal in the Software +# without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to +# whom the Software is furnished to do so, subject to the +# following conditions: + +# The above copyright notice and this permission notice shall +# be included in all copies or substantial portions of the +# Software. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +# PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + +# Every variable that is not related as a setting is here + import pygame diff --git a/src/tleng2/engine/renderer.py b/src/tleng2/engine/renderer.py index 78f2377..f4d4650 100644 --- a/src/tleng2/engine/renderer.py +++ b/src/tleng2/engine/renderer.py @@ -1,3 +1,27 @@ +# Copyright (c) 2023 Theolaos + +# Permission is hereby granted, free of charge, to any person +# obtaining a copy of this software and associated +# documentation files (the "Software"), to deal in the Software +# without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to +# whom the Software is furnished to do so, subject to the +# following conditions: + +# The above copyright notice and this permission notice shall +# be included in all copies or substantial portions of the +# Software. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +# PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + from ..utils.subpixel import SubPixelSurface from ..utils.annotations import Color from ..components.camera import CameraCatcher diff --git a/src/tleng2/engine/scene_manager.py b/src/tleng2/engine/scene_manager.py index d3073c8..f6a87c0 100644 --- a/src/tleng2/engine/scene_manager.py +++ b/src/tleng2/engine/scene_manager.py @@ -1,3 +1,27 @@ +# Copyright (c) 2023 Theolaos + +# Permission is hereby granted, free of charge, to any person +# obtaining a copy of this software and associated +# documentation files (the "Software"), to deal in the Software +# without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to +# whom the Software is furnished to do so, subject to the +# following conditions: + +# The above copyright notice and this permission notice shall +# be included in all copies or substantial portions of the +# Software. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +# PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + """ Scene Manager It justs puts the stuff on the screen and it handles the like menu->game->pause screen etc. diff --git a/src/tleng2/engine/settings.py b/src/tleng2/engine/settings.py index 38c108d..4bedbf5 100755 --- a/src/tleng2/engine/settings.py +++ b/src/tleng2/engine/settings.py @@ -1,3 +1,27 @@ +# Copyright (c) 2023 Theolaos + +# Permission is hereby granted, free of charge, to any person +# obtaining a copy of this software and associated +# documentation files (the "Software"), to deal in the Software +# without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to +# whom the Software is furnished to do so, subject to the +# following conditions: + +# The above copyright notice and this permission notice shall +# be included in all copies or substantial portions of the +# Software. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +# PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + import json import warnings diff --git a/src/tleng2/object/area.py b/src/tleng2/object/area.py index f006d49..30d9830 100755 --- a/src/tleng2/object/area.py +++ b/src/tleng2/object/area.py @@ -1,3 +1,27 @@ +# Copyright (c) 2023 Theolaos + +# Permission is hereby granted, free of charge, to any person +# obtaining a copy of this software and associated +# documentation files (the "Software"), to deal in the Software +# without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to +# whom the Software is furnished to do so, subject to the +# following conditions: + +# The above copyright notice and this permission notice shall +# be included in all copies or substantial portions of the +# Software. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +# PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + from dataclasses import dataclass, field import pygame from warnings import warn diff --git a/src/tleng2/object/point.py b/src/tleng2/object/point.py index 2dbbc6a..2106ca5 100644 --- a/src/tleng2/object/point.py +++ b/src/tleng2/object/point.py @@ -1,3 +1,27 @@ +# Copyright (c) 2023 Theolaos + +# Permission is hereby granted, free of charge, to any person +# obtaining a copy of this software and associated +# documentation files (the "Software"), to deal in the Software +# without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to +# whom the Software is furnished to do so, subject to the +# following conditions: + +# The above copyright notice and this permission notice shall +# be included in all copies or substantial portions of the +# Software. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +# PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + from pygame import Vector2, draw, surface from ..components.renderable import Renderable from ..utils.colors import RED diff --git a/src/tleng2/object/sprite.py b/src/tleng2/object/sprite.py index 138c468..aa624da 100755 --- a/src/tleng2/object/sprite.py +++ b/src/tleng2/object/sprite.py @@ -1,3 +1,27 @@ +# Copyright (c) 2023 Theolaos + +# Permission is hereby granted, free of charge, to any person +# obtaining a copy of this software and associated +# documentation files (the "Software"), to deal in the Software +# without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to +# whom the Software is furnished to do so, subject to the +# following conditions: + +# The above copyright notice and this permission notice shall +# be included in all copies or substantial portions of the +# Software. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +# PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + from .area import Area from ..services.animation import LazyAnimationService from ..services.image import ImageService diff --git a/src/tleng2/systems/engine_systems.py b/src/tleng2/systems/engine_systems.py index 381d14c..f96c68b 100644 --- a/src/tleng2/systems/engine_systems.py +++ b/src/tleng2/systems/engine_systems.py @@ -1,3 +1,27 @@ +# Copyright (c) 2023 Theolaos + +# Permission is hereby granted, free of charge, to any person +# obtaining a copy of this software and associated +# documentation files (the "Software"), to deal in the Software +# without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to +# whom the Software is furnished to do so, subject to the +# following conditions: + +# The above copyright notice and this permission notice shall +# be included in all copies or substantial portions of the +# Software. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +# PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + from ..ecs import * from ..components.engine import FpsComp from ..engine.methods import EngineMethods diff --git a/src/tleng2/systems/renderer.py b/src/tleng2/systems/renderer.py index 12cb042..c2213ea 100644 --- a/src/tleng2/systems/renderer.py +++ b/src/tleng2/systems/renderer.py @@ -1,3 +1,27 @@ +# Copyright (c) 2023 Theolaos + +# Permission is hereby granted, free of charge, to any person +# obtaining a copy of this software and associated +# documentation files (the "Software"), to deal in the Software +# without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to +# whom the Software is furnished to do so, subject to the +# following conditions: + +# The above copyright notice and this permission notice shall +# be included in all copies or substantial portions of the +# Software. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +# PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + from dataclasses import dataclass from time import time import pygame diff --git a/src/tleng2/utils/annotations.py b/src/tleng2/utils/annotations.py index 2388756..c463c18 100644 --- a/src/tleng2/utils/annotations.py +++ b/src/tleng2/utils/annotations.py @@ -1,3 +1,27 @@ +# Copyright (c) 2023 Theolaos + +# Permission is hereby granted, free of charge, to any person +# obtaining a copy of this software and associated +# documentation files (the "Software"), to deal in the Software +# without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to +# whom the Software is furnished to do so, subject to the +# following conditions: + +# The above copyright notice and this permission notice shall +# be included in all copies or substantial portions of the +# Software. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +# PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + from pygame.math import Vector2 #from pygame._common import RectValue from typing import IO, Callable, Tuple, Union, TypeVar diff --git a/src/tleng2/utils/colors.py b/src/tleng2/utils/colors.py index a69625b..7279f37 100644 --- a/src/tleng2/utils/colors.py +++ b/src/tleng2/utils/colors.py @@ -1,3 +1,27 @@ +# Copyright (c) 2023 Theolaos + +# Permission is hereby granted, free of charge, to any person +# obtaining a copy of this software and associated +# documentation files (the "Software"), to deal in the Software +# without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to +# whom the Software is furnished to do so, subject to the +# following conditions: + +# The above copyright notice and this permission notice shall +# be included in all copies or substantial portions of the +# Software. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +# PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + # legacy file # tleng2 special colors TLENG2_BLUE = (95,205,228) diff --git a/src/tleng2/utils/debug.py b/src/tleng2/utils/debug.py index d780f07..41dd6ac 100644 --- a/src/tleng2/utils/debug.py +++ b/src/tleng2/utils/debug.py @@ -1,3 +1,27 @@ +# Copyright (c) 2023 Theolaos + +# Permission is hereby granted, free of charge, to any person +# obtaining a copy of this software and associated +# documentation files (the "Software"), to deal in the Software +# without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to +# whom the Software is furnished to do so, subject to the +# following conditions: + +# The above copyright notice and this permission notice shall +# be included in all copies or substantial portions of the +# Software. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +# PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + from ..engine.settings import GlobalSettings from .colors import WHITE import pygame diff --git a/src/tleng2/utils/utils.py b/src/tleng2/utils/utils.py index b147bae..51e1dd6 100644 --- a/src/tleng2/utils/utils.py +++ b/src/tleng2/utils/utils.py @@ -1,3 +1,27 @@ +# Copyright (c) 2023 Theolaos + +# Permission is hereby granted, free of charge, to any person +# obtaining a copy of this software and associated +# documentation files (the "Software"), to deal in the Software +# without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to +# whom the Software is furnished to do so, subject to the +# following conditions: + +# The above copyright notice and this permission notice shall +# be included in all copies or substantial portions of the +# Software. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +# PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + import os from math import pi diff --git a/unit_tests/test_scenes.py b/unit_tests/test_scenes.py index e05de9c..f44f86b 100644 --- a/unit_tests/test_scenes.py +++ b/unit_tests/test_scenes.py @@ -51,6 +51,7 @@ class LogicTransform(ecs.System): schedule1 = ecs.Schedule() +# TODO add some systems here >:( schedule1.add_systems( 'Update', ) @@ -81,6 +82,7 @@ class LogicTransform(ecs.System): schedule2 = ecs.Schedule() +# TODO add some systems here also >:( schedule2.add_systems( 'Update', )