balcony fucked
This commit is contained in:
@@ -14,6 +14,7 @@ class Facade:
|
|||||||
self.padding = 0
|
self.padding = 0
|
||||||
self.window = self.get_window()
|
self.window = self.get_window()
|
||||||
self.has_balcony = self.has_balcony()
|
self.has_balcony = self.has_balcony()
|
||||||
|
self.balcony = self.get_balcony()
|
||||||
self.has_inter_floor = self.has_inter_floor()
|
self.has_inter_floor = self.has_inter_floor()
|
||||||
self.editor, self.materials = None,None
|
self.editor, self.materials = None,None
|
||||||
|
|
||||||
@@ -26,6 +27,7 @@ class Facade:
|
|||||||
with editor.pushTransform(Transform(vertice.point1.position,rotation = vertice.facing.value)):
|
with editor.pushTransform(Transform(vertice.point1.position,rotation = vertice.facing.value)):
|
||||||
self.window.build(editor, materials)
|
self.window.build(editor, materials)
|
||||||
self.build_inter_floor()
|
self.build_inter_floor()
|
||||||
|
if self.has_balcony: self.balcony.build(editor, materials)
|
||||||
|
|
||||||
def get_window(self) -> Window:
|
def get_window(self) -> Window:
|
||||||
if self.is_inner_or_outer == COLLUMN_STYLE.OUTER or self.is_inner_or_outer == COLLUMN_STYLE.BOTH:
|
if self.is_inner_or_outer == COLLUMN_STYLE.OUTER or self.is_inner_or_outer == COLLUMN_STYLE.BOTH:
|
||||||
@@ -36,7 +38,8 @@ class Facade:
|
|||||||
|
|
||||||
return Window(self.rdata["windows"] ,max_width, max_height, self.length, self.height)
|
return Window(self.rdata["windows"] ,max_width, max_height, self.length, self.height)
|
||||||
|
|
||||||
def get_balcony(self) -> Balcony:
|
def get_balcony(self) -> Balcony|None:
|
||||||
|
if not self.has_balcony: return None
|
||||||
max_width = self.length-2*self.padding
|
max_width = self.length-2*self.padding
|
||||||
return Balcony(self.rdata["balcony"], max_width, self.window)
|
return Balcony(self.rdata["balcony"], max_width, self.window)
|
||||||
|
|
||||||
@@ -46,6 +49,7 @@ class Facade:
|
|||||||
geometry.placeCuboid(self.editor,(0,self.height,-1),(self.length-1,self.height,-1),Block(self.materials[4], {"facing": "south", "half": "top"}))
|
geometry.placeCuboid(self.editor,(0,self.height,-1),(self.length-1,self.height,-1),Block(self.materials[4], {"facing": "south", "half": "top"}))
|
||||||
|
|
||||||
def has_balcony(self) -> bool:
|
def has_balcony(self) -> bool:
|
||||||
|
return True
|
||||||
return self.rdata["balcony"]["proba"] >= rd.random()
|
return self.rdata["balcony"]["proba"] >= rd.random()
|
||||||
|
|
||||||
def has_inter_floor(self) -> bool:
|
def has_inter_floor(self) -> bool:
|
||||||
|
|||||||
@@ -1,34 +1,58 @@
|
|||||||
import random as rd
|
import random as rd
|
||||||
|
from gdpc import Editor, Block, geometry, Transform
|
||||||
from buildings.geometry.Point import Point
|
from buildings.geometry.Point import Point
|
||||||
from buildings.geometry.Vertice import Vertice
|
from buildings.geometry.Vertice import Vertice
|
||||||
from buildings.elements.Window import Window
|
from buildings.elements.Window import Window
|
||||||
|
|
||||||
class Balcony:
|
class Balcony:
|
||||||
def __init__(self, rdata, windows : Window):
|
def __init__(self, rdata, max_width : int, windows : Window):
|
||||||
self.rdata = rdata
|
self.rdata = rdata
|
||||||
self.windows = windows
|
self.windows = windows
|
||||||
|
self.max_width = max_width
|
||||||
self.length = self.get_len()
|
self.length = self.get_len()
|
||||||
self.has_multiple = self.has_multiple_balcony()
|
self.has_multiple = self.has_multiple_balcony()
|
||||||
self.follow_window = self.follow_window()
|
self.follow_window = self.follow_window()
|
||||||
|
self.structure = self.get_structures()
|
||||||
|
|
||||||
|
def build(self, editor : Editor, materials : list[str]):
|
||||||
|
for s in self.structure:
|
||||||
|
s.fill(editor, materials[0])
|
||||||
|
|
||||||
def get_structures(self) -> list[Vertice]:
|
def get_structures(self) -> list[Vertice]:
|
||||||
attach_points = self.get_attach_points()
|
attach_points = self.get_attach_points()
|
||||||
len_attach_points = len(attach_points)
|
len_attach_points = len(attach_points)
|
||||||
min_wid = self.rdata["balcony"]["size"]["min_width"]
|
min_wid = self.rdata["size"]["min_width"] -1
|
||||||
growth_chance = self.rdata["balcony"]["growth"]
|
min_gap = self.rdata["multiple"]["min_gap"]
|
||||||
|
growth_chance = self.rdata["growth"]
|
||||||
midpoint = len_attach_points//2
|
midpoint = len_attach_points//2
|
||||||
x1,x2 = midpoint, len_attach_points - midpoint
|
x1,x2 = midpoint, len_attach_points - midpoint
|
||||||
|
|
||||||
structures = []
|
structures = []
|
||||||
|
centered = True
|
||||||
while True:
|
while True:
|
||||||
x1 -= 1
|
x1 -= 1
|
||||||
x2 += 1
|
x2 += 1 if centered else 0
|
||||||
if x1 < 0 : break
|
leng = attach_points[x2] - attach_points[x1] - 1
|
||||||
if attach_points[x2] - attach_points[x1] + 1 < min_wid: continue
|
|
||||||
|
if x1 == 0:
|
||||||
|
if leng >= min_wid: structures.append(self.create_structure(attach_points[x1], attach_points[x2]))
|
||||||
|
break
|
||||||
|
if leng < min_wid: continue
|
||||||
|
|
||||||
if growth_chance < rd.random():
|
if growth_chance < rd.random():
|
||||||
structures.append(self.create_structure(attach_points[x1], attach_points[x2]))
|
structures.append(self.create_structure(attach_points[x1], attach_points[x2]))
|
||||||
if not self.has_multiple: break
|
if not centered:
|
||||||
|
structures.append(self.create_structure(attach_points[len_attach_points-x1], attach_points[len_attach_points-x2]))
|
||||||
|
|
||||||
|
if not self.has_multiple: break
|
||||||
|
else:
|
||||||
|
if x1-min_wid < min_gap: break
|
||||||
|
gap = rd.randint(min_gap, x1-min_wid)
|
||||||
|
x2 = x1-gap
|
||||||
|
x1 = x2-min_wid
|
||||||
|
|
||||||
|
|
||||||
|
return structures
|
||||||
|
|
||||||
def get_attach_points(self) -> list[int]:
|
def get_attach_points(self) -> list[int]:
|
||||||
points = [i for i in range(self.max_width)]
|
points = [i for i in range(self.max_width)]
|
||||||
@@ -46,8 +70,8 @@ class Balcony:
|
|||||||
return self.windows.ypadding > 3
|
return self.windows.ypadding > 3
|
||||||
|
|
||||||
def has_multiple_balcony(self) -> bool:
|
def has_multiple_balcony(self) -> bool:
|
||||||
if self.max_width < self.rdata["balcony"]["multiple"]["min_width"]: return False
|
if self.max_width < self.rdata["multiple"]["min_width"]: return False
|
||||||
return self.rdata["balcony"]["multiple"]["proba"] >= rd.random()
|
return self.rdata["multiple"]["proba"] >= rd.random()
|
||||||
|
|
||||||
def get_len(self) -> int:
|
def get_len(self) -> int:
|
||||||
return rd.randint(self.rdata["balcony"]["size"]["min_len"], self.rdata["balcony"]["size"]["max_len"])
|
return rd.randint(self.rdata["size"]["min_len"], self.rdata["size"]["max_len"])
|
||||||
Reference in New Issue
Block a user