From: Axy Date: Tue, 22 Sep 2026 23:10:10 +0000 (+0200) Subject: Partial cleanup X-Git-Url: https://git.uwuaxy.net/sitemap.xml?a=commitdiff_plain;ds=inline;p=axy%2Fft%2Fpacman.git Partial cleanup --- diff --git a/.flake8 b/.flake8 new file mode 100644 index 0000000..0081794 --- /dev/null +++ b/.flake8 @@ -0,0 +1,2 @@ +[flake8] +ignore = E203,W503 diff --git a/src/pacman/ecs/__init__.py b/src/pacman/ecs/__init__.py index c231363..67c5ba7 100644 --- a/src/pacman/ecs/__init__.py +++ b/src/pacman/ecs/__init__.py @@ -17,7 +17,6 @@ from pacman.ecs.schedule import ( ) from pacman.ecs.world import ( Component, - Entity, Not, Query, Resource, diff --git a/src/pacman/ecs/world.py b/src/pacman/ecs/world.py index 7f0a862..9327c9c 100644 --- a/src/pacman/ecs/world.py +++ b/src/pacman/ecs/world.py @@ -1,17 +1,14 @@ import inspect -from abc import abstractmethod +from abc import ABC, abstractmethod from collections.abc import Callable, Container, Iterable, Iterator -from dataclasses import dataclass from typing import ( Any, Literal, - Protocol, Self, Union, cast, get_args, override, - runtime_checkable, ) from pacman.ecs.schedule import ( @@ -28,12 +25,7 @@ from pacman.utils.variadics_please import ( ) -@dataclass -class Resource2[T]: - storage: type[T] - - -class ComponentLike(Protocol): +class Bundle(ABC): @abstractmethod def components_iter(self) -> Iterator["Component"]: ... @classmethod @@ -41,7 +33,7 @@ class ComponentLike(Protocol): def components_type_iter(cls) -> Iterator[type["Component"]]: ... -type Components = RecursiveTuple["Component | ComponentLike"] +type Components = RecursiveTuple["Component | Bundle"] def components_iter(components: Components) -> Iterator["Component"]: @@ -65,7 +57,7 @@ def components_type_iter( elif issubclass(components, Component): yield components else: - yield from cast(type[ComponentLike], components).components_type_iter() + yield from cast(type[Bundle], components).components_type_iter() class Archetype: @@ -202,8 +194,7 @@ type Plugin = RecursiveTuple[Callable[["World"], None]] type ComponentHook[T] = Callable[["World", "Entity", T], None] -@runtime_checkable -class FromWorld(Protocol): +class FromWorld(ABC): @classmethod @abstractmethod def extract_from_world( @@ -214,7 +205,7 @@ class FromWorld(Protocol): pass -class QueryFilter: +class QueryFilter(ABC): @classmethod @abstractmethod def filter( @@ -542,7 +533,7 @@ class Resource(FromWorld, Component): class CommandQueue(FromWorld): - def __init__(self, world: "World"): + def __init__(self, world: "World") -> None: self._world = world self._queue: list[Callable[[World], Any]] = [] @@ -602,7 +593,7 @@ class World(FromWorld): ents = self.spawn_many_empty(len(comps)) self._base_archetype.add_components( cast(type[Components], ty), - list(zip(ents, cast(list[Components], comps))), + list(zip(ents, cast(list[Components], comps), strict=True)), ) return ents