Skip to content

Commit 32dad5d

Browse files
Added the Blackholio Unreal Blueprint Tutorial (#3313)
# Description of Changes - Expanded on the Unreal tutorial to create the Blueprint version, ~~this uses :::server-cpp and :::server-blueprint which might not work yet when deploying~~ with using Docusaurus Tabs. - Updated the server side code to use signed integers as discussed for both Rust + C# server modules. # API and ABI breaking changes None # Expected complexity level and risk 1 - Documentation update, does update the server side # Testing - [x] Manually tested both Rust + C# modules - [x] Ran through all images and steps
1 parent 8118dd8 commit 32dad5d

113 files changed

Lines changed: 909 additions & 342 deletions

File tree

Some content is hidden

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

demo/Blackholio/client-unity/Assets/PlayModeTests/PlayModeExampleTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public IEnumerator CreatePlayerAndTestDecay()
8989
Debug.Assert(circle != null, nameof(circle) + " != null");
9090
var ourEntity = GameManager.Conn.Db.Entity.EntityId.Find(circle.EntityId);
9191
var toChosenFood = new UnityEngine.Vector2(1000, 0);
92-
uint chosenFoodId = 0;
92+
int chosenFoodId = 0;
9393
foreach (var food in GameManager.Conn.Db.Food.Iter())
9494
{
9595
var thisFoodId = food.EntityId;

demo/Blackholio/client-unity/Assets/Scripts/EntityController.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ public abstract class EntityController : MonoBehaviour
1212

1313
private static readonly int ShaderColorProperty = Shader.PropertyToID("_Color");
1414

15-
[DoNotSerialize] public uint EntityId;
15+
[DoNotSerialize] public int EntityId;
1616

1717
protected float LerpTime;
1818
protected Vector3 LerpStartPosition;
1919
protected Vector3 LerpTargetPosition;
2020
protected Vector3 TargetScale;
2121

22-
protected virtual void Spawn(uint entityId)
22+
protected virtual void Spawn(int entityId)
2323
{
2424
EntityId = entityId;
2525

@@ -82,12 +82,12 @@ public virtual void Update()
8282
transform.localScale = Vector3.Lerp(transform.localScale, TargetScale, Time.deltaTime * 8);
8383
}
8484

85-
public static Vector3 MassToScale(uint mass)
85+
public static Vector3 MassToScale(int mass)
8686
{
8787
var diameter = MassToDiameter(mass);
8888
return new Vector3(diameter, diameter, 1);
8989
}
9090

91-
public static float MassToRadius(uint mass) => Mathf.Sqrt(mass);
92-
public static float MassToDiameter(uint mass) => MassToRadius(mass) * 2;
91+
public static float MassToRadius(int mass) => Mathf.Sqrt(mass);
92+
public static float MassToDiameter(int mass) => MassToRadius(mass) * 2;
9393
}

demo/Blackholio/client-unity/Assets/Scripts/GameManager.cs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ public class GameManager : MonoBehaviour
2424
public static Identity LocalIdentity { get; private set; }
2525
public static DbConnection Conn { get; private set; }
2626

27-
public static Dictionary<uint, EntityController> Entities = new Dictionary<uint, EntityController>();
28-
public static Dictionary<uint, PlayerController> Players = new Dictionary<uint, PlayerController>();
27+
public static Dictionary<int, EntityController> Entities = new Dictionary<int, EntityController>();
28+
public static Dictionary<int, PlayerController> Players = new Dictionary<int, PlayerController>();
2929

3030
private void Start()
3131
{
@@ -102,19 +102,19 @@ private void HandleSubscriptionApplied(SubscriptionEventContext ctx)
102102
{
103103
Debug.Log("Subscription applied!");
104104
OnSubscriptionApplied?.Invoke();
105-
105+
106106
// Once we have the initial subscription sync'd to the client cache
107107
// Get the world size from the config table and set up the arena
108108
var worldSize = Conn.Db.Config.Id.Find(0).WorldSize;
109109
SetupArena(worldSize);
110-
110+
111111
// Check to see if we already have a player, if we don't we'll need to create one
112112
var player = ctx.Db.Player.Identity.Find(LocalIdentity);
113113
if (string.IsNullOrEmpty(player.Name))
114114
{
115115
// The player has to choose a username
116116
UIUsernameChooser.Instance.Show(true);
117-
117+
118118
// When our username is updated, hide the username chooser
119119
Conn.Db.Player.OnUpdate += (_, _, newPlayer) =>
120120
{
@@ -123,14 +123,18 @@ private void HandleSubscriptionApplied(SubscriptionEventContext ctx)
123123
UIUsernameChooser.Instance.Show(false);
124124
}
125125
};
126-
} else {
126+
}
127+
else
128+
{
127129
// We already have a player
128130
if (ctx.Db.Circle.PlayerId.Filter(player.PlayerId).Any())
129131
{
130132
// We already have at least one circle, we should just be able to start
131133
// playing immediately.
132134
UIUsernameChooser.Instance.Show(false);
133-
} else {
135+
}
136+
else
137+
{
134138
// Create a new circle for our player.
135139
ctx.Reducers.EnterGame(player.Name);
136140
}
@@ -209,7 +213,7 @@ private static void PlayerOnDelete(EventContext context, Player deletedvalue)
209213
}
210214
}
211215

212-
private static PlayerController GetOrCreatePlayer(uint playerId)
216+
private static PlayerController GetOrCreatePlayer(int playerId)
213217
{
214218
if (!Players.TryGetValue(playerId, out var playerController))
215219
{

demo/Blackholio/client-unity/Assets/Scripts/LeaderboardRow.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ public class LeaderboardRow : MonoBehaviour
88
public TextMeshProUGUI UsernameText;
99
public TextMeshProUGUI MassText;
1010

11-
public void SetData(string username, uint mass)
11+
public void SetData(string username, int mass)
1212
{
1313
UsernameText.text = username;
1414
MassText.text = mass.ToString();

demo/Blackholio/client-unity/Assets/Scripts/PlayerController.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public class PlayerController : MonoBehaviour
1111

1212
public static PlayerController Local { get; private set; }
1313

14-
private uint PlayerId;
14+
private int PlayerId;
1515
private float LastMovementSendTimestamp;
1616
private Vector2? LockInputPosition;
1717
private List<CircleController> OwnedCircles = new List<CircleController>();
@@ -56,9 +56,9 @@ public void OnCircleDeleted(CircleController deletedCircle)
5656
}
5757
}
5858

59-
public uint TotalMass()
59+
public int TotalMass()
6060
{
61-
return (uint)OwnedCircles
61+
return (int)OwnedCircles
6262
.Select(circle => GameManager.Conn.Db.Entity.EntityId.Find(circle.EntityId))
6363
.Sum(e => e?.Mass ?? 0); //If this entity is being deleted on the same frame that we're moving, we can have a null entity here.
6464
}

demo/Blackholio/client-unity/Assets/Scripts/autogen/SpacetimeDBClient.g.cs

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

demo/Blackholio/client-unity/Assets/Scripts/autogen/Tables/Circle.g.cs

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

demo/Blackholio/client-unity/Assets/Scripts/autogen/Tables/Config.g.cs

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

demo/Blackholio/client-unity/Assets/Scripts/autogen/Tables/Entity.g.cs

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

demo/Blackholio/client-unity/Assets/Scripts/autogen/Tables/Food.g.cs

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

0 commit comments

Comments
 (0)