1
1
using Unity . Entities ;
2
2
using Unity . Mathematics ;
3
3
using UnityEngine ;
4
- using UnityEngine . Serialization ;
5
4
6
5
namespace Tutorials . Firefighters
7
6
{
8
7
public class ConfigAuthoring : MonoBehaviour
9
8
{
10
- [ Header ( "Ponds" ) ]
9
+ [ Header ( "Ponds" ) ]
11
10
public int NumPondsPerEdge ;
12
11
13
- [ Header ( "Bots" ) ]
12
+ [ Header ( "Bots" ) ]
14
13
public int NumTeams ;
15
14
public int NumPassersPerTeam ;
16
15
public int BotMoveSpeed = 3 ; // units per second
17
16
public float LineMaxOffset = 4 ;
18
17
19
- [ Header ( "Buckets" ) ]
18
+ [ Header ( "Buckets" ) ]
20
19
public float BucketFillRate ;
21
20
public int NumBuckets ;
22
21
public Color BucketEmptyColor ;
23
22
public Color BucketFullColor ;
24
23
public float BucketEmptyScale ;
25
24
public float BucketFullScale ;
26
25
27
- [ Header ( "Ground" ) ]
26
+ [ Header ( "Ground" ) ]
28
27
public int GroundNumColumns ;
29
28
public int GroundNumRows ;
30
29
31
- [ Header ( "Heat" ) ]
30
+ [ Header ( "Heat" ) ]
32
31
public Color MinHeatColor ;
33
32
public Color MaxHeatColor ;
34
33
public float HeatSpreadSpeed ;
35
34
public float HeatOscillationScale ;
36
35
public int NumInitialCellsOnFire ;
37
36
public float HeatDouseTargetMin ;
38
37
39
- [ Header ( "Prefabs" ) ]
38
+ [ Header ( "Prefabs" ) ]
40
39
public GameObject BotPrefab ;
41
40
public GameObject BucketPrefab ;
42
41
public GameObject PondPrefab ;
@@ -48,18 +47,20 @@ class Baker : Baker<ConfigAuthoring>
48
47
public override void Bake ( ConfigAuthoring authoring )
49
48
{
50
49
var entity = GetEntity ( authoring , TransformUsageFlags . None ) ;
50
+ var numTeams = math . max ( authoring . NumTeams , 1 ) ;
51
51
AddComponent ( entity , new Config
52
52
{
53
53
GroundNumColumns = authoring . GroundNumColumns ,
54
54
GroundNumRows = authoring . GroundNumRows ,
55
55
NumPondsPerEdge = authoring . NumPondsPerEdge ,
56
- NumTeams = math . max ( authoring . NumTeams , 1 ) ,
56
+ NumTeams = numTeams ,
57
57
NumPassersPerTeam =
58
58
( math . max ( authoring . NumPassersPerTeam , 4 ) / 2 ) *
59
59
2 , // round down to even number and set min to 4
60
60
BotMoveSpeed = authoring . BotMoveSpeed ,
61
61
LineMaxOffset = authoring . LineMaxOffset ,
62
- NumBuckets = authoring . NumBuckets ,
62
+ NumBuckets =
63
+ math . max ( authoring . NumBuckets , numTeams ) , // make sure there's at least one bucket per team
63
64
BucketFillRate = authoring . BucketFillRate ,
64
65
MinHeatColor = ( Vector4 ) authoring . MinHeatColor ,
65
66
MaxHeatColor = ( Vector4 ) authoring . MaxHeatColor ,
@@ -120,4 +121,4 @@ public class ConfigManaged : IComponentData
120
121
public GameObject BotAnimatedPrefabGO ;
121
122
public UIController UIController ;
122
123
}
123
- }
124
+ }
0 commit comments