mirror of
https://github.com/Steffo99/lihzahrd.git
synced 2024-11-21 15:44:24 +00:00
Use slots for faster access
This commit is contained in:
parent
740577f578
commit
57378bfbaa
6 changed files with 12 additions and 1 deletions
|
@ -4,6 +4,8 @@ from .frameimportantdata import FrameImportantData
|
|||
|
||||
|
||||
class Block:
|
||||
__slots__ = "type", "frame", "paint", "is_active"
|
||||
|
||||
def __init__(self,
|
||||
type_: BlockType,
|
||||
frame: typing.Optional[FrameImportantData],
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
class FrameImportantData:
|
||||
__slots__ = "frame_x", "frame_y"
|
||||
|
||||
def __init__(self, frame_x, frame_y):
|
||||
self.frame_x: int = frame_x
|
||||
self.frame_y: int = frame_y
|
||||
|
|
|
@ -2,6 +2,8 @@ from .liquidtype import LiquidType
|
|||
|
||||
|
||||
class Liquid:
|
||||
__slots__ = "type", "volume"
|
||||
|
||||
def __init__(self, type_: LiquidType, volume: int):
|
||||
self.type: LiquidType = type_
|
||||
self.volume: int = volume
|
||||
|
|
|
@ -5,6 +5,7 @@ from .liquid import Liquid
|
|||
|
||||
|
||||
class Tile:
|
||||
__slots__ = "block", "wall", "liquid"
|
||||
|
||||
def __init__(self, block: typing.Optional[Block], wall: typing.Optional[Wall], liquid: typing.Optional[Liquid]):
|
||||
self.block: typing.Optional[Block] = block
|
||||
|
|
|
@ -3,6 +3,8 @@ from .walltype import WallType
|
|||
|
||||
|
||||
class Wall:
|
||||
__slots__ = "type", "paint"
|
||||
|
||||
def __init__(self, type_: WallType, paint: typing.Optional[int]):
|
||||
self.type: WallType = type_
|
||||
self.paint: typing.Optional[int] = paint
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
class Wires:
|
||||
__slots__ = "red", "green", "blue", "yellow", "actuator"
|
||||
|
||||
def __init__(self,
|
||||
red: bool = False,
|
||||
green: bool = False,
|
||||
|
@ -12,4 +14,4 @@ class Wires:
|
|||
self.actuator: bool = actuator
|
||||
|
||||
def __repr__(self):
|
||||
return f"Wires(red={self.red}, green={self.green}, blue={self.blue}, yellow={self.yellow}, actuator={self.actuator})"
|
||||
return f"Wires(red={self.red}, green={self.green}, blue={self.blue}, yellow={self.yellow}, actuator={self.actuator})"
|
||||
|
|
Loading…
Reference in a new issue