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

Update docs

This commit is contained in:
Steffo 2019-08-10 21:05:44 +02:00
parent 57378bfbaa
commit 60e9f17490
31 changed files with 5820 additions and 150 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
docs/doctrees/tiles.doctree Normal file

Binary file not shown.

Binary file not shown.

View file

@ -6,6 +6,7 @@ lihzahrd
world world
header header
tiles
Some useful links Some useful links

View file

@ -0,0 +1,11 @@
lihzahrd.header
====================================
.. toctree::
:maxdepth: 2
.. automodule:: lihzahrd.tiles
:members:
:private-members:
:undoc-members:

File diff suppressed because it is too large Load diff

View file

@ -35,6 +35,7 @@
<link rel="stylesheet" href="_static/pygments.css" type="text/css" /> <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<link rel="index" title="Index" href="genindex.html" /> <link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" /> <link rel="search" title="Search" href="search.html" />
<link rel="next" title="lihzahrd.header" href="tiles.html" />
<link rel="prev" title="lihzahrd.World" href="world.html" /> <link rel="prev" title="lihzahrd.World" href="world.html" />
</head> </head>
@ -84,6 +85,7 @@
<li class="toctree-l1 current"><a class="current reference internal" href="#">lihzahrd.header</a><ul class="simple"> <li class="toctree-l1 current"><a class="current reference internal" href="#">lihzahrd.header</a><ul class="simple">
</ul> </ul>
</li> </li>
<li class="toctree-l1"><a class="reference internal" href="tiles.html">lihzahrd.header</a></li>
</ul> </ul>
@ -466,91 +468,6 @@
</dd></dl> </dd></dl>
<dl class="class">
<dt id="lihzahrd.header.FileReader">
<em class="property">class </em><code class="sig-prename descclassname">lihzahrd.header.</code><code class="sig-name descname">FileReader</code><span class="sig-paren">(</span><em class="sig-param">file</em><span class="sig-paren">)</span><a class="headerlink" href="#lihzahrd.header.FileReader" title="Permalink to this definition"></a></dt>
<dd><dl class="method">
<dt id="lihzahrd.header.FileReader.bit">
<code class="sig-name descname">bit</code><span class="sig-paren">(</span><span class="sig-paren">)</span> &#x2192; Tuple[lihzahrd.header.filereader.FileReader.bool, lihzahrd.header.filereader.FileReader.bool, lihzahrd.header.filereader.FileReader.bool, lihzahrd.header.filereader.FileReader.bool, lihzahrd.header.filereader.FileReader.bool, lihzahrd.header.filereader.FileReader.bool, lihzahrd.header.filereader.FileReader.bool, lihzahrd.header.filereader.FileReader.bool]<a class="headerlink" href="#lihzahrd.header.FileReader.bit" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="lihzahrd.header.FileReader.bool">
<code class="sig-name descname">bool</code><span class="sig-paren">(</span><span class="sig-paren">)</span> &#x2192; bool<a class="headerlink" href="#lihzahrd.header.FileReader.bool" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="lihzahrd.header.FileReader.datetime">
<code class="sig-name descname">datetime</code><span class="sig-paren">(</span><span class="sig-paren">)</span> &#x2192; datetime.datetime<a class="headerlink" href="#lihzahrd.header.FileReader.datetime" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="lihzahrd.header.FileReader.double">
<code class="sig-name descname">double</code><span class="sig-paren">(</span><span class="sig-paren">)</span> &#x2192; float<a class="headerlink" href="#lihzahrd.header.FileReader.double" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="lihzahrd.header.FileReader.int1">
<code class="sig-name descname">int1</code><span class="sig-paren">(</span><span class="sig-paren">)</span> &#x2192; int<a class="headerlink" href="#lihzahrd.header.FileReader.int1" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="lihzahrd.header.FileReader.int2">
<code class="sig-name descname">int2</code><span class="sig-paren">(</span><span class="sig-paren">)</span> &#x2192; int<a class="headerlink" href="#lihzahrd.header.FileReader.int2" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="lihzahrd.header.FileReader.int4">
<code class="sig-name descname">int4</code><span class="sig-paren">(</span><span class="sig-paren">)</span> &#x2192; int<a class="headerlink" href="#lihzahrd.header.FileReader.int4" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="lihzahrd.header.FileReader.int8">
<code class="sig-name descname">int8</code><span class="sig-paren">(</span><span class="sig-paren">)</span> &#x2192; int<a class="headerlink" href="#lihzahrd.header.FileReader.int8" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="lihzahrd.header.FileReader.rect">
<code class="sig-name descname">rect</code><span class="sig-paren">(</span><span class="sig-paren">)</span> &#x2192; lihzahrd.header.rect.Rect<a class="headerlink" href="#lihzahrd.header.FileReader.rect" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="lihzahrd.header.FileReader.single">
<code class="sig-name descname">single</code><span class="sig-paren">(</span><span class="sig-paren">)</span> &#x2192; float<a class="headerlink" href="#lihzahrd.header.FileReader.single" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="lihzahrd.header.FileReader.string">
<code class="sig-name descname">string</code><span class="sig-paren">(</span><em class="sig-param">size=None</em><span class="sig-paren">)</span> &#x2192; str<a class="headerlink" href="#lihzahrd.header.FileReader.string" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="lihzahrd.header.FileReader.uint1">
<code class="sig-name descname">uint1</code><span class="sig-paren">(</span><span class="sig-paren">)</span> &#x2192; int<a class="headerlink" href="#lihzahrd.header.FileReader.uint1" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="lihzahrd.header.FileReader.uint2">
<code class="sig-name descname">uint2</code><span class="sig-paren">(</span><span class="sig-paren">)</span> &#x2192; int<a class="headerlink" href="#lihzahrd.header.FileReader.uint2" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="lihzahrd.header.FileReader.uint4">
<code class="sig-name descname">uint4</code><span class="sig-paren">(</span><span class="sig-paren">)</span> &#x2192; int<a class="headerlink" href="#lihzahrd.header.FileReader.uint4" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="lihzahrd.header.FileReader.uint8">
<code class="sig-name descname">uint8</code><span class="sig-paren">(</span><span class="sig-paren">)</span> &#x2192; int<a class="headerlink" href="#lihzahrd.header.FileReader.uint8" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="lihzahrd.header.FileReader.uuid">
<code class="sig-name descname">uuid</code><span class="sig-paren">(</span><span class="sig-paren">)</span> &#x2192; uuid.UUID<a class="headerlink" href="#lihzahrd.header.FileReader.uuid" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
</dd></dl>
<dl class="class"> <dl class="class">
<dt id="lihzahrd.header.FourPartSplit"> <dt id="lihzahrd.header.FourPartSplit">
<em class="property">class </em><code class="sig-prename descclassname">lihzahrd.header.</code><code class="sig-name descname">FourPartSplit</code><span class="sig-paren">(</span><em class="sig-param">separators: List[int], properties: List</em><span class="sig-paren">)</span><a class="headerlink" href="#lihzahrd.header.FourPartSplit" title="Permalink to this definition"></a></dt> <em class="property">class </em><code class="sig-prename descclassname">lihzahrd.header.</code><code class="sig-name descname">FourPartSplit</code><span class="sig-paren">(</span><em class="sig-param">separators: List[int], properties: List</em><span class="sig-paren">)</span><a class="headerlink" href="#lihzahrd.header.FourPartSplit" title="Permalink to this definition"></a></dt>
@ -879,11 +796,6 @@
</dd></dl> </dd></dl>
<dl class="class">
<dt id="lihzahrd.header.Rect">
<em class="property">class </em><code class="sig-prename descclassname">lihzahrd.header.</code><code class="sig-name descname">Rect</code><span class="sig-paren">(</span><em class="sig-param">left</em>, <em class="sig-param">right</em>, <em class="sig-param">top</em>, <em class="sig-param">bottom</em><span class="sig-paren">)</span><a class="headerlink" href="#lihzahrd.header.Rect" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="class"> <dl class="class">
<dt id="lihzahrd.header.Sandstorm"> <dt id="lihzahrd.header.Sandstorm">
<em class="property">class </em><code class="sig-prename descclassname">lihzahrd.header.</code><code class="sig-name descname">Sandstorm</code><span class="sig-paren">(</span><em class="sig-param">is_active: bool</em>, <em class="sig-param">time_left: int</em>, <em class="sig-param">severity: float</em>, <em class="sig-param">intended_severity: float</em><span class="sig-paren">)</span><a class="headerlink" href="#lihzahrd.header.Sandstorm" title="Permalink to this definition"></a></dt> <em class="property">class </em><code class="sig-prename descclassname">lihzahrd.header.</code><code class="sig-name descname">Sandstorm</code><span class="sig-paren">(</span><em class="sig-param">is_active: bool</em>, <em class="sig-param">time_left: int</em>, <em class="sig-param">severity: float</em>, <em class="sig-param">intended_severity: float</em><span class="sig-paren">)</span><a class="headerlink" href="#lihzahrd.header.Sandstorm" title="Permalink to this definition"></a></dt>
@ -1011,6 +923,8 @@
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
<a href="tiles.html" class="btn btn-neutral float-right" title="lihzahrd.header" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a>
<a href="world.html" class="btn btn-neutral float-left" title="lihzahrd.World" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a> <a href="world.html" class="btn btn-neutral float-left" title="lihzahrd.World" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a>

View file

@ -82,6 +82,7 @@
<ul> <ul>
<li class="toctree-l1"><a class="reference internal" href="world.html">lihzahrd.World</a></li> <li class="toctree-l1"><a class="reference internal" href="world.html">lihzahrd.World</a></li>
<li class="toctree-l1"><a class="reference internal" href="header.html">lihzahrd.header</a></li> <li class="toctree-l1"><a class="reference internal" href="header.html">lihzahrd.header</a></li>
<li class="toctree-l1"><a class="reference internal" href="tiles.html">lihzahrd.header</a></li>
</ul> </ul>
@ -156,6 +157,9 @@
<li class="toctree-l1"><a class="reference internal" href="header.html">lihzahrd.header</a><ul class="simple"> <li class="toctree-l1"><a class="reference internal" href="header.html">lihzahrd.header</a><ul class="simple">
</ul> </ul>
</li> </li>
<li class="toctree-l1"><a class="reference internal" href="tiles.html">lihzahrd.header</a><ul class="simple">
</ul>
</li>
</ul> </ul>
</div> </div>
<div class="section" id="some-useful-links"> <div class="section" id="some-useful-links">

Binary file not shown.

View file

@ -84,6 +84,7 @@
<ul> <ul>
<li class="toctree-l1"><a class="reference internal" href="world.html">lihzahrd.World</a></li> <li class="toctree-l1"><a class="reference internal" href="world.html">lihzahrd.World</a></li>
<li class="toctree-l1"><a class="reference internal" href="header.html">lihzahrd.header</a></li> <li class="toctree-l1"><a class="reference internal" href="header.html">lihzahrd.header</a></li>
<li class="toctree-l1"><a class="reference internal" href="tiles.html">lihzahrd.header</a></li>
</ul> </ul>
@ -166,6 +167,11 @@
<td>&#160;&#160;&#160; <td>&#160;&#160;&#160;
<a href="header.html#module-lihzahrd.header"><code class="xref">lihzahrd.header</code></a></td><td> <a href="header.html#module-lihzahrd.header"><code class="xref">lihzahrd.header</code></a></td><td>
<em></em></td></tr> <em></em></td></tr>
<tr class="cg-1">
<td></td>
<td>&#160;&#160;&#160;
<a href="tiles.html#module-lihzahrd.tiles"><code class="xref">lihzahrd.tiles</code></a></td><td>
<em></em></td></tr>
</table> </table>

View file

@ -82,6 +82,7 @@
<ul> <ul>
<li class="toctree-l1"><a class="reference internal" href="world.html">lihzahrd.World</a></li> <li class="toctree-l1"><a class="reference internal" href="world.html">lihzahrd.World</a></li>
<li class="toctree-l1"><a class="reference internal" href="header.html">lihzahrd.header</a></li> <li class="toctree-l1"><a class="reference internal" href="header.html">lihzahrd.header</a></li>
<li class="toctree-l1"><a class="reference internal" href="tiles.html">lihzahrd.header</a></li>
</ul> </ul>

File diff suppressed because one or more lines are too long

3977
docs/html/tiles.html Normal file

File diff suppressed because it is too large Load diff

View file

@ -85,6 +85,7 @@
</ul> </ul>
</li> </li>
<li class="toctree-l1"><a class="reference internal" href="header.html">lihzahrd.header</a></li> <li class="toctree-l1"><a class="reference internal" href="header.html">lihzahrd.header</a></li>
<li class="toctree-l1"><a class="reference internal" href="tiles.html">lihzahrd.header</a></li>
</ul> </ul>
@ -155,8 +156,13 @@
</div> </div>
<dl class="class"> <dl class="class">
<dt id="lihzahrd.World"> <dt id="lihzahrd.World">
<em class="property">class </em><code class="sig-prename descclassname">lihzahrd.</code><code class="sig-name descname">World</code><span class="sig-paren">(</span><em class="sig-param">version: lihzahrd.header.version.Version</em>, <em class="sig-param">savefile_type: int</em>, <em class="sig-param">revision: int</em>, <em class="sig-param">is_favorite: bool</em>, <em class="sig-param">name: str</em>, <em class="sig-param">generator: lihzahrd.header.generatorinfo.GeneratorInfo</em>, <em class="sig-param">uuid_: uuid.UUID</em>, <em class="sig-param">id_: int</em>, <em class="sig-param">bounds: lihzahrd.header.rect.Rect</em>, <em class="sig-param">size: lihzahrd.header.coordinates.Coordinates</em>, <em class="sig-param">is_expert: bool</em>, <em class="sig-param">created_on</em>, <em class="sig-param">styles: lihzahrd.header.styles.Styles</em>, <em class="sig-param">backgrounds: lihzahrd.header.backgrounds.Backgrounds</em>, <em class="sig-param">spawn_point: lihzahrd.header.coordinates.Coordinates</em>, <em class="sig-param">underground_level: float</em>, <em class="sig-param">cavern_level: float</em>, <em class="sig-param">time: lihzahrd.header.time.Time</em>, <em class="sig-param">events: lihzahrd.header.events.Events</em>, <em class="sig-param">dungeon_point: lihzahrd.header.coordinates.Coordinates</em>, <em class="sig-param">world_evil: lihzahrd.header.worldeviltype.WorldEvilType</em>, <em class="sig-param">saved_npcs: lihzahrd.header.savednpcs.SavedNPCs</em>, <em class="sig-param">altars_smashed: lihzahrd.header.altarssmashed.AltarsSmashed</em>, <em class="sig-param">is_hardmode: bool</em>, <em class="sig-param">shadow_orbs: lihzahrd.header.shadoworbs.ShadowOrbs</em>, <em class="sig-param">bosses_defeated: lihzahrd.header.bossesdefeated.BossesDefeated</em>, <em class="sig-param">anglers_quest: lihzahrd.header.anglerquest.AnglerQuest</em>, <em class="sig-param">clouds: lihzahrd.header.clouds.Clouds</em>, <em class="sig-param">cultist_delay: int</em><span class="sig-paren">)</span><a class="headerlink" href="#lihzahrd.World" title="Permalink to this definition"></a></dt> <em class="property">class </em><code class="sig-prename descclassname">lihzahrd.</code><code class="sig-name descname">World</code><span class="sig-paren">(</span><em class="sig-param">version: lihzahrd.header.version.Version</em>, <em class="sig-param">savefile_type: int</em>, <em class="sig-param">revision: int</em>, <em class="sig-param">is_favorite: bool</em>, <em class="sig-param">name: str</em>, <em class="sig-param">generator: lihzahrd.header.generatorinfo.GeneratorInfo</em>, <em class="sig-param">uuid_: uuid.UUID</em>, <em class="sig-param">id_: int</em>, <em class="sig-param">bounds: lihzahrd.fileutils.rect.Rect</em>, <em class="sig-param">size: lihzahrd.header.coordinates.Coordinates</em>, <em class="sig-param">is_expert: bool</em>, <em class="sig-param">created_on</em>, <em class="sig-param">styles: lihzahrd.header.styles.Styles</em>, <em class="sig-param">backgrounds: lihzahrd.header.backgrounds.Backgrounds</em>, <em class="sig-param">spawn_point: lihzahrd.header.coordinates.Coordinates</em>, <em class="sig-param">underground_level: float</em>, <em class="sig-param">cavern_level: float</em>, <em class="sig-param">time: lihzahrd.header.time.Time</em>, <em class="sig-param">events: lihzahrd.header.events.Events</em>, <em class="sig-param">dungeon_point: lihzahrd.header.coordinates.Coordinates</em>, <em class="sig-param">world_evil: lihzahrd.header.worldeviltype.WorldEvilType</em>, <em class="sig-param">saved_npcs: lihzahrd.header.savednpcs.SavedNPCs</em>, <em class="sig-param">altars_smashed: lihzahrd.header.altarssmashed.AltarsSmashed</em>, <em class="sig-param">is_hardmode: bool</em>, <em class="sig-param">shadow_orbs: lihzahrd.header.shadoworbs.ShadowOrbs</em>, <em class="sig-param">bosses_defeated: lihzahrd.header.bossesdefeated.BossesDefeated</em>, <em class="sig-param">anglers_quest: lihzahrd.header.anglerquest.AnglerQuest</em>, <em class="sig-param">clouds: lihzahrd.header.clouds.Clouds</em>, <em class="sig-param">cultist_delay: int</em><span class="sig-paren">)</span><a class="headerlink" href="#lihzahrd.World" title="Permalink to this definition"></a></dt>
<dd><p>The Python representation of a Terraria world.</p> <dd><p>The Python representation of a Terraria world.</p>
<dl class="method">
<dt id="lihzahrd.World._read_tiles">
<em class="property">static </em><code class="sig-name descname">_read_tiles</code><span class="sig-paren">(</span><em class="sig-param">fr: lihzahrd.fileutils.filereader.FileReader</em>, <em class="sig-param">tileframeimportant</em><span class="sig-paren">)</span> &#x2192; List<a class="headerlink" href="#lihzahrd.World._read_tiles" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="attribute"> <dl class="attribute">
<dt id="lihzahrd.World.altars_smashed"> <dt id="lihzahrd.World.altars_smashed">
<code class="sig-name descname">altars_smashed</code><em class="property"> = None</em><a class="headerlink" href="#lihzahrd.World.altars_smashed" title="Permalink to this definition"></a></dt> <code class="sig-name descname">altars_smashed</code><em class="property"> = None</em><a class="headerlink" href="#lihzahrd.World.altars_smashed" title="Permalink to this definition"></a></dt>

View file

@ -6,6 +6,7 @@ lihzahrd
world world
header header
tiles
Some useful links Some useful links

11
docs_source/tiles.rst Normal file
View file

@ -0,0 +1,11 @@
lihzahrd.header
====================================
.. toctree::
:maxdepth: 2
.. automodule:: lihzahrd.tiles
:members:
:private-members:
:undoc-members:

View file

@ -1,7 +1,7 @@
from .liquidtype import LiquidType from .liquidtype import LiquidType
from .rleencoding import RLEEncoding from .rleencoding import RLEEncoding
from .shape import Shape from .shape import Shape
from .wires import Wires from .wiring import Wiring
from .blocktype import BlockType from .blocktype import BlockType
from .frameimportantdata import FrameImportantData from .frameimportantdata import FrameImportantData
from .walltype import WallType from .walltype import WallType
@ -10,5 +10,5 @@ from .wall import Wall
from .liquid import Liquid from .liquid import Liquid
from .tile import Tile from .tile import Tile
__all__ = ["LiquidType", "RLEEncoding", "Shape", "Wires", "BlockType", "FrameImportantData", "WallType", "Block", __all__ = ["LiquidType", "RLEEncoding", "Shape", "Wiring", "BlockType", "FrameImportantData", "WallType", "Block",
"Wall", "Liquid", "Tile"] "Wall", "Liquid", "Tile"]

View file

@ -1,20 +1,33 @@
import typing import typing
from .blocktype import BlockType from .blocktype import BlockType
from .frameimportantdata import FrameImportantData from .frameimportantdata import FrameImportantData
from .shape import Shape
class Block: class Block:
__slots__ = "type", "frame", "paint", "is_active" """A block that has been placed in the world."""
__slots__ = "type", "frame", "shape", "paint", "is_active"
def __init__(self, def __init__(self,
type_: BlockType, type_: BlockType,
frame: typing.Optional[FrameImportantData], frame: typing.Optional[FrameImportantData],
shape: Shape,
paint: typing.Optional[int], paint: typing.Optional[int],
is_active: bool = True): is_active: bool = True):
self.type: BlockType = type_ self.type: BlockType = type_
"""The type of the block (dirt, stone, ...)."""
self.frame: typing.Optional[FrameImportantData] = frame self.frame: typing.Optional[FrameImportantData] = frame
"""The framedata of the block, if present."""
self.shape: Shape = shape
self.paint: typing.Optional[int] = paint self.paint: typing.Optional[int] = paint
"""The paint color of a block."""
self.is_active: bool = is_active self.is_active: bool = is_active
"""If the block is solid or can be passed through because of an Actuator."""
def __repr__(self): def __repr__(self):
return f"Block(type_={repr(self.type)}, frame={self.frame}, paint={self.paint}, is_active={self.is_active})" return f"Block(type_={repr(self.type)}, frame={self.frame}, paint={self.paint}, is_active={self.is_active})"

View file

@ -2,6 +2,9 @@ import enum
class BlockType(enum.IntEnum): class BlockType(enum.IntEnum):
"""All possible block types.
Data from https://github.com/tModLoader/tModLoader/wiki/Vanilla-Tile-IDs."""
DIRT = 0 DIRT = 0
STONE = 1 STONE = 1
GRASS = 2 GRASS = 2

View file

@ -1,4 +1,9 @@
class FrameImportantData: class FrameImportantData:
"""Frame data of FrameImportant blocks.
Some blocks share the same type and texture of other blocks (ex: banners), so they store some texture data inside
the save file."""
__slots__ = "frame_x", "frame_y" __slots__ = "frame_x", "frame_y"
def __init__(self, frame_x, frame_y): def __init__(self, frame_x, frame_y):

View file

@ -2,8 +2,17 @@ from .liquidtype import LiquidType
class Liquid: class Liquid:
"""A liquid present in a tile."""
__slots__ = "type", "volume" __slots__ = "type", "volume"
def __init__(self, type_: LiquidType, volume: int): def __init__(self, type_: LiquidType, volume: int):
self.type: LiquidType = type_ self.type: LiquidType = type_
"""The type of liquid present in the tile."""
self.volume: int = volume self.volume: int = volume
"""The volume of liquid present in the tile.
0 means the tile has no liquid, while 255 means the tile is full of liquid.
Values over 255 aren't supported."""

View file

@ -2,6 +2,7 @@ import enum
class LiquidType(enum.IntEnum): class LiquidType(enum.IntEnum):
"""All possible types of liquids."""
NO_LIQUID = 0 NO_LIQUID = 0
WATER = 1 WATER = 1
LAVA = 2 LAVA = 2

View file

@ -2,9 +2,16 @@ import enum
class RLEEncoding(enum.IntEnum): class RLEEncoding(enum.IntEnum):
"""How the RLE compression is encoded."""
NO_COMPRESSION = 0 NO_COMPRESSION = 0
"""The read data refers to a single tile."""
SINGLE_BYTE = 1 SINGLE_BYTE = 1
"""The read data refers to 2-255 tiles (1 byte)."""
DOUBLE_BYTE = 2 DOUBLE_BYTE = 2
"""The read data refers to 256-4800 tiles (2 bytes)."""
@classmethod @classmethod
def from_flags(cls, flags1): def from_flags(cls, flags1):

View file

@ -2,6 +2,10 @@ import enum
class Shape(enum.IntEnum): class Shape(enum.IntEnum):
"""The shape of a block, given to it with an hammer.
The directions refer to the missing slope corner."""
NORMAL = 0 NORMAL = 0
HALF_TILE = 1 HALF_TILE = 1
TOP_RIGHT_SLOPE = 2 TOP_RIGHT_SLOPE = 2

View file

@ -2,15 +2,23 @@ import typing
from .block import Block from .block import Block
from .wall import Wall from .wall import Wall
from .liquid import Liquid from .liquid import Liquid
from .wiring import Wiring
class Tile: class Tile:
__slots__ = "block", "wall", "liquid" """A tile, composed by a block, a wall, a liquid and wires."""
def __init__(self, block: typing.Optional[Block], wall: typing.Optional[Wall], liquid: typing.Optional[Liquid]): __slots__ = "block", "wall", "liquid", "wiring"
def __init__(self,
block: typing.Optional[Block],
wall: typing.Optional[Wall],
liquid: typing.Optional[Liquid],
wiring: Wiring):
self.block: typing.Optional[Block] = block self.block: typing.Optional[Block] = block
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: Wiring = wiring
def __repr__(self): def __repr__(self):
return f"<Tile {'B' if self.block else '_'}{'W' if self.wall else '_'}{'L' if self.liquid else '_'}>" return f"<Tile {'B' if self.block else '_'}{'W' if self.wall else '_'}{'L' if self.liquid else '_'}>"

View file

@ -3,6 +3,8 @@ from .walltype import WallType
class Wall: class Wall:
"""A wall that has been placed in the world."""
__slots__ = "type", "paint" __slots__ = "type", "paint"
def __init__(self, type_: WallType, paint: typing.Optional[int]): def __init__(self, type_: WallType, paint: typing.Optional[int]):

View file

@ -2,6 +2,9 @@ import enum
class WallType(enum.IntEnum): class WallType(enum.IntEnum):
"""All possible wall types.
Data from https://github.com/tModLoader/tModLoader/wiki/Vanilla-Wall-IDs."""
STONE = 1 STONE = 1
DIRT_UNSAFE = 2 DIRT_UNSAFE = 2
EBONSTONE_UNSAFE = 3 EBONSTONE_UNSAFE = 3

View file

@ -1,4 +1,6 @@
class Wires: class Wiring:
"""Wiring data for a certain tile."""
__slots__ = "red", "green", "blue", "yellow", "actuator" __slots__ = "red", "green", "blue", "yellow", "actuator"
def __init__(self, def __init__(self,
@ -8,10 +10,20 @@ class Wires:
yellow: bool = False, yellow: bool = False,
actuator: bool = False): actuator: bool = False):
self.red: bool = red self.red: bool = red
"""If there's a red Wire in the tile."""
self.green: bool = green self.green: bool = green
"""If there's a green Wire in the tile."""
self.blue: bool = blue self.blue: bool = blue
"""If there's a blue Wire in the tile."""
self.yellow: bool = yellow self.yellow: bool = yellow
"""If there's a yellow Wire in the tile."""
self.actuator: bool = actuator self.actuator: bool = actuator
"""If there's an Actuator in the tile."""
def __repr__(self): 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}," \
f" actuator={self.actuator})"

View file

@ -151,18 +151,18 @@ class World:
if flags2[0]: if flags2[0]:
flags3 = fr.bits() flags3 = fr.bits()
is_active = not flags3[2] is_active = not flags3[2]
wires = Wires(red=flags2[1], green=flags2[2], blue=flags2[3], yellow=flags3[5], actuator=flags3[1]) wiring = Wiring(red=flags2[1], green=flags2[2], blue=flags2[3], yellow=flags3[5], actuator=flags3[1])
is_block_painted = flags3[3] is_block_painted = flags3[3]
is_wall_painted = flags3[4] is_wall_painted = flags3[4]
else: else:
is_active = True is_active = True
wires = Wires(red=flags2[1], green=flags2[2], blue=flags2[3]) wiring = Wiring(red=flags2[1], green=flags2[2], blue=flags2[3])
is_block_painted = False is_block_painted = False
is_wall_painted = False is_wall_painted = False
else: else:
shape = Shape.NORMAL shape = Shape.NORMAL
is_active = True is_active = True
wires = Wires() wiring = Wiring()
is_block_painted = False is_block_painted = False
is_wall_painted = False is_wall_painted = False
if has_block: if has_block:
@ -180,7 +180,11 @@ class World:
block_paint = fr.uint1() block_paint = fr.uint1()
else: else:
block_paint = None block_paint = None
block = Block(type_=block_id, frame=FrameImportantData(frame_x, frame_y), paint=block_paint) block = Block(type_=block_id,
frame=FrameImportantData(frame_x, frame_y),
paint=block_paint,
is_active=is_active,
shape=shape)
else: else:
block = None block = None
if has_wall: if has_wall:
@ -202,7 +206,7 @@ class World:
multiply_by = fr.uint1() + 1 multiply_by = fr.uint1() + 1
else: else:
multiply_by = 1 multiply_by = 1
tile = Tile(block=block, wall=wall, liquid=liquid) tile = Tile(block=block, wall=wall, liquid=liquid, wiring=wiring)
return [tile] * multiply_by return [tile] * multiply_by
@classmethod @classmethod