84 lines
2.6 KiB
Plaintext
84 lines
2.6 KiB
Plaintext
Structure Generation Logic
|
|
|
|
1. Start with Program structure call
|
|
This call builds a map with the structure within it
|
|
It also appends/adds to a Live Structures list
|
|
Live Structures are similar to Structures, but their position and size is absolute (not relative or percentage)
|
|
|
|
2. Program build structure calls are _RECURSIVE_.
|
|
build method:
|
|
-- BEGIN BUILD LOGIC --
|
|
while (retry < retry_limit) {
|
|
retry_limit++;
|
|
generate position, size, and draw in this.map
|
|
create this.live structure for this.map
|
|
-- BUILD SUB STRUCTURES --
|
|
copy this.map to temp
|
|
for each relation
|
|
buildStructure to temp with this live structure
|
|
end
|
|
merge temp with this.map
|
|
-- CHECK IF OVERLAPPING STUFF --
|
|
if (overlap_flag || !is_overlapping) {
|
|
-- MERGE WITH PARENT MAP AND ADD
|
|
merge this.map and parent.map (resize parent if parent map is RESIZE)
|
|
add this.live to parent.live
|
|
break;
|
|
} else {
|
|
clear this Live Structures
|
|
clear this (map)
|
|
}
|
|
}
|
|
delete this.map
|
|
3. linking
|
|
for structure in live.unlinked (limit calls somehow, so endless is avoided)
|
|
assuming structure generation as:
|
|
tree -> node
|
|
-> node -> subnode
|
|
tree -> other
|
|
if in first tree:
|
|
"node" refers to first node
|
|
"node:subnode" refers to any node with subnode
|
|
":tree:other" -- first ":" denotes global, up to end ":"
|
|
if in subnode:
|
|
"^:^" - refers to tree, "$" means parent
|
|
"^:^:node" - refers to either parent or other node
|
|
|
|
General link syntax:
|
|
"^" - parent of live structure
|
|
":" - live sub structure of whatever context we're in
|
|
":" - if first item, that means global - travel up to parent root and discover from there
|
|
|
|
get target structure {
|
|
if target name[0] == ":"
|
|
target = getLiveStructure(getLiveStructureRoot(live), name)
|
|
else if target name[0] != ":"
|
|
target = getLiveStructure(live, name)
|
|
}
|
|
run pathing algorithm from live.x/live.y to target.x/target.y
|
|
while(!at_destination) {
|
|
create temp map
|
|
buildStructure(temp map, live)
|
|
merge temp map this.map at x, y
|
|
}
|
|
|
|
1. first pass
|
|
Generate structure positions and size
|
|
|
|
2. second pass
|
|
Link structures via from and to structure members
|
|
|
|
mock program logic:
|
|
buildStruct
|
|
(
|
|
... buildStruct ...
|
|
)
|
|
while (live_structures.unlinked) {
|
|
linkStruct
|
|
(
|
|
... buildStruct(s) from *from to *to ...
|
|
)
|
|
}
|
|
|
|
linking is contained in a loop limited by link_limit. This allows for linking paths to paths, up to a point (prevent endless loop)
|