Skip to content

Commit b796a90

Browse files
firefighters tutorial step 4: animation and UI
1 parent dc53fa2 commit b796a90

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+5663
-17
lines changed

EntitiesSamples/Assets/Miscellaneous/AnimateGameObject/SpawnSystem.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
using System;
21
using Unity.Burst;
32
using Unity.Collections;
43
using Unity.Entities;
54
using UnityEngine;
6-
using Object = UnityEngine.Object;
75

86
namespace Miscellaneous.AnimationWithGameObjects
97
{

EntitiesSamples/Assets/Tutorials/Firefighters/Common/Bot.prefab

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,6 @@ MeshRenderer:
6060
m_ReflectionProbeUsage: 1
6161
m_RayTracingMode: 2
6262
m_RayTraceProcedural: 0
63-
m_RayTracingAccelStructBuildFlagsOverride: 0
64-
m_RayTracingAccelStructBuildFlags: 1
65-
m_SmallMeshCulling: 1
6663
m_RenderingLayerMask: 1
6764
m_RendererPriority: 0
6865
m_Materials:

EntitiesSamples/Assets/Tutorials/Firefighters/Common/Config.prefab

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,5 @@ MonoBehaviour:
8888
type: 3}
8989
GroundCellPrefab: {fileID: 3422103013957337004, guid: 0142cf2bddc0e2f448344a8fb2222b4c,
9090
type: 3}
91+
BotAnimatedPrefabGO: {fileID: 5701704621631426976, guid: 36e93c435d1648a4c86d516057a9cbe2,
92+
type: 3}

EntitiesSamples/Assets/Tutorials/Firefighters/Common/ExecuteAuthoring.cs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ public class ExecuteAuthoring : MonoBehaviour
99
public bool ExecuteBotSystem;
1010
public bool ExecuteBucketSystem;
1111
public bool ExecuteTeamSystem;
12-
12+
public bool ExecuteUISystem;
13+
public bool ExecuteAnimationSystem;
14+
1315
class Baker : Baker<ExecuteAuthoring>
1416
{
1517
public override void Bake(ExecuteAuthoring authoring)
@@ -34,6 +36,16 @@ public override void Bake(ExecuteAuthoring authoring)
3436
{
3537
AddComponent<ExecuteTeam>(entity);
3638
}
39+
40+
if (authoring.ExecuteUISystem)
41+
{
42+
AddComponent<ExecuteUI>(entity);
43+
}
44+
45+
if (authoring.ExecuteAnimationSystem)
46+
{
47+
AddComponent<ExecuteAnimation>(entity);
48+
}
3749
}
3850
}
3951
}
@@ -53,4 +65,12 @@ public struct ExecuteBucket : IComponentData
5365
public struct ExecuteTeam : IComponentData
5466
{
5567
}
68+
69+
public struct ExecuteUI : IComponentData
70+
{
71+
}
72+
73+
public struct ExecuteAnimation : IComponentData
74+
{
75+
}
5676
}

EntitiesSamples/Assets/Tutorials/Firefighters/Common/firefighters.png.meta

Lines changed: 114 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

EntitiesSamples/Assets/Tutorials/Firefighters/README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,8 @@ This step adds code to spread the fire. Three solutions are demonstrated:
1818

1919
# Step 3: Bot behaviour
2020

21-
This step adds behiour to the bots, who are organized into teams. Each team forms a line between a pond and the closest fire. A bucket is filled at the pond and then passed up the line.
21+
This step adds behiour to the bots, who are organized into teams. Each team forms a line between a pond and the closest fire. A bucket is filled at the pond and then passed up the line.
22+
23+
# Step 4: Animation and UI
24+
25+
This step replaces the bot capsules with animated characters. A UI HUD element displays the total count of fires that have been doused.

EntitiesSamples/Assets/Tutorials/Firefighters/README.md.meta

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

EntitiesSamples/Assets/Tutorials/Firefighters/Step 1/BotAuthoring.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@ public struct Bot : IComponentData
2828
public Entity Bucket; // The bucket that the bot is carrying.
2929
public bool IsCarrying; // True if carrying a bucket.
3030
public Entity Team; // The team to which the bot belongs.
31+
32+
public readonly bool IsMoving()
33+
{
34+
return !(State == BotState.IDLE
35+
|| State == BotState.CLAIM_BUCKET
36+
|| State == BotState.WAIT_IN_LINE
37+
|| State == BotState.FILL_BUCKET);
38+
}
3139
}
3240

3341
public enum BotState

EntitiesSamples/Assets/Tutorials/Firefighters/Step 1/Components.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using Unity.Entities;
2+
using UnityEngine;
23

34
namespace Tutorials.Firefighters
45
{
@@ -7,6 +8,7 @@ public struct Team : IComponentData
78
public Entity Filler;
89
public Entity Douser;
910
public bool HasBucket;
11+
public int NumFiresDoused;
1012
}
1113

1214
// all bots in the team (including the Filler and Douser) in order of passing, starting with the Filler
@@ -24,4 +26,9 @@ public struct Heat : IBufferElementData
2426
{
2527
public float Value;
2628
}
29+
30+
public class BotAnimation : IComponentData
31+
{
32+
public GameObject AnimatedGO; // the GO that is rendered and animated
33+
}
2734
}

EntitiesSamples/Assets/Tutorials/Firefighters/Step 1/ConfigAuthoring.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public class ConfigAuthoring : MonoBehaviour
4141
public GameObject BucketPrefab;
4242
public GameObject PondPrefab;
4343
public GameObject GroundCellPrefab;
44+
public GameObject BotAnimatedPrefabGO;
4445

4546
class Baker : Baker<ConfigAuthoring>
4647
{
@@ -76,6 +77,9 @@ public override void Bake(ConfigAuthoring authoring)
7677
PondPrefab = GetEntity(authoring.PondPrefab, TransformUsageFlags.Dynamic),
7778
GroundCellPrefab = GetEntity(authoring.GroundCellPrefab, TransformUsageFlags.Dynamic),
7879
});
80+
var configManaged = new ConfigManaged();
81+
configManaged.BotAnimatedPrefabGO = authoring.BotAnimatedPrefabGO;
82+
AddComponentObject(entity, configManaged);
7983
}
8084
}
8185
}
@@ -110,4 +114,10 @@ public struct Config : IComponentData
110114
public Entity PondPrefab;
111115
public Entity GroundCellPrefab;
112116
}
117+
118+
public class ConfigManaged : IComponentData
119+
{
120+
public GameObject BotAnimatedPrefabGO;
121+
public UIController UIController;
122+
}
113123
}

0 commit comments

Comments
 (0)