1
Fork 0
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:
Steffo 2019-08-12 17:18:48 +02:00
parent a8e483e5af
commit ff982e207c
4 changed files with 32 additions and 3 deletions

View file

@ -0,0 +1,3 @@
from .sign import Sign
__all__ = ["Sign"]

11
lihzahrd/signs/sign.py Normal file
View 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}>"

View file

@ -3,18 +3,20 @@ from .block import Block
from .wall import Wall from .wall import Wall
from .liquid import Liquid from .liquid import Liquid
from .wiring import Wiring from .wiring import Wiring
from ..chests import Chest
class Tile: class Tile:
"""A tile, composed by a block, a wall, a liquid and wires.""" """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, def __init__(self,
block: typing.Optional[Block] = None, block: typing.Optional[Block] = None,
wall: typing.Optional[Wall] = None, wall: typing.Optional[Wall] = None,
liquid: typing.Optional[Liquid] = 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: if wiring is None:
wiring = Wiring() wiring = Wiring()
@ -22,6 +24,7 @@ class Tile:
self.wall: typing.Optional[Wall] = wall self.wall: typing.Optional[Wall] = wall
self.liquid: typing.Optional[Liquid] = liquid self.liquid: typing.Optional[Liquid] = liquid
self.wiring: typing.Optional[Wiring] = wiring self.wiring: typing.Optional[Wiring] = wiring
self.extra: typing.Optional[typing.Union[Chest]] = extra
def __repr__(self): 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 '_'}>"

View file

@ -5,6 +5,7 @@ from .fileutils import *
from .header import * from .header import *
from .tiles import * from .tiles import *
from .chests import * from .chests import *
from .signs import *
from .timer import Timer from .timer import Timer
@ -515,6 +516,17 @@ class World:
unknown_chests_data = f.read_until(pointers.signs) 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, 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, 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, is_expert=is_expert, created_on=created_on, styles=world_styles, backgrounds=backgrounds,