diff --git a/Game/Level/LevelServiceSource.cs b/Game/Level/LevelServiceSource.cs index d129417..153be07 100644 --- a/Game/Level/LevelServiceSource.cs +++ b/Game/Level/LevelServiceSource.cs @@ -5,6 +5,7 @@ using GodotHostTest.AetherBind; using GodotHostTest.Game.Target; using GodotHostTest.Interfaces; using OwofGames.AetherBind; +using OwofGames.GodotHost.Observability; using OwofGames.GodotLume; using ServiceSource = GodotHostTest.AetherBind.ServiceSource; @@ -12,6 +13,7 @@ namespace GodotHostTest.Game.Level; public partial class LevelServiceSource : ServiceSource { + private Activity? _activityValue; [Export] private TargetSpawner _targetSpawner = null!; protected override void OnScopeCreated(IProvider serviceProvider) @@ -21,14 +23,21 @@ public partial class LevelServiceSource : ServiceSource [WithProvider] private void OnScopeCreated(IValueSetter targetCollector, - IValueSetter targetSpawner, ActivitySource activitySource, IValueSetter activity) + IValueSetter targetSpawner, IActivitySourceFactory activitySourceFactory, + IValueSetter activity) { // ReSharper disable once ExplicitCallerInfoArgument - the caller name is not significant in this case - var activityValue = activitySource.StartActivity("Level") ?? - throw new InvalidOperationException( - "No listeners for the activity - is OpenTelemetry running?"); - activity.Set(activityValue); + _activityValue = activitySourceFactory.ActivitySource.StartActivity("Level") ?? + throw new InvalidOperationException( + "No listeners for the activity - is OpenTelemetry running?"); + activity.Set(_activityValue); targetCollector.Set(_targetSpawner); targetSpawner.Set(_targetSpawner); } + + public override void _Ready() + { + // after 3 seconds, dispose the activity for simulation purposes + GetTree().CreateTimer(3).Timeout += _activityValue!.Dispose; + } } \ No newline at end of file diff --git a/Game/Root/GameServiceSource.cs b/Game/Root/GameServiceSource.cs index 0a3e562..2b6fea1 100644 --- a/Game/Root/GameServiceSource.cs +++ b/Game/Root/GameServiceSource.cs @@ -4,7 +4,7 @@ using GodotHostTest.Game.Score; using GodotHostTest.Game.Target; using GodotHostTest.Interfaces; using Microsoft.Extensions.DependencyInjection; -using OwofGames.AetherBind.Observability; +using OwofGames.GodotHost.Observability; using OwofGames.GodotLume; using RootServiceSource = GodotHostTest.AetherBind.RootServiceSource; @@ -24,6 +24,6 @@ public partial class GameServiceSource : RootServiceSource protected override void ConfigureServices(IServiceCollection serviceCollection) { - serviceCollection.AddObservability(); + serviceCollection.AddObservability(builder => builder.AddGrpcExporter("http://localhost:4317")); } } \ No newline at end of file diff --git a/Game/Turret/Turret.cs b/Game/Turret/Turret.cs index e8595d1..7beb5a2 100644 --- a/Game/Turret/Turret.cs +++ b/Game/Turret/Turret.cs @@ -8,13 +8,14 @@ namespace GodotHostTest.Game.Turret; public partial class Turret : Sprite2D { [Export] private Node2D _launcher = null!; + [Inject] private ILogger _logger = null!; [Export] private PackedScene _projectilePackedScene = null!; private double _rotationDirection; [Export] private double _rotationSpeed = 6; - [Inject] private ISceneInstantiator _sceneInstantiator = null!; + [Export] private double _slowDownFactor = 0.3; private void OnTimerTimeout() { @@ -24,20 +25,12 @@ public partial class Turret : Sprite2D _logger.LogInformation("Projectile launched."); } - public override void _Input(InputEvent @event) - { - _rotationDirection = 0; - if (@event.IsActionPressed("rotate_clockwise")) _rotationDirection = 1; - - if (@event.IsActionPressed("rotate_counterclockwise")) _rotationDirection = -1; - } - public override void _PhysicsProcess(double delta) { _rotationDirection = 0; if (Input.IsActionPressed("rotate_clockwise")) _rotationDirection = 1; - if (Input.IsActionPressed("rotate_counterclockwise")) _rotationDirection = -1; + if (Input.IsActionPressed("slow_down")) _rotationDirection *= _slowDownFactor; _launcher.Rotation += (float)(_rotationSpeed * delta * _rotationDirection); base._PhysicsProcess(delta); diff --git a/Game/Turret/turret.tscn b/Game/Turret/turret.tscn index 11abb0e..f5d584f 100644 --- a/Game/Turret/turret.tscn +++ b/Game/Turret/turret.tscn @@ -12,8 +12,10 @@ point_count = 2 [node name="Turret" type="Sprite2D" unique_id=682995021 node_paths=PackedStringArray("_launcher")] texture = ExtResource("1_fa2t6") script = ExtResource("2_tkk1n") -_projectilePackedScene = ExtResource("3_eoix6") _launcher = NodePath("Launcher") +_projectilePackedScene = ExtResource("3_eoix6") +_rotationSpeed = 4.0 +_slowDownFactor = 0.5 [node name="Launcher" type="Sprite2D" parent="." unique_id=1492355681] texture = ExtResource("4_q6l7p") diff --git a/appsettings.json b/appsettings.json index fbbf415..80c6d89 100644 --- a/appsettings.json +++ b/appsettings.json @@ -1,5 +1,10 @@ { "Logging": { + "Godot": { + "LogLevel": { + "OwofGames.GodotHost.Observability": "Trace" + } + }, "OpenTelemetry": { "LogLevel": { "Default": "Trace" diff --git a/godot-host-test.csproj b/godot-host-test.csproj index 1886943..e9bb39b 100644 --- a/godot-host-test.csproj +++ b/godot-host-test.csproj @@ -13,12 +13,12 @@ - - ..\OwofGames.Godot\OwofGames.AetherBind.Observability\bin\Debug\net8.0\OwofGames.AetherBind.Observability.dll - ..\OwofGames.Godot\OwofGames.GodotHost\bin\Debug\net8.0\OwofGames.GodotHost.dll + + ..\OwofGames.Godot\OwofGames.GodotHost.Observability\bin\Debug\net8.0\OwofGames.GodotHost.Observability.dll + ..\OwofGames.Godot\OwofGames.GodotHost\bin\Debug\net8.0\OwofGames.GodotLogger.dll diff --git a/godot-host-test.sln.DotSettings.user b/godot-host-test.sln.DotSettings.user index 41ccc10..b5cc359 100644 --- a/godot-host-test.sln.DotSettings.user +++ b/godot-host-test.sln.DotSettings.user @@ -2,6 +2,7 @@ True True True + True True True True @@ -11,6 +12,7 @@ ForceIncluded ForceIncluded ForceIncluded + ForceIncluded ForceIncluded ForceIncluded ForceIncluded @@ -26,6 +28,7 @@ ForceIncluded ForceIncluded ForceIncluded + ForceIncluded <AssemblyExplorer> <Assembly Path="/home/redglow/sources/OwofGames.Godot/OwofGames.AetherBind.Observability/bin/Debug/net8.0/OwofGames.AetherBind.Observability.dll" /> </AssemblyExplorer> diff --git a/project.godot b/project.godot index 966d0cd..f5df16b 100644 --- a/project.godot +++ b/project.godot @@ -40,6 +40,11 @@ rotate_counterclockwise={ "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194319,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) ] } +slow_down={ +"deadzone": 0.2, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194325,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +] +} [layer_names]