Base working for damage

This commit is contained in:
2026-10-09 23:10:40 -06:00
parent 2895be91c4
commit 3e0ad62cf2
31 changed files with 9758 additions and 67 deletions
+40
View File
@@ -0,0 +1,40 @@
import threading
import logging
from typing import Callable, List
from .photon import PhotonDecoder, PhotonMessage
from .translate import into_game_message
from .world import World
logger = logging.getLogger(__name__)
class Pipeline:
"""Decodes captured UDP payloads into app events (aoaddons lib.rs flow)."""
def __init__(self, emit: Callable[[dict], None]):
self.emit = emit
self.decoder = PhotonDecoder()
self.world = World()
self._lock = threading.RLock()
def on_udp(self, payload: bytes):
logger.debug("received UDP payload: %d bytes", len(payload))
messages = self.decoder.decode_packet(payload)
if not messages:
return
with self._lock:
for message in messages:
for event in self._events_from_message(message):
self.emit(event)
def _events_from_message(self, message: PhotonMessage) -> List[dict]:
game_message = into_game_message(message)
if game_message is None:
return []
logger.debug("translated game message: %s", game_message)
events = self.world.transform(game_message)
for event in events:
logger.debug("emitting app event: %s", event)
return events