Skip to content

Commit dae6726

Browse files
committed
[bfops/bump-versions]: Merge remote-tracking branch 'origin/master' into bfops/bump-versions
2 parents 150c8d2 + d62295d commit dae6726

87 files changed

Lines changed: 6453 additions & 391 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.

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,7 @@ jobs:
741741

742742
- name: Run .NET tests
743743
working-directory: sdks/csharp
744-
run: dotnet test -warnaserror --no-restore
744+
run: dotnet test -warnaserror --no-restore SpacetimeDB.ClientSDK.csproj
745745

746746
- name: Verify C# formatting
747747
working-directory: sdks/csharp

crates/smoketests/tests/smoketests/quickstart.rs

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -133,14 +133,32 @@ fn create_nuget_config(sources: &[(String, PathBuf)], mappings: &[(String, Strin
133133

134134
/// Override nuget config to use a local NuGet package on a .NET project.
135135
fn override_nuget_package(project_dir: &Path, package: &str, source_dir: &Path, build_subdir: &str) -> Result<()> {
136+
override_nuget_package_from_project(project_dir, package, source_dir, None, build_subdir)
137+
}
138+
139+
/// Override nuget config to use a local NuGet package built from a specific .NET project.
140+
fn override_nuget_package_from_project(
141+
project_dir: &Path,
142+
package: &str,
143+
source_dir: &Path,
144+
source_project: Option<&str>,
145+
build_subdir: &str,
146+
) -> Result<()> {
136147
println!("Override {package}: {project_dir:?} with {source_dir:?}");
137148

138149
// Make sure the local package is built
139150
let workspace = workspace_root();
140151
let repo_nuget_config = workspace.join("NuGet.Config");
152+
let source_project_path = source_project.map(|project| source_dir.join(project));
141153
if repo_nuget_config.exists() {
142-
let output = Command::new("dotnet")
143-
.args(["restore", "--configfile", repo_nuget_config.to_str().unwrap()])
154+
let mut command = Command::new("dotnet");
155+
command.arg("restore");
156+
if let Some(source_project_path) = &source_project_path {
157+
command.arg(source_project_path);
158+
}
159+
let output = command
160+
.arg("--configfile")
161+
.arg(&repo_nuget_config)
144162
.current_dir(source_dir)
145163
.output()
146164
.context("Failed to run dotnet restore")?;
@@ -152,8 +170,13 @@ fn override_nuget_package(project_dir: &Path, package: &str, source_dir: &Path,
152170
);
153171
}
154172

155-
let output = Command::new("dotnet")
156-
.args(["pack", "-c", "Release", "--no-restore"])
173+
let mut command = Command::new("dotnet");
174+
command.arg("pack");
175+
if let Some(source_project_path) = &source_project_path {
176+
command.arg(source_project_path);
177+
}
178+
let output = command
179+
.args(["-c", "Release", "--no-restore"])
157180
.current_dir(source_dir)
158181
.output()
159182
.context("Failed to run dotnet pack")?;
@@ -165,8 +188,13 @@ fn override_nuget_package(project_dir: &Path, package: &str, source_dir: &Path,
165188
);
166189
}
167190
} else {
168-
let output = Command::new("dotnet")
169-
.args(["pack", "-c", "Release"])
191+
let mut command = Command::new("dotnet");
192+
command.arg("pack");
193+
if let Some(source_project_path) = &source_project_path {
194+
command.arg(source_project_path);
195+
}
196+
let output = command
197+
.args(["-c", "Release"])
170198
.current_dir(source_dir)
171199
.output()
172200
.context("Failed to run dotnet pack")?;
@@ -637,10 +665,11 @@ log = "0.4"
637665
&workspace.join("crates/bindings-csharp/BSATN.Runtime"),
638666
"bin/Release",
639667
)?;
640-
override_nuget_package(
668+
override_nuget_package_from_project(
641669
client_path,
642670
"SpacetimeDB.ClientSDK",
643671
&workspace.join("sdks/csharp"),
672+
Some("SpacetimeDB.ClientSDK.csproj"),
644673
"bin~/Release",
645674
)?;
646675

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Normalize EOL for all files that Git considers text files.
2+
* text=auto eol=lf
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Godot 4+ specific ignores
2+
.godot/
3+
/android/
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
using Godot;
2+
3+
public partial class CameraController : Camera2D
4+
{
5+
[Export]
6+
public float BaseVisibleRadius { get; set; } = 50.0f;
7+
8+
[Export]
9+
public float FollowLerpSpeed { get; set; } = 8.0f;
10+
11+
[Export]
12+
public float ZoomLerpSpeed { get; set; } = 2.0f;
13+
14+
private float WorldSize { get; }
15+
16+
public CameraController(float worldSize)
17+
{
18+
WorldSize = worldSize;
19+
}
20+
21+
public override void _Process(double delta)
22+
{
23+
Vector2 targetPosition;
24+
if (GameManager.IsConnected() && PlayerController.Local != null && PlayerController.Local.TryGetCenterOfMass(out var centerOfMass))
25+
{
26+
targetPosition = centerOfMass;
27+
}
28+
else
29+
{
30+
var hWorldSize = WorldSize * 0.5f;
31+
targetPosition = new Vector2(hWorldSize, hWorldSize);
32+
}
33+
34+
GlobalPosition = GlobalPosition.Lerp(targetPosition, (float)delta * FollowLerpSpeed);
35+
36+
if (PlayerController.Local == null)
37+
{
38+
return;
39+
}
40+
41+
var targetCameraSize = CalculateCameraSize(PlayerController.Local);
42+
var desiredZoom = Vector2.One * (BaseVisibleRadius / Mathf.Max(targetCameraSize, 1.0f));
43+
Zoom = Zoom.Lerp(desiredZoom, (float)delta * ZoomLerpSpeed);
44+
}
45+
46+
private static float CalculateCameraSize(PlayerController player) => 10.0f
47+
+ Mathf.Min(10.0f, player.TotalMass() / 5.0f)
48+
+ Mathf.Min(player.NumberOfOwnedCircles - 1, 1) * 30.0f;
49+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
uid://c5uuweuf2vu0e
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
using Godot;
2+
3+
public partial class Circle2D : Node2D
4+
{
5+
private float _radius = 10.0f;
6+
[Export]
7+
public float Radius
8+
{
9+
get => _radius;
10+
set
11+
{
12+
if (Mathf.IsEqualApprox(_radius, value)) return;
13+
14+
_radius = value;
15+
QueueRedraw();
16+
}
17+
}
18+
19+
private Color _color = Colors.Brown;
20+
[Export]
21+
public Color Color
22+
{
23+
get => _color;
24+
set
25+
{
26+
if (_color == value) return;
27+
28+
_color = value;
29+
QueueRedraw();
30+
}
31+
}
32+
33+
public override void _Draw() => DrawCircle(Vector2.Zero, Radius, Color);
34+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
uid://7lmrsq2i7mi1
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
using Godot;
2+
using SpacetimeDB.Types;
3+
4+
public partial class CircleController : EntityController
5+
{
6+
private static readonly Color[] ColorPalette =
7+
[
8+
//Yellow
9+
new(175 / 255.0f, 159 / 255.0f, 49 / 255.0f),
10+
new(175 / 255.0f, 116 / 255.0f, 49 / 255.0f),
11+
//Purple
12+
new(112 / 255.0f, 47 / 255.0f, 252 / 255.0f),
13+
new(51 / 255.0f, 91 / 255.0f, 252 / 255.0f),
14+
//Red
15+
new(176 / 255.0f, 54 / 255.0f, 54 / 255.0f),
16+
new(176 / 255.0f, 109 / 255.0f, 54 / 255.0f),
17+
new(141 / 255.0f, 43 / 255.0f, 99 / 255.0f),
18+
//Blue
19+
new(2 / 255.0f, 188 / 255.0f, 250 / 255.0f),
20+
new(7 / 255.0f, 50 / 255.0f, 251 / 255.0f),
21+
new(2 / 255.0f, 28 / 255.0f, 146 / 255.0f)
22+
];
23+
24+
private static CanvasLayer _labelLayer;
25+
private static CanvasLayer LabelLayer
26+
{
27+
get
28+
{
29+
if (_labelLayer == null)
30+
{
31+
32+
if (Engine.GetMainLoop() is not SceneTree sceneTree) return null;
33+
var root = sceneTree.Root;
34+
if (root == null) return null;
35+
_labelLayer = new CanvasLayer { Name = "CircleLabelLayer" };
36+
root.AddChild(_labelLayer);
37+
}
38+
return _labelLayer;
39+
}
40+
}
41+
private static Control _labelRoot;
42+
private static Control LabelRoot
43+
{
44+
get
45+
{
46+
if (_labelRoot == null)
47+
{
48+
_labelRoot = new Control
49+
{
50+
Name = "CircleLabelRoot",
51+
MouseFilter = Control.MouseFilterEnum.Ignore
52+
};
53+
_labelRoot.SetAnchorsPreset(Control.LayoutPreset.FullRect);
54+
55+
LabelLayer.AddChild(_labelRoot);
56+
}
57+
return _labelRoot;
58+
}
59+
}
60+
61+
private Label _label;
62+
private Label Label
63+
{
64+
get
65+
{
66+
if (_label == null)
67+
{
68+
_label = new Label
69+
{
70+
Name = $"{Name}_Label",
71+
TopLevel = false,
72+
MouseFilter = Control.MouseFilterEnum.Ignore
73+
};
74+
LabelRoot.AddChild(_label);
75+
}
76+
return _label;
77+
}
78+
}
79+
80+
private PlayerController OwnerPlayer { get; set; }
81+
82+
public CircleController(Circle circle, PlayerController ownerPlayer) : base(circle.EntityId, ColorPalette[circle.PlayerId % ColorPalette.Length])
83+
{
84+
OwnerPlayer = ownerPlayer;
85+
Label.Text = ownerPlayer.Username;
86+
87+
ownerPlayer.OnCircleSpawned(this);
88+
}
89+
90+
public override void _Process(double delta)
91+
{
92+
base._Process(delta);
93+
UpdateScreenLabelPosition();
94+
}
95+
96+
public override void OnDelete()
97+
{
98+
base.OnDelete();
99+
100+
if (IsInstanceValid(Label))
101+
{
102+
Label.QueueFree();
103+
}
104+
105+
OwnerPlayer?.OnCircleDeleted(this);
106+
}
107+
108+
private void UpdateScreenLabelPosition()
109+
{
110+
Label.Size = Label.GetCombinedMinimumSize();
111+
var screenPosition = GetGlobalTransformWithCanvas().Origin;
112+
var offset = new Vector2(0.0f, Radius + 8.0f);
113+
Label.Position = screenPosition + offset - (Label.Size / 2.0f);
114+
}
115+
}

0 commit comments

Comments
 (0)