Skip to content

Commit 49550c7

Browse files
committed
[bfops/run-dotnet-format]: revert
1 parent 9c594af commit 49550c7

23 files changed

Lines changed: 4982 additions & 863 deletions

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
using System.Collections.Generic;
33
using UnityEngine;
44

5-
#if !NET5_0_OR_GREATER
5+
#if !NET5_0_OR_GREATER
66
namespace System.Runtime.CompilerServices
7-
{
8-
internal static class IsExternalInit { } // https://stackoverflow.com/a/64749403/1484415
7+
{
8+
internal static class IsExternalInit { } // https://stackoverflow.com/a/64749403/1484415
99
}
1010
#endif

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

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ public class CameraController : MonoBehaviour
77
{
88
public static float WorldSize = 0.0f;
99

10-
private void LateUpdate()
10+
private void LateUpdate()
1111
{
1212
var arenaCenterTransform = new Vector3(WorldSize / 2, WorldSize / 2, -10.0f);
1313
if (PlayerController.Local == null || !GameManager.IsConnected() || PlayerController.Local.NumberOfOwnedCircles == 0)
@@ -29,20 +29,18 @@ private void LateUpdate()
2929
y = centerOfMass.Value.y,
3030
z = transform.position.z
3131
};
32-
}
33-
else
34-
{
32+
} else {
3533
transform.position = arenaCenterTransform;
3634
}
3735

38-
float targetCameraSize = CalculateCameraSize(PlayerController.Local);
39-
Camera.main.orthographicSize = Mathf.Lerp(Camera.main.orthographicSize, targetCameraSize, Time.deltaTime * 2);
40-
}
36+
float targetCameraSize = CalculateCameraSize(PlayerController.Local);
37+
Camera.main.orthographicSize = Mathf.Lerp(Camera.main.orthographicSize, targetCameraSize, Time.deltaTime * 2);
38+
}
4139

42-
private float CalculateCameraSize(PlayerController player)
43-
{
44-
return 50f + //Base size
40+
private float CalculateCameraSize(PlayerController player)
41+
{
42+
return 50f + //Base size
4543
Mathf.Min(50, player.TotalMass() / 5) + //Increase camera size with mass
4644
Mathf.Min(player.NumberOfOwnedCircles - 1, 1) * 30; //Zoom out when player splits
47-
}
45+
}
4846
}

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

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,41 +6,41 @@
66

77
public class CircleController : EntityController
88
{
9-
public static Color[] ColorPalette = new[]
10-
{
9+
public static Color[] ColorPalette = new[]
10+
{
1111
//Yellow
1212
(Color)new Color32(175, 159, 49, 255),
13-
(Color)new Color32(175, 116, 49, 255),
13+
(Color)new Color32(175, 116, 49, 255),
1414

1515
//Purple
1616
(Color)new Color32(112, 47, 252, 255),
17-
(Color)new Color32(51, 91, 252, 255),
17+
(Color)new Color32(51, 91, 252, 255),
1818

1919
//Red
2020
(Color)new Color32(176, 54, 54, 255),
21-
(Color)new Color32(176, 109, 54, 255),
22-
(Color)new Color32(141, 43, 99, 255),
21+
(Color)new Color32(176, 109, 54, 255),
22+
(Color)new Color32(141, 43, 99, 255),
2323

2424
//Blue
2525
(Color)new Color32(2, 188, 250, 255),
26-
(Color)new Color32(7, 50, 251, 255),
27-
(Color)new Color32(2, 28, 146, 255),
28-
};
26+
(Color)new Color32(7, 50, 251, 255),
27+
(Color)new Color32(2, 28, 146, 255),
28+
};
2929

3030
private PlayerController Owner;
3131

3232
public void Spawn(Circle circle, PlayerController owner)
3333
{
3434
base.Spawn(circle.EntityId);
35-
SetColor(ColorPalette[circle.PlayerId % ColorPalette.Length]);
35+
SetColor(ColorPalette[circle.PlayerId % ColorPalette.Length]);
3636

3737
this.Owner = owner;
3838
GetComponentInChildren<TMPro.TextMeshProUGUI>().text = owner.Username;
3939
}
4040

41-
public override void OnDelete(EventContext context)
42-
{
43-
base.OnDelete(context);
41+
public override void OnDelete(EventContext context)
42+
{
43+
base.OnDelete(context);
4444
Owner.OnCircleDeleted(this);
45-
}
45+
}
4646
}

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@
55

66
public class DeathScreen : MonoBehaviour
77
{
8-
public Button RespawnButton;
8+
public Button RespawnButton;
99

10-
public void SetVisible(bool visible)
11-
{
12-
gameObject.SetActive(visible);
13-
}
10+
public void SetVisible(bool visible)
11+
{
12+
gameObject.SetActive(visible);
13+
}
1414

15-
public void Respawn()
16-
{
17-
GameManager.Conn.Reducers.Respawn();
18-
SetVisible(false);
19-
}
15+
public void Respawn()
16+
{
17+
GameManager.Conn.Reducers.Respawn();
18+
SetVisible(false);
19+
}
2020
}

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

Lines changed: 69 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -8,86 +8,86 @@
88

99
public abstract class EntityController : MonoBehaviour
1010
{
11-
const float LERP_DURATION_SEC = 0.1f;
11+
const float LERP_DURATION_SEC = 0.1f;
1212

13-
private static readonly int ShaderColorProperty = Shader.PropertyToID("_Color");
13+
private static readonly int ShaderColorProperty = Shader.PropertyToID("_Color");
1414

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

17-
protected float LerpTime;
18-
protected Vector3 LerpStartPosition;
19-
protected Vector3 LerpTargetPosition;
20-
protected Vector3 TargetScale;
17+
protected float LerpTime;
18+
protected Vector3 LerpStartPosition;
19+
protected Vector3 LerpTargetPosition;
20+
protected Vector3 TargetScale;
2121

22-
protected virtual void Spawn(int entityId)
23-
{
24-
EntityId = entityId;
22+
protected virtual void Spawn(int entityId)
23+
{
24+
EntityId = entityId;
2525

26-
var entity = GameManager.Conn.Db.Entity.EntityId.Find(entityId);
27-
LerpStartPosition = LerpTargetPosition = transform.position = (Vector2)entity.Position;
28-
transform.localScale = Vector3.one;
29-
TargetScale = MassToScale(entity.Mass);
30-
}
26+
var entity = GameManager.Conn.Db.Entity.EntityId.Find(entityId);
27+
LerpStartPosition = LerpTargetPosition = transform.position = (Vector2)entity.Position;
28+
transform.localScale = Vector3.one;
29+
TargetScale = MassToScale(entity.Mass);
30+
}
3131

32-
public void SetColor(Color color)
33-
{
34-
GetComponent<SpriteRenderer>().material.SetColor(ShaderColorProperty, color);
35-
}
32+
public void SetColor(Color color)
33+
{
34+
GetComponent<SpriteRenderer>().material.SetColor(ShaderColorProperty, color);
35+
}
3636

37-
public virtual void OnEntityUpdated(Entity newVal)
38-
{
39-
LerpTime = 0.0f;
40-
LerpStartPosition = transform.position;
41-
LerpTargetPosition = (Vector2)newVal.Position;
42-
TargetScale = MassToScale(newVal.Mass);
43-
}
37+
public virtual void OnEntityUpdated(Entity newVal)
38+
{
39+
LerpTime = 0.0f;
40+
LerpStartPosition = transform.position;
41+
LerpTargetPosition = (Vector2)newVal.Position;
42+
TargetScale = MassToScale(newVal.Mass);
43+
}
4444

45-
public virtual void OnDelete(EventContext context)
46-
{
47-
if (context.Event is SpacetimeDB.Event<Reducer>.Reducer reducer &&
48-
reducer.ReducerEvent.Reducer is Reducer.ConsumeEntity consume)
49-
{
50-
var consumerId = consume.Request.ConsumerEntityId;
51-
if (GameManager.Entities.TryGetValue(consumerId, out var consumerEntity))
52-
{
53-
StartCoroutine(DespawnCoroutine(consumerEntity.transform));
54-
return;
55-
}
56-
}
45+
public virtual void OnDelete(EventContext context)
46+
{
47+
if (context.Event is SpacetimeDB.Event<Reducer>.Reducer reducer &&
48+
reducer.ReducerEvent.Reducer is Reducer.ConsumeEntity consume)
49+
{
50+
var consumerId = consume.Request.ConsumerEntityId;
51+
if (GameManager.Entities.TryGetValue(consumerId, out var consumerEntity))
52+
{
53+
StartCoroutine(DespawnCoroutine(consumerEntity.transform));
54+
return;
55+
}
56+
}
5757

58-
Destroy(gameObject);
59-
}
58+
Destroy(gameObject);
59+
}
6060

61-
public IEnumerator DespawnCoroutine(Transform targetTransform)
62-
{
63-
const float DESPAWN_TIME = 0.2f;
64-
var startPosition = transform.position;
65-
var startScale = transform.localScale;
66-
GetComponent<SpriteRenderer>().sortingOrder++; //Render consumed food above the circle that's consuming it
67-
for (float time = Time.deltaTime; time < DESPAWN_TIME; time += Time.deltaTime)
68-
{
69-
float t = time / DESPAWN_TIME;
70-
transform.position = Vector3.Lerp(startPosition, targetTransform.position, t);
71-
transform.localScale = Vector3.Lerp(startScale, Vector3.zero, t);
72-
yield return null;
73-
}
74-
Destroy(gameObject);
75-
}
61+
public IEnumerator DespawnCoroutine(Transform targetTransform)
62+
{
63+
const float DESPAWN_TIME = 0.2f;
64+
var startPosition = transform.position;
65+
var startScale = transform.localScale;
66+
GetComponent<SpriteRenderer>().sortingOrder++; //Render consumed food above the circle that's consuming it
67+
for (float time = Time.deltaTime; time < DESPAWN_TIME; time += Time.deltaTime)
68+
{
69+
float t = time / DESPAWN_TIME;
70+
transform.position = Vector3.Lerp(startPosition, targetTransform.position, t);
71+
transform.localScale = Vector3.Lerp(startScale, Vector3.zero, t);
72+
yield return null;
73+
}
74+
Destroy(gameObject);
75+
}
7676

77-
public virtual void Update()
78-
{
79-
//Interpolate position and scale
80-
LerpTime = Mathf.Min(LerpTime + Time.deltaTime, LERP_DURATION_SEC);
81-
transform.position = Vector3.Lerp(LerpStartPosition, LerpTargetPosition, LerpTime / LERP_DURATION_SEC);
82-
transform.localScale = Vector3.Lerp(transform.localScale, TargetScale, Time.deltaTime * 8);
83-
}
77+
public virtual void Update()
78+
{
79+
//Interpolate position and scale
80+
LerpTime = Mathf.Min(LerpTime + Time.deltaTime, LERP_DURATION_SEC);
81+
transform.position = Vector3.Lerp(LerpStartPosition, LerpTargetPosition, LerpTime / LERP_DURATION_SEC);
82+
transform.localScale = Vector3.Lerp(transform.localScale, TargetScale, Time.deltaTime * 8);
83+
}
8484

85-
public static Vector3 MassToScale(int mass)
86-
{
87-
var diameter = MassToDiameter(mass);
88-
return new Vector3(diameter, diameter, 1);
89-
}
85+
public static Vector3 MassToScale(int mass)
86+
{
87+
var diameter = MassToDiameter(mass);
88+
return new Vector3(diameter, diameter, 1);
89+
}
9090

91-
public static float MassToRadius(int mass) => Mathf.Sqrt(mass);
92-
public static float MassToDiameter(int 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/Extensions.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@
33

44
namespace SpacetimeDB.Types
55
{
6-
public partial class DbVector2
7-
{
8-
public static implicit operator Vector2(DbVector2 vec)
9-
{
10-
return new Vector2(vec.X, vec.Y);
11-
}
6+
public partial class DbVector2
7+
{
8+
public static implicit operator Vector2(DbVector2 vec)
9+
{
10+
return new Vector2(vec.X, vec.Y);
11+
}
1212

13-
public static implicit operator DbVector2(Vector2 vec)
14-
{
15-
return new DbVector2(vec.x, vec.y);
16-
}
17-
}
13+
public static implicit operator DbVector2(Vector2 vec)
14+
{
15+
return new DbVector2(vec.x, vec.y);
16+
}
17+
}
1818
}

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,20 @@
44

55
public class FoodController : EntityController
66
{
7-
public static Color[] ColorPalette = new[]
8-
{
9-
(Color)new Color32(119, 252, 173, 255),
10-
(Color)new Color32(76, 250, 146, 255),
11-
(Color)new Color32(35, 246, 120, 255),
7+
public static Color[] ColorPalette = new[]
8+
{
9+
(Color)new Color32(119, 252, 173, 255),
10+
(Color)new Color32(76, 250, 146, 255),
11+
(Color)new Color32(35, 246, 120, 255),
1212

13-
(Color)new Color32(119, 251, 201, 255),
14-
(Color)new Color32(76, 249, 184, 255),
15-
(Color)new Color32(35, 245, 165, 255),
16-
};
13+
(Color)new Color32(119, 251, 201, 255),
14+
(Color)new Color32(76, 249, 184, 255),
15+
(Color)new Color32(35, 245, 165, 255),
16+
};
1717

1818
public void Spawn(Food food)
1919
{
2020
base.Spawn(food.EntityId);
21-
SetColor(ColorPalette[EntityId % ColorPalette.Length]);
21+
SetColor(ColorPalette[EntityId % ColorPalette.Length]);
2222
}
2323
}

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ private void Start()
2020
Rows[i] = go;
2121
}
2222
}
23-
23+
2424
private void Update()
2525
{
2626
var players = GameManager.Players.Values
@@ -30,22 +30,22 @@ private void Update()
3030
.Take(10)
3131
.ToList();
3232
var localPlayer = PlayerController.Local;
33-
if (localPlayer != null && !players.Any(p => p.player == localPlayer) && localPlayer.NumberOfOwnedCircles > 0)
33+
if (localPlayer != null && !players.Any(p => p.player == localPlayer) && localPlayer.NumberOfOwnedCircles > 0)
3434
{
3535
players.Add((localPlayer, localPlayer.TotalMass()));
36-
}
36+
}
3737

3838
int i;
3939
for (i = 0; i < players.Count; i++)
40-
{
40+
{
4141
var player = players[i];
42-
var row = Rows[i];
42+
var row = Rows[i];
4343
row.SetData(player.player.Username, player.mass);
4444
row.gameObject.SetActive(true);
45-
}
45+
}
4646
for (; i < MAX_ROW_COUNT; i++)
47-
{
48-
Rows[i].gameObject.SetActive(false);
49-
}
47+
{
48+
Rows[i].gameObject.SetActive(false);
49+
}
5050
}
5151
}

0 commit comments

Comments
 (0)