mirror of
https://github.com/OMGeeky/pytiled_parser.git
synced 2026-02-23 15:49:52 +01:00
updated objectgroup layer casting to be accurate. It was previously being done as a list of TiledObjects rather than a Layer
This commit is contained in:
@@ -5,6 +5,7 @@ from typing import List, NamedTuple, Optional
|
|||||||
import attr
|
import attr
|
||||||
from typing_extensions import TypedDict
|
from typing_extensions import TypedDict
|
||||||
|
|
||||||
|
from . import layer
|
||||||
from . import properties as properties_
|
from . import properties as properties_
|
||||||
from . import tiled_object
|
from . import tiled_object
|
||||||
from .common_types import Color, OrderedPair
|
from .common_types import Color, OrderedPair
|
||||||
@@ -96,7 +97,7 @@ class Tile:
|
|||||||
type: Optional[str] = None
|
type: Optional[str] = None
|
||||||
terrain: Optional[TileTerrain] = None
|
terrain: Optional[TileTerrain] = None
|
||||||
animation: Optional[List[Frame]] = None
|
animation: Optional[List[Frame]] = None
|
||||||
objects: Optional[List[tiled_object.TiledObject]] = None
|
objects: Optional[layer.Layer] = None
|
||||||
image: Optional[Path] = None
|
image: Optional[Path] = None
|
||||||
image_width: Optional[int] = None
|
image_width: Optional[int] = None
|
||||||
image_height: Optional[int] = None
|
image_height: Optional[int] = None
|
||||||
@@ -199,7 +200,7 @@ class RawTile(TypedDict):
|
|||||||
imagewidth: int
|
imagewidth: int
|
||||||
opacity: float
|
opacity: float
|
||||||
properties: List[properties_.RawProperty]
|
properties: List[properties_.RawProperty]
|
||||||
objects: List[tiled_object.RawTiledObject]
|
objectgroup: layer.RawLayer
|
||||||
terrain: List[int]
|
terrain: List[int]
|
||||||
type: str
|
type: str
|
||||||
|
|
||||||
@@ -303,10 +304,8 @@ def _cast_tile(raw_tile: RawTile) -> Tile:
|
|||||||
for frame in raw_tile["animation"]:
|
for frame in raw_tile["animation"]:
|
||||||
tile.animation.append(_cast_frame(frame))
|
tile.animation.append(_cast_frame(frame))
|
||||||
|
|
||||||
if raw_tile.get("objects") is not None:
|
if raw_tile.get("objectgroup") is not None:
|
||||||
tile.objects = []
|
tile.objects = layer.cast(raw_tile["objectgroup"])
|
||||||
for object_ in raw_tile["objects"]:
|
|
||||||
tile.objects.append(tiled_object.cast(object_))
|
|
||||||
|
|
||||||
if raw_tile.get("properties") is not None:
|
if raw_tile.get("properties") is not None:
|
||||||
tile.properties = properties_.cast(raw_tile["properties"])
|
tile.properties = properties_.cast(raw_tile["properties"])
|
||||||
|
|||||||
Reference in New Issue
Block a user