corrections corners bugs, clean tree structure and start entrance

This commit is contained in:
AKreuzer
2024-06-11 03:06:06 +02:00
parent 536c71d372
commit de3950d376
21 changed files with 153 additions and 86 deletions

View File

@@ -1,28 +1,28 @@
import random as rd
import numpy as np
import math
from utils.Enums import COLLUMN_STYLE
from utils.functions import *
from buildings.geometry.Tile import Tile
from buildings.geometry.Polygon import Polygon
from buildings.geometry.Point import Point
from buildings.geometry.Rectangle import Rectangle
from buildings.elements.Collumn import Collumn
class Foundations:
# TODO : gérer les collones sur les tiles trop petites et les colones 1tile/2 + fulltile
# TODO : gérer les collones sur les tiles trop petites et les colones 1tile/2
def __init__(self,
rdata,
size : tuple[int, int],
matrice : list[list[int]],
tile_size : int,
is_collumn_full_tile : bool,
is_inner_or_outer : COLLUMN_STYLE):
tile_size : int):
# Foundations are the base of the building, they are made of tiles and based on a matrice
# Random components
self.tile_size = tile_size
self.is_collumn_full_tile = is_collumn_full_tile
self.is_inner_or_outer = is_inner_or_outer
self.is_inner_or_outer = select_random(rdata["collumn_style"], COLLUMN_STYLE)
self.floor_height = rd.randint(rdata["floor"]["min_height"], rdata["floor"]["max_height"])-1
self.size = size
self.length, self.width = size
@@ -35,6 +35,17 @@ class Foundations:
self.z_distribution = []
self.polygon = self.get_polygon()
self.collumns = self.get_columns()
def build(self, editor, materials : list[str]):
self.polygon.fill(editor, materials[5],0)
self.polygon.fill(editor, materials[6], self.floor_height)
self.build_collumns(editor, materials)
def build_collumns(self, editor, materials : list[str]):
for collumn in self.collumns:
if collumn.is_outer and self.is_inner_or_outer == COLLUMN_STYLE.INNER: continue
if not collumn.is_outer and self.is_inner_or_outer == COLLUMN_STYLE.OUTER: continue
collumn.fill(editor, materials[7], self.floor_height)
def add_tile(self, tile : Tile):
self.tiles.append(tile)
@@ -42,11 +53,10 @@ class Foundations:
def get_polygon(self) -> Polygon:
## The polygon is a shape of tiles representing the foundation shape
polygon = Polygon(self.size)
avaliable_space = (self.length_in_tiles, self.width_in_tiles)
# we save the distribution, usefull for the next steps
self.x_distribution = self.get_distribution(len(self.matrice), avaliable_space[0])
self.z_distribution = self.get_distribution(len(self.matrice[0]), avaliable_space[1])
self.x_distribution = self.get_distribution(len(self.matrice), self.length_in_tiles)
self.z_distribution = self.get_distribution(len(self.matrice[0]), self.width_in_tiles)
# this bullshit is to create tiles from the matrice and the distribution
x_padding = 0
@@ -61,7 +71,7 @@ class Foundations:
z_padding += zsize * self.tile_size
x_padding += xsize * self.tile_size
polygon.set_vertices_and_neighbors(self.tiles, self.vertices)
polygon.set_vertices_and_neighbors(self.tiles, self.vertices, self.floor_height)
polygon.compress(self.tiles, self.vertices)
return polygon
@@ -106,6 +116,7 @@ class Foundations:
return sizes
def get_columns(self) -> list[Collumn]:
if self.is_inner_or_outer == COLLUMN_STYLE.NONE: return []
collumns = []
for tile in self.tiles: