Skip to content

Commit c6a003f

Browse files
bfopscloutiertyler
andauthored
Upgrade to 1.0.0-rc1 (#9)
* upgrade to 1.0.0-rc1 * fixed compilation errors --------- Co-authored-by: Zeke Foppa <[email protected]> Co-authored-by: Tyler Cloutier <[email protected]>
1 parent 8bacbd7 commit c6a003f

File tree

6 files changed

+132
-97
lines changed

6 files changed

+132
-97
lines changed

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,6 @@ public IEnumerator ReconnectionViaReloadingScene()
235235
GameManager.OnConnect += () =>
236236
{
237237
connected = true;
238-
239238
};
240239
GameManager.OnSubscriptionApplied += () =>
241240
{

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

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public class GameManager : MonoBehaviour
2020

2121
public static event CallbackDelegate OnConnect;
2222
public static event CallbackDelegate OnSubscriptionApplied;
23-
23+
2424
public static Color[] colorPalette = new[]
2525
{
2626
(Color)new Color32(248, 72, 245, 255),
@@ -36,20 +36,20 @@ public class GameManager : MonoBehaviour
3636
(Color)new Color32(247, 26, 37, 255),
3737
(Color)new Color32(253, 121, 43, 255),
3838
};
39-
39+
4040
public static GameManager instance;
4141
public static Camera localCamera;
4242
public static Dictionary<uint, PlayerController> playerIdToPlayerController =
4343
new Dictionary<uint, PlayerController>();
4444

4545
public static Identity localIdentity = default;
4646
public static DbConnection conn;
47-
47+
4848
private void Start()
4949
{
5050
instance = this;
5151
Application.targetFrameRate = 60;
52-
52+
5353
// Now that we’ve registered all our callbacks, lets connect to spacetimedb
5454
conn = DbConnection.Builder().OnConnect((_conn, identity, token) => {
5555
// Called when we connect to SpacetimeDB and receive our client identity
@@ -63,19 +63,19 @@ private void Start()
6363
conn.Db.Food.OnInsert += FoodOnInsert;
6464
conn.Db.Player.OnInsert += PlayerOnInsert;
6565
conn.Db.Player.OnDelete += PlayerOnDelete;
66-
66+
6767
// Request all tables
6868
conn.SubscriptionBuilder().OnApplied(ctx =>
6969
{
7070
Debug.Log("Subscription applied!");
7171
OnSubscriptionApplied?.Invoke();
7272
}).Subscribe("SELECT * FROM *");
73-
73+
7474
OnConnect?.Invoke();
75-
}).OnConnectError(ex =>
75+
}).OnConnectError((ex) =>
7676
{
7777
// Called when we have an error connecting to SpacetimeDB
78-
Debug.LogException(ex);
78+
Debug.LogError($"Connection error: {ex}");
7979
}).OnDisconnect((_conn, ex) =>
8080
{
8181
// Called when we are disconnected from SpacetimeDB
@@ -88,19 +88,19 @@ private void Start()
8888
.WithModuleName("untitled-circle-game")
8989
// .WithCredentials((localIdentity.Value, PlayerPrefs.GetString(AuthToken.GetTokenKey())))
9090
.Build();
91-
91+
9292
#pragma warning disable CS0612 // Type or member is obsolete
9393
conn.onUnhandledReducerError += InstanceOnUnhandledReducerError;
9494
#pragma warning restore CS0612 // Type or member is obsolete
95-
95+
9696
localCamera = Camera.main;
9797
}
9898

9999
private void InstanceOnUnhandledReducerError(ReducerEvent<Reducer> reducerEvent)
100100
{
101101
Debug.LogError("There was an error!");
102102
}
103-
103+
104104
private void PlayerOnDelete(EventContext context, Player deletedvalue)
105105
{
106106
if (playerIdToPlayerController.TryGetValue(deletedvalue.PlayerId, out var playerController))
@@ -115,7 +115,7 @@ private void PlayerOnInsert(EventContext context, Player insertedPlayer)
115115
{
116116
// We have a player, but no circle, let's respawn
117117
Respawn();
118-
}
118+
}
119119
}
120120

121121
private void EntityOnUpdate(EventContext context, Entity oldEntity, Entity newEntity)
@@ -125,7 +125,7 @@ private void EntityOnUpdate(EventContext context, Entity oldEntity, Entity newEn
125125
{
126126
return;
127127
}
128-
128+
129129
var player = GetOrCreatePlayer(circle.PlayerId);
130130
player.CircleUpdate(oldEntity, newEntity);
131131
}
@@ -135,11 +135,11 @@ private void CircleOnDelete(EventContext context, Circle deletedCircle)
135135
var player = GetOrCreatePlayer(deletedCircle.PlayerId);
136136
player.DespawnCircle(deletedCircle);
137137
}
138-
138+
139139
private void CircleOnInsert(EventContext context, Circle insertedValue)
140140
{
141141
var player = GetOrCreatePlayer(insertedValue.PlayerId);
142-
// Spawn the new circle
142+
// Spawn the new circle
143143
player.SpawnCircle(insertedValue, circlePrefab);
144144
}
145145

@@ -157,7 +157,7 @@ PlayerController GetOrCreatePlayer(uint playerId)
157157

158158
return playerController;
159159
}
160-
160+
161161
private void FoodOnInsert(EventContext context, Food insertedValue)
162162
{
163163
// Spawn the new food

0 commit comments

Comments
 (0)