-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBlueprint.cs
More file actions
129 lines (108 loc) · 4.52 KB
/
Blueprint.cs
File metadata and controls
129 lines (108 loc) · 4.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
using UnityEngine;
using UnityEngine.Assertions;
namespace TowerGenerator
{
public class Blueprint
{
public class Segment
{
public class TopologySegment
{
public class ChunkGeometry
{
public Bounds Bounds; // position and aspects
public Vector3 BuildDirection;
public MetaBase Meta;
public int SizeIndex;
}
public ChunkGeometry Geometry;
public Vector3 Connection = Vector3.zero;
public bool HasCollision { get; set; }
public override string ToString()
{
return $"{Geometry.Meta.name}";
}
}
public class VisualSegment
{
public Transform ChunkTransform;
public long Seed;
// transform of created chunk
// decorations
// biome
// color scheme
}
public class ContentSegment
{
// monsters, chests, coins/diamonds, path
}
public override string ToString()
{
return $"{Topology}";
}
public TopologySegment Topology;
public VisualSegment Visual;
public ContentSegment Content;
}
public TreeNode<Segment> Tree;
//public static Segment mapper(SegmentArchitect.MemorySegment memSegData)
//{
// var blueprintSegment = new Segment();
// blueprintSegment.Topology = new Segment.TopologySegment();
// blueprintSegment.Topology.Geometry = memSegData.ChunkGeometry;
// return blueprintSegment;
//}
public void AddSubtree(
TreeNode<Segment> parent, // to which segment of a blueprint tree need to add
Vector3 connectorSideOnParent, // side of parent to connect subtree
TreeNode<Segment> subtree)
{
parent?.AddChild(subtree);
if (parent == null)
Tree = subtree;
}
//public static TreeNode<Segment> CreateTopologySegments(
// TreeNode<Segment> from,
// Vector3 connectorSideOnParent,
// TreeNode<SegmentArchitect.MemorySegment> project)
//{
// var blueprintChain = TreeNode<SegmentArchitect.MemorySegment>.Convert(project, mapper);
// from?.AddChild(blueprintChain);
// return blueprintChain;
//}
public static TreeNode<Segment> CreateTopologySegment(
TreeNode<Blueprint.Segment> parent,
Vector3 connectorSideOnParent,
Blueprint.Segment.TopologySegment.ChunkGeometry chunkGeometry)
{
Assert.IsNotNull(chunkGeometry);
// create segment & node
var segment = new Blueprint.Segment();
segment.Topology = new Blueprint.Segment.TopologySegment();
var node = new TreeNode<Blueprint.Segment>(segment);
// add created node to the parent
parent?.AddChild(node);
// set pos
//var parentAspRatX = parent?.Data.Topology.Geometry.Bounds.size.x ?? 0;
//var parentAspRatY = parent?.Data.Topology.Geometry.Bounds.size.y ?? 0;
//var parentAspRatZ = parent?.Data.Topology.Geometry.Bounds.size.z ?? 0;
//var xOffset = (parentAspRatX + aspectRatio.x) * attachDirection.x * .5f;
//var yOffset = (parentAspRatY + aspectRatio.y) * attachDirection.y * .5f;
//var zOffset = (parentAspRatZ + aspectRatio.z) * attachDirection.z * .5f;
//segment.Topology.Geometry.Bounds.center = parent == null
// ? Vector3.zero
// : parent.Data.Topology.Geometry.Bounds.center + new Vector3(xOffset, yOffset, zOffset);
//segment.Topology.Geometry.Bounds.center += offset;
//segment.Topology.Geometry.Bounds.size = aspectRatio;
//segment.Topology.Geometry.EntityType = chunkType;
//segment.Topology.HasCollision = false;
//segment.Topology.Geometry.BuildDirection = attachDirection;
node.Data.Topology.Geometry = chunkGeometry;
// connections
Assert.IsTrue(segment.Topology.Connection == Vector3.zero);
segment.Topology.Connection = -chunkGeometry.BuildDirection;
//State.Created.Push(node);
return node;
}
}
}