mirror of
https://github.com/Steffo99/lihzahrd.git
synced 2024-11-21 23:54:23 +00:00
Parse sign data
This commit is contained in:
parent
a8e483e5af
commit
ff982e207c
4 changed files with 32 additions and 3 deletions
3
lihzahrd/signs/__init__.py
Normal file
3
lihzahrd/signs/__init__.py
Normal file
|
@ -0,0 +1,3 @@
|
|||
from .sign import Sign
|
||||
|
||||
__all__ = ["Sign"]
|
11
lihzahrd/signs/sign.py
Normal file
11
lihzahrd/signs/sign.py
Normal file
|
@ -0,0 +1,11 @@
|
|||
from ..fileutils import Coordinates
|
||||
|
||||
|
||||
class Sign:
|
||||
"""A sign with something written on it."""
|
||||
def __init__(self, position: Coordinates, text: str = ""):
|
||||
self.position: Coordinates = position
|
||||
self.text: str = text
|
||||
|
||||
def __repr__(self):
|
||||
return f"<Sign at {self.position}>"
|
|
@ -3,18 +3,20 @@ from .block import Block
|
|||
from .wall import Wall
|
||||
from .liquid import Liquid
|
||||
from .wiring import Wiring
|
||||
from ..chests import Chest
|
||||
|
||||
|
||||
class Tile:
|
||||
"""A tile, composed by a block, a wall, a liquid and wires."""
|
||||
|
||||
__slots__ = "block", "wall", "liquid", "wiring"
|
||||
__slots__ = "block", "wall", "liquid", "wiring", "extra"
|
||||
|
||||
def __init__(self,
|
||||
block: typing.Optional[Block] = None,
|
||||
wall: typing.Optional[Wall] = None,
|
||||
liquid: typing.Optional[Liquid] = None,
|
||||
wiring: typing.Optional[Wiring] = None):
|
||||
wiring: typing.Optional[Wiring] = None,
|
||||
extra: typing.Optional[typing.Union[Chest]] = None):
|
||||
if wiring is None:
|
||||
wiring = Wiring()
|
||||
|
||||
|
@ -22,6 +24,7 @@ class Tile:
|
|||
self.wall: typing.Optional[Wall] = wall
|
||||
self.liquid: typing.Optional[Liquid] = liquid
|
||||
self.wiring: typing.Optional[Wiring] = wiring
|
||||
self.extra: typing.Optional[typing.Union[Chest]] = extra
|
||||
|
||||
def __repr__(self):
|
||||
return f"<Tile {'B' if self.block else '_'}{'W' if self.wall else '_'}{'L' if self.liquid else '_'}{'W' if self.wiring else '_'}>"
|
||||
return f"<Tile {'B' if self.block else '_'}{'W' if self.wall else '_'}{'L' if self.liquid else '_'}{'W' if self.wiring else '_'}{'E' if self.extra else '_'}>"
|
||||
|
|
|
@ -5,6 +5,7 @@ from .fileutils import *
|
|||
from .header import *
|
||||
from .tiles import *
|
||||
from .chests import *
|
||||
from .signs import *
|
||||
from .timer import Timer
|
||||
|
||||
|
||||
|
@ -515,6 +516,17 @@ class World:
|
|||
|
||||
unknown_chests_data = f.read_until(pointers.signs)
|
||||
|
||||
with Timer("Signs", display=True):
|
||||
signs = []
|
||||
|
||||
signs_count = f.int2()
|
||||
|
||||
for _ in range(signs_count):
|
||||
sign = Sign(text=f.string(),
|
||||
position=Coordinates(f.int4(), f.int4()))
|
||||
|
||||
unknown_signs_data = f.read_until(pointers.npcs)
|
||||
|
||||
world = World(version=version, savefile_type=savefile_type, revision=revision, is_favorite=is_favorite,
|
||||
name=name, generator=generator, uuid_=uuid_, id_=id_, bounds=bounds, size=world_size,
|
||||
is_expert=is_expert, created_on=created_on, styles=world_styles, backgrounds=backgrounds,
|
||||
|
|
Loading…
Reference in a new issue