Files
godot-host-test/Game/Level/LevelServiceSource.cs
T
2026-07-25 22:26:07 +02:00

34 lines
1.2 KiB
C#

using System;
using System.Diagnostics;
using Godot;
using GodotHostTest.AetherBind;
using GodotHostTest.Game.Target;
using GodotHostTest.Interfaces;
using OwofGames.AetherBind;
using OwofGames.GodotLume;
using ServiceSource = GodotHostTest.AetherBind.ServiceSource;
namespace GodotHostTest.Game.Level;
public partial class LevelServiceSource : ServiceSource
{
[Export] private TargetSpawner _targetSpawner = null!;
protected override void OnScopeCreated(IProvider serviceProvider)
{
OnScopeCreatedWithProvider(serviceProvider);
}
[WithProvider]
private void OnScopeCreated(IValueSetter<ITargetCollector> targetCollector,
IValueSetter<ITargetSpawner> targetSpawner, ActivitySource activitySource, IValueSetter<Activity> 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);
targetCollector.Set(_targetSpawner);
targetSpawner.Set(_targetSpawner);
}
}