Fix gas poisoning, explosion hit detection and render order

- Move gas poisoning from Gas.move() to Gas.collisions() so all rats are
  registered in the collision system before the poison query runs.
- Shrink gas and explosion bboxes so rats must be well inside the tile to
  be poisoned/killed.
- Use AABB overlap instead of partial_move threshold for gas poisoning.
- Draw mobile units first, then top-layer effects (gas, mines, bombs,
  explosions) so rats appear under the gas.
- Add draw_on_top hint to Unit base class and top-layer units.
This commit is contained in:
2026-06-16 19:19:14 +02:00
parent 3e8cd97fda
commit 2f8e3e8b28
7 changed files with 88 additions and 33 deletions
+13
View File
@@ -9,6 +9,19 @@ This structure is designed to be easily portable to Nim.
from typing import Dict, List, Tuple, Set
from dataclasses import dataclass
def shrink_bbox(bbox: Tuple[float, float, float, float], ratio: float) -> Tuple[float, float, float, float]:
"""Return a smaller bbox centered on the original one.
ratio is the fraction of width/height removed from each side.
E.g. ratio=0.25 keeps the central 50% of the original area.
"""
x1, y1, x2, y2 = bbox
dx = (x2 - x1) * ratio / 2
dy = (y2 - y1) * ratio / 2
return (x1 + dx, y1 + dy, x2 - dx, y2 - dy)
@dataclass
class CollisionLayer:
"""Define which types of units can collide with each other."""