1
Fork 0
mirror of https://github.com/Steffo99/lihzahrd.git synced 2024-11-21 23:54:23 +00:00

Added pylon, plate + hat/weapon rack parsing.

Combined Mannequin and Hat Tack into ClothingDisplay class.
Plate and weapon rack into single item display. Perhaps they'd be better
as tile entities?
This commit is contained in:
Dale Floer 2020-06-01 21:22:52 -07:00 committed by Stefano Pigozzi
parent f6df5928b0
commit e69b3aff5e
6 changed files with 79 additions and 9 deletions

View file

@ -1,6 +1,7 @@
from .itemtype import ItemType
from .itemstack import ItemStack
from .chest import Chest
from .mannequin import Mannequin
from .clothingdisplay import ClothingDisplay
from .singleitemdisplay import SingleItemDisplay
__all__ = ["ItemType", "ItemStack", "Chest", "Mannequin"]
__all__ = ["ItemType", "ItemStack", "Chest", "ClothingDisplay", "SingleItemDisplay"]

View file

@ -1,16 +1,20 @@
import typing
from .itemstack import ItemStack
class Mannequin:
"""Data pertaining to a Logic Sensor (https://terraria.gamepedia.com/Mannequin)."""
class ClothingDisplay:
"""Data pertaining to an item to display clothing.
Currently this is a Womannequin/Mannequin (https://terraria.gamepedia.com/Womannequin)
and hat rack (https://terraria.gamepedia.com/Hat_Rack).
"""
__slots__ = "item_flags", "dye_flags", "wearing_items", "wearing_dyes"
__slots__ = "item_flags", "dye_flags", "wearing_items", "wearing_dyes", "display_type"
def __init__(self,
item_flags: typing.List[bool],
dye_flags: typing.List[bool],
wearing_items: typing.List[ItemStack],
wearing_dyes: typing.List[ItemStack],):
wearing_dyes: typing.List[ItemStack],
display_type: str,):
self.item_flags: typing.List[bool] = item_flags
"""Which slots have items in them."""
@ -20,7 +24,9 @@ class Mannequin:
"""What items is the mannequin wearing."""
self.wearing_dyes: typing.List[ItemStack] = wearing_dyes
"""What dyes is the mannequin wearing."""
self.display_type: str = display_type
"""What type of display is this?"""
def __repr__(self):
return f"Mannequin()"
return f"ClothingDisplay(type={self.display_type}, dyes={len(self.wearing_dyes)}, )"

View file

@ -0,0 +1,23 @@
import typing
from .itemstack import ItemStack
class SingleItemDisplay:
"""Data pertaining to a single display item.
Currently weapon rack (https://terraria.gamepedia.com/Weapon_Rack)
and food plate (https://terraria.gamepedia.com/Plate).
"""
__slots__ = "display_item", "display_type"
def __init__(self,
display_item: typing.List[ItemStack],
display_type: str):
self.display_item: typing.List[ItemStack] = display_item
"""What item is on display."""
self.display_type: str = display_type
"""What type of single item display this is."""
def __repr__(self):
return f"SingleItemDisplay(display_type={self.display_type}, display_item={self.display_item})"

View file

@ -2,5 +2,6 @@ from .tileentity import TileEntity
from .itemframe import ItemFrame
from .logicsensor import LogicSensor
from .targetdummy import TargetDummy
from .pylon import Pylon
__all__ = ["TileEntity", "ItemFrame", "LogicSensor", "TargetDummy"]
__all__ = ["TileEntity", "ItemFrame", "LogicSensor", "TargetDummy", "Pylon"]

8
lihzahrd/tileentities/pylon.py Executable file
View file

@ -0,0 +1,8 @@
class Pylon:
"""Data pertaining to a Pylon (https://terraria.gamepedia.com/Pylons)"""
def __init__(self, pylon: bool = True):
self.pylon: bool = pylon
def __repr__(self):
return f"pylon={self.pylon}"

View file

@ -757,7 +757,38 @@ class World:
slot_item_modifier = f.int1()
slot_item_stack = f.int2()
mannequin_dyes[slot] = ItemStack(slot_item_id, slot_item_modifier, slot_item_stack)
te_extra = Mannequin(item_flags, dye_flags, mannequin_items, mannequin_dyes)
te_extra = ClothingDisplay(item_flags, dye_flags, mannequin_items, mannequin_dyes, "mannequin")
# Weapon Rack
elif te_type == 4:
rack_item = ItemStack(ItemType(f.int2()), f.int1(), f.int2())
te_extra = SingleItemDisplay(rack_item, "weapon_rack")
# Hat Rack
elif te_type == 5:
# This isn't 100% tested, but the first two flags should be items, and the second two should be dyes.
item_flags = f.bits()
# Maximum of two items slots and two dye slots.
rack_items = [None for _ in range(2)]
rack_dyes = [None for _ in range(2)]
for slot in range(2):
if item_flags[slot]:
slot_item_id = ItemType(f.int2())
slot_item_modifier = f.int1()
slot_item_stack = f.int2()
rack_items[slot] = ItemStack(slot_item_id, slot_item_modifier, slot_item_stack)
for slot in range(2):
if item_flags[slot + 2]:
slot_item_id = ItemType(f.int2())
slot_item_modifier = f.int1()
slot_item_stack = f.int2()
rack_dyes[slot] = ItemStack(slot_item_id, slot_item_modifier, slot_item_stack)
te_extra = ClothingDisplay(item_flags, dye_flags, mannequin_items, mannequin_dyes, "hat_rack")
# Food Plate
elif te_type == 6:
plate_item = ItemStack(ItemType(f.int2()), f.int1(), f.int2())
te_extra = SingleItemDisplay(plate_item, "food_plate")
# Teleport Pylon
elif te_type == 7:
te_extra = Pylon()
else:
print(f"te_type:", te_type)
te_extra = None