forked from Unity-Technologies/EntityComponentSystemSamples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCartesianGridOnCubeAuthoring.cs
More file actions
42 lines (36 loc) · 1.38 KB
/
Copy pathCartesianGridOnCubeAuthoring.cs
File metadata and controls
42 lines (36 loc) · 1.38 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
using Unity.Entities;
using UnityEngine;
// ReSharper disable once InconsistentNaming
[AddComponentMenu("DOTS Samples/GridPath/Cartesian Grid on Cube")]
public class CartesianGridOnCubeAuthoring : MonoBehaviour
{
[Range(2, 512)]
public int RowCount;
public GameObject[] FloorPrefab;
public GameObject WallPrefab;
// Specific wall probability, given PotentialWallProbability
public float WallSProbability = 0.5f;
public float WallWProbability = 0.5f;
class Baker : Baker<CartesianGridOnCubeAuthoring>
{
public override void Bake(CartesianGridOnCubeAuthoring authoring)
{
var floorPrefabCount = authoring.FloorPrefab.Length;
if (floorPrefabCount == 0)
return;
var floorPrefabs = AddBuffer<CartesianGridOnCubeGeneratorFloorPrefab>();
floorPrefabs.Length = authoring.FloorPrefab.Length;
for (int i = 0; i < authoring.FloorPrefab.Length; i++)
{
floorPrefabs[i] = GetEntity(authoring.FloorPrefab[i]);
}
AddComponent(new CartesianGridOnCubeGenerator
{
RowCount = authoring.RowCount,
WallSProbability = authoring.WallSProbability,
WallWProbability = authoring.WallWProbability,
WallPrefab = GetEntity(authoring.WallPrefab),
});
}
}
}