feat: initial import
This commit is contained in:
@@ -0,0 +1,4 @@
|
|||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
charset = utf-8
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
# Normalize EOL for all files that Git considers text files.
|
||||||
|
* text=auto eol=lf
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
# Godot 4+ specific ignores
|
||||||
|
.godot/
|
||||||
|
/android/
|
||||||
+13
@@ -0,0 +1,13 @@
|
|||||||
|
# Default ignored files
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
||||||
|
# Rider ignored files
|
||||||
|
/modules.xml
|
||||||
|
/.idea.godot-host-test.iml
|
||||||
|
/projectSettingsUpdater.xml
|
||||||
|
/contentModel.xml
|
||||||
|
# Ignored default folder with query files
|
||||||
|
/queries/
|
||||||
|
# Datasource local storage ignored files
|
||||||
|
/dataSources/
|
||||||
|
/dataSources.local.xml
|
||||||
+4
@@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="Encoding" addBOMForNewFiles="with BOM under Windows, with no BOM otherwise" />
|
||||||
|
</project>
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="UserContentModel">
|
||||||
|
<attachedFolders />
|
||||||
|
<explicitIncludes />
|
||||||
|
<explicitExcludes />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
<component name="libraryTable">
|
||||||
|
<library name="GdSdk" type="GdScript">
|
||||||
|
<CLASSES />
|
||||||
|
<JAVADOC />
|
||||||
|
<SOURCES>
|
||||||
|
<root url="file://$APPLICATION_PLUGINS_DIR$/GdScript/extracted/Master" />
|
||||||
|
</SOURCES>
|
||||||
|
</library>
|
||||||
|
</component>
|
||||||
+12
@@ -0,0 +1,12 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="CommitMessageInspectionProfile">
|
||||||
|
<profile version="1.0">
|
||||||
|
<inspection_tool class="CommitFormat" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||||
|
<inspection_tool class="CommitNamingConvention" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||||
|
</profile>
|
||||||
|
</component>
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
using Godot;
|
||||||
|
using GodotHostTest.GodotDI;
|
||||||
|
using GodotHostTest.Interfaces;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
|
||||||
|
namespace GodotHostTest.Game;
|
||||||
|
|
||||||
|
public partial class GameRootScope : RootScope
|
||||||
|
{
|
||||||
|
[Export] private TargetSpawner _targetSpawner = null!;
|
||||||
|
|
||||||
|
protected override void Configure(IServiceCollection serviceCollection)
|
||||||
|
{
|
||||||
|
serviceCollection
|
||||||
|
.AddSingleton<ITargetCollector>(_targetSpawner)
|
||||||
|
.AddSingleton<ITargetSpawner>(_targetSpawner);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
uid://dk578xnlxjwrr
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
using Godot;
|
||||||
|
using GodotHostTest.GodotDI;
|
||||||
|
using GodotHostTest.Helpers;
|
||||||
|
using GodotHostTest.Interfaces;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using R3;
|
||||||
|
|
||||||
|
namespace GodotHostTest.Game;
|
||||||
|
|
||||||
|
public partial class Projectile : Node2D
|
||||||
|
{
|
||||||
|
[Inject] private readonly ILogger<Projectile> _logger = null!;
|
||||||
|
[Inject] private readonly ITargetSpawner _targetSpawner = null!;
|
||||||
|
|
||||||
|
// Called when the node enters the scene tree for the first time.
|
||||||
|
public override void _Ready()
|
||||||
|
{
|
||||||
|
_targetSpawner.TargetSpawned
|
||||||
|
.Subscribe(_ => _logger.LogInformation("Projectile got informed of target spawning")).AddTo(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
uid://dc5mvle8lc40j
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
using R3;
|
||||||
|
using Godot;
|
||||||
|
using GodotHostTest.GodotDI;
|
||||||
|
using GodotHostTest.Helpers;
|
||||||
|
using GodotHostTest.Interfaces;
|
||||||
|
|
||||||
|
namespace GodotHostTest.Game;
|
||||||
|
|
||||||
|
public partial class Score : Control
|
||||||
|
{
|
||||||
|
[Export] private AnimationPlayer _animationPlayer = null!;
|
||||||
|
[Export] private Label _label = null!;
|
||||||
|
[Inject] private readonly ITargetSpawner _targetSpawner = null!;
|
||||||
|
|
||||||
|
private int _score;
|
||||||
|
|
||||||
|
public override void _Ready()
|
||||||
|
{
|
||||||
|
_targetSpawner.TargetSpawned.Subscribe(OnTargetSpawned).AddTo(this);
|
||||||
|
base._Ready();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnTargetSpawned(ITarget target)
|
||||||
|
{
|
||||||
|
_animationPlayer.Play("wiggle");
|
||||||
|
target.Hit.Select(_ => 20).Merge(target.TimedOut.Select(_ => -5)).SubscribeOnce(delta =>
|
||||||
|
{
|
||||||
|
_score += delta;
|
||||||
|
UpdateScore();
|
||||||
|
}).AddTo(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdateScore()
|
||||||
|
{
|
||||||
|
_label.Text = $"Score: {_score}";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
uid://bgrjeadxhgmvi
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
using Godot;
|
||||||
|
using GodotHostTest.GodotDI;
|
||||||
|
using GodotHostTest.Interfaces;
|
||||||
|
using R3;
|
||||||
|
|
||||||
|
namespace GodotHostTest.Game;
|
||||||
|
|
||||||
|
public partial class Target : Node2D, ITarget
|
||||||
|
{
|
||||||
|
[Export] public double TimeOutDurationInSeconds;
|
||||||
|
[Export] public required Timer TimeOutTimer;
|
||||||
|
[Export] public required Sprite2D Image;
|
||||||
|
[Export] public required Area2D CollisionArea;
|
||||||
|
|
||||||
|
private readonly Subject<Unit> _timedOut = new();
|
||||||
|
private readonly Subject<Unit> _hit = new();
|
||||||
|
|
||||||
|
[Inject] private readonly ITargetCollector _targetCollector = null!;
|
||||||
|
|
||||||
|
public override void _Ready()
|
||||||
|
{
|
||||||
|
_targetCollector.NewTarget(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void _ExitTree()
|
||||||
|
{
|
||||||
|
_timedOut.Dispose();
|
||||||
|
_hit.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Observable<Unit> TimedOut => _timedOut.AsObservable();
|
||||||
|
|
||||||
|
public Observable<Unit> Hit => _hit.AsObservable();
|
||||||
|
|
||||||
|
// todo: hook to collision
|
||||||
|
private void OnHit()
|
||||||
|
{
|
||||||
|
Disable();
|
||||||
|
TimeOutTimer.Stop();
|
||||||
|
_hit.OnNext(Unit.Default);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Enable()
|
||||||
|
{
|
||||||
|
Image.Visible = true;
|
||||||
|
CollisionArea.Monitoring = true;
|
||||||
|
TimeOutTimer.Start(TimeOutDurationInSeconds);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Disable()
|
||||||
|
{
|
||||||
|
Image.Visible = false;
|
||||||
|
CollisionArea.Monitoring = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnTimeout()
|
||||||
|
{
|
||||||
|
Disable();
|
||||||
|
_timedOut.OnNext(Unit.Default);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
uid://bv2hat41dyxiv
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using Godot;
|
||||||
|
using GodotHostTest.Helpers;
|
||||||
|
using GodotHostTest.Interfaces;
|
||||||
|
using R3;
|
||||||
|
|
||||||
|
namespace GodotHostTest.Game;
|
||||||
|
|
||||||
|
public partial class TargetSpawner : Node2D, ITargetCollector, ITargetSpawner
|
||||||
|
{
|
||||||
|
[Export] public double TimeBetweenSpawns;
|
||||||
|
|
||||||
|
[Export] public required Timer Timer;
|
||||||
|
|
||||||
|
private readonly List<ITarget> _availableTargets = [];
|
||||||
|
|
||||||
|
public override void _Ready()
|
||||||
|
{
|
||||||
|
Spawn();
|
||||||
|
Timer.Start(TimeBetweenSpawns);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void MakeTargetAvailable(ITarget target)
|
||||||
|
{
|
||||||
|
_availableTargets.Add(target);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnTimer()
|
||||||
|
{
|
||||||
|
Spawn();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Spawn()
|
||||||
|
{
|
||||||
|
// pick a random target
|
||||||
|
var randomIndex = GD.RandRange(0, _availableTargets.Count - 1);
|
||||||
|
var target = _availableTargets[randomIndex];
|
||||||
|
_availableTargets.RemoveAt(randomIndex);
|
||||||
|
|
||||||
|
// enable it
|
||||||
|
target.Enable();
|
||||||
|
|
||||||
|
// notify that a target has been spawned
|
||||||
|
_targetSpawned.OnNext(target);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void NewTarget(ITarget target)
|
||||||
|
{
|
||||||
|
_availableTargets.Add(target);
|
||||||
|
target.Hit.Merge(target.TimedOut).Select(_ => target).Subscribe(MakeTargetAvailable).AddTo(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
base.Dispose(disposing);
|
||||||
|
_targetSpawned.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
private readonly Subject<ITarget> _targetSpawned = new();
|
||||||
|
public Observable<ITarget> TargetSpawned => _targetSpawned.AsObservable();
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
uid://cxfrtglku2gfa
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
using Godot;
|
||||||
|
using GodotHostTest.GodotDI;
|
||||||
|
|
||||||
|
namespace GodotHostTest.Game;
|
||||||
|
|
||||||
|
public partial class Turret : Sprite2D
|
||||||
|
{
|
||||||
|
[Inject] private readonly ISceneInstantiator _sceneInstantiator = null!;
|
||||||
|
[Export] private PackedScene _projectilePackedScene = null!;
|
||||||
|
|
||||||
|
public override void _Ready()
|
||||||
|
{
|
||||||
|
GetTree().CreateTimer(1).Timeout += () => AddChild(_sceneInstantiator.Instantiate(_projectilePackedScene));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
uid://ce7gnp1lcrrdv
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
[gd_scene format=3 uid="uid://brbufibn7hi3o"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" uid="uid://dc5mvle8lc40j" path="res://Game/Projectile.cs" id="1_80yud"]
|
||||||
|
[ext_resource type="Script" uid="uid://qjonl8stia46" path="res://GodotDI/Scope.cs" id="2_3kmdq"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://y1ros3y7hag2" path="res://icon.svg" id="3_1i54g"]
|
||||||
|
|
||||||
|
[node name="Projectile" type="Node2D" unique_id=1686616504]
|
||||||
|
script = ExtResource("1_80yud")
|
||||||
|
|
||||||
|
[node name="Scope" type="Node" parent="." unique_id=513224818 node_paths=PackedStringArray("InjectedNodes")]
|
||||||
|
script = ExtResource("2_3kmdq")
|
||||||
|
InjectedNodes = [NodePath("..")]
|
||||||
|
|
||||||
|
[node name="Sprite2D" type="Sprite2D" parent="." unique_id=1021740171]
|
||||||
|
modulate = Color(1, 1, 0, 1)
|
||||||
|
rotation = 0.7853982
|
||||||
|
scale = Vector2(0.3, 0.3)
|
||||||
|
texture = ExtResource("3_1i54g")
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
[gd_scene format=3 uid="uid://3v8kq1rfwhmr"]
|
||||||
|
|
||||||
|
[ext_resource type="Texture2D" uid="uid://y1ros3y7hag2" path="res://icon.svg" id="1_032qf"]
|
||||||
|
[ext_resource type="Script" uid="uid://bv2hat41dyxiv" path="res://Game/Target.cs" id="1_c0a8e"]
|
||||||
|
|
||||||
|
[sub_resource type="RectangleShape2D" id="RectangleShape2D_u8d0v"]
|
||||||
|
size = Vector2(128, 128)
|
||||||
|
|
||||||
|
[node name="Target" type="Node2D" unique_id=2101558052 node_paths=PackedStringArray("TimeOutTimer", "Image", "CollisionArea")]
|
||||||
|
script = ExtResource("1_c0a8e")
|
||||||
|
TimeOutDurationInSeconds = 7.0
|
||||||
|
TimeOutTimer = NodePath("TimeOutTimer")
|
||||||
|
Image = NodePath("Sprite2D")
|
||||||
|
CollisionArea = NodePath("CollisionArea")
|
||||||
|
|
||||||
|
[node name="Sprite2D" type="Sprite2D" parent="." unique_id=31059524]
|
||||||
|
visible = false
|
||||||
|
modulate = Color(1, 0.20392157, 0.015686275, 1)
|
||||||
|
texture = ExtResource("1_032qf")
|
||||||
|
|
||||||
|
[node name="CollisionArea" type="Area2D" parent="." unique_id=116681968]
|
||||||
|
monitoring = false
|
||||||
|
monitorable = false
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="CollisionArea" unique_id=1558252366]
|
||||||
|
shape = SubResource("RectangleShape2D_u8d0v")
|
||||||
|
|
||||||
|
[node name="TimeOutTimer" type="Timer" parent="." unique_id=1079777109]
|
||||||
|
one_shot = true
|
||||||
|
|
||||||
|
[connection signal="timeout" from="TimeOutTimer" to="." method="OnTimeout"]
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
using Godot;
|
||||||
|
|
||||||
|
namespace GodotHostTest.GodotDI;
|
||||||
|
|
||||||
|
public interface ISceneInstantiator
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Instantiate a packed scene, just like <see cref="PackedScene.Instantiate"/>, but also looks for a scope between the top level children and triggers the dependency injection mechanism when found.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="packedScene">The packed scene to instantiate.</param>
|
||||||
|
/// <returns>The created node, with its dependencies satisfied.</returns>
|
||||||
|
Node Instantiate(PackedScene packedScene);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Instantiate a packed scene, just like <see cref="PackedScene.Instantiate{T}"/>, but also looks for a scope between the top level children and triggers the dependency injection mechanism when found.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="packedScene">The packed scene to instantiate.</param>
|
||||||
|
/// <returns>The created node, with its dependencies satisfied.</returns>
|
||||||
|
T Instantiate<T>(PackedScene packedScene) where T : Node;
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
uid://bv7aut87rpm5u
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace GodotHostTest.GodotDI;
|
||||||
|
|
||||||
|
[AttributeUsage(AttributeTargets.Field)]
|
||||||
|
public class InjectAttribute: Attribute;
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
uid://mshffj1jlgi7
|
||||||
@@ -0,0 +1,77 @@
|
|||||||
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
using Godot;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using OwofGames.GodotHost;
|
||||||
|
|
||||||
|
namespace GodotHostTest.GodotDI;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The base class for a root scope. Implement this class and its abstract methods to kick off the DI system.
|
||||||
|
/// </summary>
|
||||||
|
public abstract partial class RootScope : Scope, ISceneInstantiator
|
||||||
|
{
|
||||||
|
private Host? _host;
|
||||||
|
|
||||||
|
private Host Host
|
||||||
|
{
|
||||||
|
get => _host ??
|
||||||
|
throw new InvalidOperationException(
|
||||||
|
"Some method of RootScope has been invoked before it entered the tree");
|
||||||
|
set => _host = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ILogger<RootScope>? _logger;
|
||||||
|
|
||||||
|
private ILogger<RootScope> Logger => _logger ??= Host.GetLogger<RootScope>();
|
||||||
|
|
||||||
|
public override void _EnterTree()
|
||||||
|
{
|
||||||
|
// create the host
|
||||||
|
Host = new HostBuilder()
|
||||||
|
.SetServiceCollectionBuilder(InnerConfigure)
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
// resolve nodes
|
||||||
|
ResolveInjectedNodes(Host.ServiceProvider);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void InnerConfigure(IServiceCollection serviceCollection)
|
||||||
|
{
|
||||||
|
serviceCollection.AddSingleton<ISceneInstantiator>(this);
|
||||||
|
Configure(serviceCollection);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Configure the service collection by adding the registrations your game needs.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="serviceCollection">The service collection to enrich.</param>
|
||||||
|
protected abstract void Configure(IServiceCollection serviceCollection);
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public Node Instantiate(PackedScene packedScene)
|
||||||
|
{
|
||||||
|
var node = packedScene.Instantiate();
|
||||||
|
var scope = node.GetChildren().OfType<Scope>().SingleOrDefault();
|
||||||
|
if (scope == null)
|
||||||
|
{
|
||||||
|
Logger.LogDebug(
|
||||||
|
"Instantiated the scene {PackedSceneName} through ISceneInstantiator.Instantiate, but no scope found.",
|
||||||
|
packedScene.GetName());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
scope.ResolveInjectedNodes(Host.ServiceProvider);
|
||||||
|
}
|
||||||
|
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public T Instantiate<T>(PackedScene packedScene)
|
||||||
|
where T : Node
|
||||||
|
{
|
||||||
|
return (T)Instantiate(packedScene);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
uid://fr0c6wwras8c
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
using System;
|
||||||
|
using System.Reflection;
|
||||||
|
using Godot;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
|
||||||
|
namespace GodotHostTest.GodotDI;
|
||||||
|
|
||||||
|
public partial class Scope : Node
|
||||||
|
{
|
||||||
|
[Export] protected Node?[] InjectedNodes = [];
|
||||||
|
|
||||||
|
internal void ResolveInjectedNodes(IServiceProvider serviceProvider)
|
||||||
|
{
|
||||||
|
// resolve the injected nodes
|
||||||
|
// TODO: move to source generator, make it the only way for injection
|
||||||
|
foreach (var node in InjectedNodes)
|
||||||
|
{
|
||||||
|
if (node == null) continue;
|
||||||
|
foreach (var field in node.GetType()
|
||||||
|
.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic))
|
||||||
|
{
|
||||||
|
if (field.GetCustomAttribute<InjectAttribute>() == null) continue;
|
||||||
|
var fieldType = field.FieldType;
|
||||||
|
var service = serviceProvider.GetRequiredService(fieldType);
|
||||||
|
field.SetValue(node, service);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
uid://qjonl8stia46
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
using System;
|
||||||
|
using Godot;
|
||||||
|
|
||||||
|
namespace GodotHostTest.Helpers;
|
||||||
|
|
||||||
|
public static class NodeExtensions
|
||||||
|
{
|
||||||
|
public static void AddTo(this IDisposable disposable, Node node)
|
||||||
|
{
|
||||||
|
node.TreeExited += OnTreeExited;
|
||||||
|
return;
|
||||||
|
|
||||||
|
void OnTreeExited()
|
||||||
|
{
|
||||||
|
disposable.Dispose();
|
||||||
|
node.TreeExited -= OnTreeExited;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
uid://lbkratfmlq5e
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
using System;
|
||||||
|
using R3;
|
||||||
|
|
||||||
|
namespace GodotHostTest.Helpers;
|
||||||
|
|
||||||
|
public static class ObservableHelpers
|
||||||
|
{
|
||||||
|
public static IDisposable SubscribeOnce<T>(this Observable<T> observable, Action<T> action)
|
||||||
|
{
|
||||||
|
IDisposable? disposable = null;
|
||||||
|
disposable = observable.Subscribe(x =>
|
||||||
|
{
|
||||||
|
// ReSharper disable once AccessToModifiedClosure
|
||||||
|
disposable?.Dispose();
|
||||||
|
action(x);
|
||||||
|
});
|
||||||
|
return disposable;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
uid://kfb8ooqmhoh0
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
using System;
|
||||||
|
using R3;
|
||||||
|
|
||||||
|
namespace GodotHostTest.Helpers;
|
||||||
|
|
||||||
|
public class Pipe<T> : IDisposable
|
||||||
|
{
|
||||||
|
private readonly ReplaySubject<Observable<T>> _subject = new(1);
|
||||||
|
|
||||||
|
public Pipe()
|
||||||
|
{
|
||||||
|
Observable = _subject.Switch();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Observable<T> Observable { get; }
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
_subject.Dispose();
|
||||||
|
GC.SuppressFinalize(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void PipeIn(Observable<T> observable)
|
||||||
|
{
|
||||||
|
_subject.OnNext(observable);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
uid://crh20vve83rew
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
namespace GodotHostTest.Interfaces;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// An object that keeps track of the score.
|
||||||
|
/// </summary>
|
||||||
|
public interface IScore
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// A target has been hit.
|
||||||
|
/// </summary>
|
||||||
|
void TargetHit();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A target has timed out.
|
||||||
|
/// </summary>
|
||||||
|
void TargetTimedOut();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The current score.
|
||||||
|
/// </summary>
|
||||||
|
public int Score { get; }
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
uid://wf8obkyi1rod
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
using R3;
|
||||||
|
|
||||||
|
namespace GodotHostTest.Interfaces;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A target for our projectiles.
|
||||||
|
/// </summary>
|
||||||
|
public interface ITarget
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The target hasn't been hit in the allotted time and has timed out.
|
||||||
|
/// </summary>
|
||||||
|
Observable<Unit> TimedOut { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The target has been hit.
|
||||||
|
/// </summary>
|
||||||
|
Observable<Unit> Hit { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Enable the target. Targets start disabled and gets disabled when they're hit or time out.
|
||||||
|
/// </summary>
|
||||||
|
void Enable();
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
uid://bgkbpxwire4qb
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
namespace GodotHostTest.Interfaces;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// An object which collects targets as soon as they are created.
|
||||||
|
/// </summary>
|
||||||
|
public interface ITargetCollector
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Register a target.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="target">The new target.</param>
|
||||||
|
void NewTarget(ITarget target);
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
uid://cyuavtr6x72uj
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
using R3;
|
||||||
|
|
||||||
|
namespace GodotHostTest.Interfaces;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// An object that spawns targets.
|
||||||
|
/// </summary>
|
||||||
|
public interface ITargetSpawner
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Observable that produces a value whenever a target gets spawned.
|
||||||
|
/// </summary>
|
||||||
|
Observable<ITarget> TargetSpawned { get; }
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
uid://b8ksms66cbg3
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
using Godot;
|
||||||
|
|
||||||
|
namespace GodotHostTest;
|
||||||
|
|
||||||
|
public partial class PrintOrder : Node
|
||||||
|
{
|
||||||
|
[Export] private Node? _otherNode;
|
||||||
|
|
||||||
|
public PrintOrder()
|
||||||
|
{
|
||||||
|
PrintStatus("constructor");
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void _EnterTree()
|
||||||
|
{
|
||||||
|
PrintStatus("_enter_tree");
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void _Ready()
|
||||||
|
{
|
||||||
|
PrintStatus("_ready");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void PrintStatus(string moment)
|
||||||
|
{
|
||||||
|
var hasExport = _otherNode != null;
|
||||||
|
var hasParent = GetParent() != null;
|
||||||
|
var numChildren = GetChildren().Count - 1; // remove the non-script child
|
||||||
|
GD.Print($"[{moment,11}] Child {Name,-8} Has export? {hasExport} Has parent? {hasParent} Script children? {numChildren}");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
uid://c30r02q21wx33
|
||||||
@@ -0,0 +1,79 @@
|
|||||||
|
[gd_scene format=3 uid="uid://cfobsqrtg2n2a"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" uid="uid://c30r02q21wx33" path="res://PrintOrder.cs" id="1_f88u3"]
|
||||||
|
|
||||||
|
[node name="TestOrder" type="Node2D" unique_id=2018587797]
|
||||||
|
|
||||||
|
[node name="Root1" type="Node2D" parent="." unique_id=1113529794 node_paths=PackedStringArray("_otherNode")]
|
||||||
|
script = ExtResource("1_f88u3")
|
||||||
|
_otherNode = NodePath("../ImportedNode")
|
||||||
|
|
||||||
|
[node name="Child" type="Node" parent="Root1" unique_id=1210473518]
|
||||||
|
|
||||||
|
[node name="Child1" type="Node2D" parent="Root1" unique_id=1613779589 node_paths=PackedStringArray("_otherNode")]
|
||||||
|
script = ExtResource("1_f88u3")
|
||||||
|
_otherNode = NodePath("../../ImportedNode")
|
||||||
|
|
||||||
|
[node name="Child" type="Node" parent="Root1/Child1" unique_id=87552907]
|
||||||
|
|
||||||
|
[node name="Descendant1" type="Node2D" parent="Root1/Child1" unique_id=669587585 node_paths=PackedStringArray("_otherNode")]
|
||||||
|
script = ExtResource("1_f88u3")
|
||||||
|
_otherNode = NodePath("../../../ImportedNode")
|
||||||
|
|
||||||
|
[node name="Child" type="Node" parent="Root1/Child1/Descendant1" unique_id=12685308]
|
||||||
|
|
||||||
|
[node name="Descendant2" type="Node2D" parent="Root1/Child1" unique_id=109086010 node_paths=PackedStringArray("_otherNode")]
|
||||||
|
script = ExtResource("1_f88u3")
|
||||||
|
_otherNode = NodePath("../../../ImportedNode")
|
||||||
|
|
||||||
|
[node name="Child" type="Node" parent="Root1/Child1/Descendant2" unique_id=1161770344]
|
||||||
|
|
||||||
|
[node name="Child2" type="Node2D" parent="Root1" unique_id=806378838 node_paths=PackedStringArray("_otherNode")]
|
||||||
|
script = ExtResource("1_f88u3")
|
||||||
|
_otherNode = NodePath("../../ImportedNode")
|
||||||
|
|
||||||
|
[node name="Child" type="Node" parent="Root1/Child2" unique_id=1260588174]
|
||||||
|
|
||||||
|
[node name="Child3" type="Node2D" parent="Root1" unique_id=2084092809 node_paths=PackedStringArray("_otherNode")]
|
||||||
|
script = ExtResource("1_f88u3")
|
||||||
|
_otherNode = NodePath("../../ImportedNode")
|
||||||
|
|
||||||
|
[node name="Child" type="Node" parent="Root1/Child3" unique_id=1306245672]
|
||||||
|
|
||||||
|
[node name="Root2" type="Node2D" parent="." unique_id=1070917045 node_paths=PackedStringArray("_otherNode")]
|
||||||
|
script = ExtResource("1_f88u3")
|
||||||
|
_otherNode = NodePath("../ImportedNode")
|
||||||
|
|
||||||
|
[node name="Child" type="Node" parent="Root2" unique_id=564938069]
|
||||||
|
|
||||||
|
[node name="Child1" type="Node2D" parent="Root2" unique_id=1331804694 node_paths=PackedStringArray("_otherNode")]
|
||||||
|
script = ExtResource("1_f88u3")
|
||||||
|
_otherNode = NodePath("../../ImportedNode")
|
||||||
|
|
||||||
|
[node name="Child" type="Node" parent="Root2/Child1" unique_id=358417729]
|
||||||
|
|
||||||
|
[node name="Descendant1" type="Node2D" parent="Root2/Child1" unique_id=765114105 node_paths=PackedStringArray("_otherNode")]
|
||||||
|
script = ExtResource("1_f88u3")
|
||||||
|
_otherNode = NodePath("../../../ImportedNode")
|
||||||
|
|
||||||
|
[node name="Child" type="Node" parent="Root2/Child1/Descendant1" unique_id=119960501]
|
||||||
|
|
||||||
|
[node name="Descendant2" type="Node2D" parent="Root2/Child1" unique_id=1849254856 node_paths=PackedStringArray("_otherNode")]
|
||||||
|
script = ExtResource("1_f88u3")
|
||||||
|
_otherNode = NodePath("../../../ImportedNode")
|
||||||
|
|
||||||
|
[node name="Child" type="Node" parent="Root2/Child1/Descendant2" unique_id=439293261]
|
||||||
|
|
||||||
|
[node name="Child2" type="Node2D" parent="Root2" unique_id=690813149 node_paths=PackedStringArray("_otherNode")]
|
||||||
|
script = ExtResource("1_f88u3")
|
||||||
|
_otherNode = NodePath("../../ImportedNode")
|
||||||
|
|
||||||
|
[node name="Child" type="Node" parent="Root2/Child2" unique_id=1594270861]
|
||||||
|
|
||||||
|
[node name="Child3" type="Node2D" parent="Root2" unique_id=497541522 node_paths=PackedStringArray("_otherNode")]
|
||||||
|
script = ExtResource("1_f88u3")
|
||||||
|
_otherNode = NodePath("../../ImportedNode")
|
||||||
|
|
||||||
|
[node name="Child" type="Node" parent="Root2/Child3" unique_id=1948966308]
|
||||||
|
|
||||||
|
[node name="ImportedNode" type="Node" parent="." unique_id=2077860292]
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"sdk": {
|
||||||
|
"version": "9.0.0",
|
||||||
|
"rollForward": "latestMajor",
|
||||||
|
"allowPrerelease": true
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
<Project Sdk="Godot.NET.Sdk/4.7.0">
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
|
<TargetFramework Condition=" '$(GodotTargetPlatform)' == 'android' ">net9.0</TargetFramework>
|
||||||
|
<EnableDynamicLoading>true</EnableDynamicLoading>
|
||||||
|
<RootNamespace>GodotHostTest</RootNamespace>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="R3" Version="1.3.1" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="OwofGames.GodotHost">
|
||||||
|
<HintPath>..\OwofGames.Godot\OwofGames.GodotHost\bin\Debug\net8.0\OwofGames.GodotHost.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="OwofGames.GodotLogger">
|
||||||
|
<HintPath>..\OwofGames.Godot\OwofGames.GodotHost\bin\Debug\net8.0\OwofGames.GodotLogger.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Configuration.CommandLine" Version="10.0.0"/>
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="10.0.0"/>
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="10.0.0"/>
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="10.0.0"/>
|
||||||
|
<PackageReference Include="Microsoft.Extensions.FileProviders.Composite" Version="10.0.0"/>
|
||||||
|
<PackageReference Include="Microsoft.Extensions.FileProviders.Physical" Version="10.0.0"/>
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Logging" Version="10.0.0"/>
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Logging.Configuration" Version="10.0.0"/>
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio 2012
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "godot-host-test", "godot-host-test.csproj", "{ACB2B98F-A7C5-4486-BC24-2B85B7990C5B}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
ExportDebug|Any CPU = ExportDebug|Any CPU
|
||||||
|
ExportRelease|Any CPU = ExportRelease|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{ACB2B98F-A7C5-4486-BC24-2B85B7990C5B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{ACB2B98F-A7C5-4486-BC24-2B85B7990C5B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{ACB2B98F-A7C5-4486-BC24-2B85B7990C5B}.ExportDebug|Any CPU.ActiveCfg = ExportDebug|Any CPU
|
||||||
|
{ACB2B98F-A7C5-4486-BC24-2B85B7990C5B}.ExportDebug|Any CPU.Build.0 = ExportDebug|Any CPU
|
||||||
|
{ACB2B98F-A7C5-4486-BC24-2B85B7990C5B}.ExportRelease|Any CPU.ActiveCfg = ExportRelease|Any CPU
|
||||||
|
{ACB2B98F-A7C5-4486-BC24-2B85B7990C5B}.ExportRelease|Any CPU.Build.0 = ExportRelease|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||||
|
<s:Boolean x:Key="/Default/AddReferences/RecentPaths/=_002Fhome_002Fredglow_002Fsources_002FOwofGames_002EGodot_002FOwofGames_002EGodotHost_002Fbin_002FDebug_002Fnet8_002E0_002FOwofGames_002EGodotHost_002Edll/@EntryIndexedValue">True</s:Boolean>
|
||||||
|
<s:Boolean x:Key="/Default/AddReferences/RecentPaths/=_002Fhome_002Fredglow_002Fsources_002FOwofGames_002EGodot_002FOwofGames_002EGodotHost_002Fbin_002FDebug_002Fnet8_002E0_002FOwofGames_002EGodotLogger_002Edll/@EntryIndexedValue">True</s:Boolean>
|
||||||
|
<s:String x:Key="/Default/Environment/Hierarchy/Build/BuildTool/DotNetCliExePath/@EntryValue">/usr/lib/dotnet/dotnet</s:String>
|
||||||
|
<s:String x:Key="/Default/Environment/Hierarchy/Build/BuildTool/CustomBuildToolPath/@EntryValue">/usr/lib/dotnet/sdk/10.0.109/MSBuild.dll</s:String></wpf:ResourceDictionary>
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="128" height="128"><rect width="124" height="124" x="2" y="2" fill="#363d52" stroke="#212532" stroke-width="4" rx="14"/><g fill="#fff" transform="translate(12.322 12.322)scale(.101)"><path d="M105 673v33q407 354 814 0v-33z"/><path fill="#478cbf" d="m105 673 152 14q12 1 15 14l4 67 132 10 8-61q2-11 15-15h162q13 4 15 15l8 61 132-10 4-67q3-13 15-14l152-14V427q30-39 56-81-35-59-83-108-43 20-82 47-40-37-88-64 7-51 8-102-59-28-123-42-26 43-46 89-49-7-98 0-20-46-46-89-64 14-123 42 1 51 8 102-48 27-88 64-39-27-82-47-48 49-83 108 26 42 56 81zm0 33v39c0 276 813 276 814 0v-39l-134 12-5 69q-2 10-14 13l-162 11q-12 0-16-11l-10-65H446l-10 65q-4 11-16 11l-162-11q-12-3-14-13l-5-69z"/><path d="M483 600c0 34 58 34 58 0v-86c0-34-58-34-58 0z"/><circle cx="725" cy="526" r="90"/><circle cx="299" cy="526" r="90"/></g><g fill="#414042" transform="translate(12.322 12.322)scale(.101)"><circle cx="307" cy="532" r="60"/><circle cx="717" cy="532" r="60"/></g></svg>
|
||||||
|
After Width: | Height: | Size: 995 B |
@@ -0,0 +1,43 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://y1ros3y7hag2"
|
||||||
|
path="res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://icon.svg"
|
||||||
|
dest_files=["res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/high_quality=false
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/uastc_level=0
|
||||||
|
compress/rdo_quality_loss=0.0
|
||||||
|
compress/hdr_compression=1
|
||||||
|
compress/normal_map=0
|
||||||
|
compress/channel_pack=0
|
||||||
|
mipmaps/generate=false
|
||||||
|
mipmaps/limit=-1
|
||||||
|
roughness/mode=0
|
||||||
|
roughness/src_normal=""
|
||||||
|
process/channel_remap/red=0
|
||||||
|
process/channel_remap/green=1
|
||||||
|
process/channel_remap/blue=2
|
||||||
|
process/channel_remap/alpha=3
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/normal_map_invert_y=false
|
||||||
|
process/hdr_as_srgb=false
|
||||||
|
process/hdr_clamp_exposure=false
|
||||||
|
process/size_limit=0
|
||||||
|
detect_3d/compress_to=1
|
||||||
|
svg/scale=1.0
|
||||||
|
editor/scale_with_editor_scale=false
|
||||||
|
editor/convert_colors_with_editor_theme=false
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
; Engine configuration file.
|
||||||
|
; It's best edited using the editor UI and not directly,
|
||||||
|
; since the parameters that go here are not all obvious.
|
||||||
|
;
|
||||||
|
; Format:
|
||||||
|
; [section] ; section goes between []
|
||||||
|
; param=value ; assign values to parameters
|
||||||
|
|
||||||
|
config_version=5
|
||||||
|
|
||||||
|
[application]
|
||||||
|
|
||||||
|
config/name="godot-host-test"
|
||||||
|
run/main_scene="uid://vsburk37p4u"
|
||||||
|
config/features=PackedStringArray("4.7", "C#", "Forward Plus")
|
||||||
|
config/icon="res://icon.svg"
|
||||||
|
|
||||||
|
[display]
|
||||||
|
|
||||||
|
window/stretch/mode="canvas_items"
|
||||||
|
window/stretch/aspect="expand"
|
||||||
|
|
||||||
|
[dotnet]
|
||||||
|
|
||||||
|
project/assembly_name="godot-host-test"
|
||||||
|
|
||||||
|
[physics]
|
||||||
|
|
||||||
|
3d/physics_engine="Jolt Physics"
|
||||||
|
|
||||||
|
[rendering]
|
||||||
|
|
||||||
|
rendering_device/driver.windows="d3d12"
|
||||||
+142
@@ -0,0 +1,142 @@
|
|||||||
|
[gd_scene format=3 uid="uid://vsburk37p4u"]
|
||||||
|
|
||||||
|
[ext_resource type="PackedScene" uid="uid://3v8kq1rfwhmr" path="res://Game/target.tscn" id="2_c77vg"]
|
||||||
|
[ext_resource type="Script" uid="uid://cxfrtglku2gfa" path="res://Game/TargetSpawner.cs" id="3_iqet6"]
|
||||||
|
[ext_resource type="Script" uid="uid://dk578xnlxjwrr" path="res://Game/GameRootScope.cs" id="3_t2jh2"]
|
||||||
|
[ext_resource type="Script" uid="uid://bgrjeadxhgmvi" path="res://Game/Score.cs" id="4_t2jh2"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://y1ros3y7hag2" path="res://icon.svg" id="5_4ty2a"]
|
||||||
|
[ext_resource type="Script" uid="uid://ce7gnp1lcrrdv" path="res://Game/Turret.cs" id="6_rckqj"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://brbufibn7hi3o" path="res://Game/projectile.tscn" id="7_rckqj"]
|
||||||
|
|
||||||
|
[sub_resource type="Animation" id="Animation_bbjqm"]
|
||||||
|
length = 0.001
|
||||||
|
tracks/0/type = "value"
|
||||||
|
tracks/0/imported = false
|
||||||
|
tracks/0/enabled = true
|
||||||
|
tracks/0/path = NodePath("Score:offset_transform_position")
|
||||||
|
tracks/0/interp = 1
|
||||||
|
tracks/0/loop_wrap = true
|
||||||
|
tracks/0/keys = {
|
||||||
|
"times": PackedFloat32Array(0),
|
||||||
|
"transitions": PackedFloat32Array(1),
|
||||||
|
"update": 0,
|
||||||
|
"values": [Vector2(0, 0)]
|
||||||
|
}
|
||||||
|
tracks/1/type = "value"
|
||||||
|
tracks/1/imported = false
|
||||||
|
tracks/1/enabled = true
|
||||||
|
tracks/1/path = NodePath("Score:offset_transform_rotation")
|
||||||
|
tracks/1/interp = 1
|
||||||
|
tracks/1/loop_wrap = true
|
||||||
|
tracks/1/keys = {
|
||||||
|
"times": PackedFloat32Array(0),
|
||||||
|
"transitions": PackedFloat32Array(1),
|
||||||
|
"update": 0,
|
||||||
|
"values": [0.0]
|
||||||
|
}
|
||||||
|
|
||||||
|
[sub_resource type="Animation" id="Animation_4ty2a"]
|
||||||
|
resource_name = "wiggle"
|
||||||
|
length = 0.3
|
||||||
|
tracks/0/type = "value"
|
||||||
|
tracks/0/imported = false
|
||||||
|
tracks/0/enabled = true
|
||||||
|
tracks/0/path = NodePath("Score:offset_transform_position")
|
||||||
|
tracks/0/interp = 1
|
||||||
|
tracks/0/loop_wrap = true
|
||||||
|
tracks/0/keys = {
|
||||||
|
"times": PackedFloat32Array(0, 0.049999997, 0.099999994, 0.15, 0.2, 0.24999999),
|
||||||
|
"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1),
|
||||||
|
"update": 0,
|
||||||
|
"values": [Vector2(0, 0), Vector2(10, -10), Vector2(-10, -10), Vector2(10, 10), Vector2(-10, 10), Vector2(0, 0)]
|
||||||
|
}
|
||||||
|
tracks/1/type = "value"
|
||||||
|
tracks/1/imported = false
|
||||||
|
tracks/1/enabled = true
|
||||||
|
tracks/1/path = NodePath("Score:offset_transform_rotation")
|
||||||
|
tracks/1/interp = 1
|
||||||
|
tracks/1/loop_wrap = true
|
||||||
|
tracks/1/keys = {
|
||||||
|
"times": PackedFloat32Array(0, 0.049999997, 0.099999994, 0.15, 0.2, 0.24999999),
|
||||||
|
"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1),
|
||||||
|
"update": 0,
|
||||||
|
"values": [0.0, 0.08726646, -0.08726646, 0.08726646, -0.08726646, 0.0]
|
||||||
|
}
|
||||||
|
|
||||||
|
[sub_resource type="AnimationLibrary" id="AnimationLibrary_rckqj"]
|
||||||
|
_data = {
|
||||||
|
&"RESET": SubResource("Animation_bbjqm"),
|
||||||
|
&"wiggle": SubResource("Animation_4ty2a")
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="Node2D" type="Node2D" unique_id=920849082]
|
||||||
|
|
||||||
|
[node name="RootScope" type="Node" parent="." unique_id=1453141084 node_paths=PackedStringArray("_targetSpawner", "InjectedNodes")]
|
||||||
|
script = ExtResource("3_t2jh2")
|
||||||
|
_targetSpawner = NodePath("../Spawner")
|
||||||
|
InjectedNodes = [NodePath("../Turret"), NodePath("../Target"), NodePath("../Target2"), NodePath("../Target3"), NodePath("../Target4"), NodePath("../Target5"), NodePath("../Target6"), NodePath("../Spawner"), NodePath("../Score")]
|
||||||
|
|
||||||
|
[node name="Target" parent="." unique_id=2101558052 instance=ExtResource("2_c77vg")]
|
||||||
|
position = Vector2(198, 143)
|
||||||
|
TimeOutDurationInSeconds = 2.0
|
||||||
|
|
||||||
|
[node name="Target2" parent="." unique_id=1480287846 instance=ExtResource("2_c77vg")]
|
||||||
|
position = Vector2(669, 64)
|
||||||
|
TimeOutDurationInSeconds = 2.0
|
||||||
|
|
||||||
|
[node name="Target3" parent="." unique_id=242951997 instance=ExtResource("2_c77vg")]
|
||||||
|
position = Vector2(1060, 263)
|
||||||
|
TimeOutDurationInSeconds = 2.0
|
||||||
|
|
||||||
|
[node name="Target4" parent="." unique_id=1190782819 instance=ExtResource("2_c77vg")]
|
||||||
|
position = Vector2(961, 620)
|
||||||
|
TimeOutDurationInSeconds = 2.0
|
||||||
|
|
||||||
|
[node name="Target5" parent="." unique_id=1183803617 instance=ExtResource("2_c77vg")]
|
||||||
|
position = Vector2(469, 591)
|
||||||
|
TimeOutDurationInSeconds = 2.0
|
||||||
|
|
||||||
|
[node name="Target6" parent="." unique_id=2017833482 instance=ExtResource("2_c77vg")]
|
||||||
|
position = Vector2(53, 417)
|
||||||
|
TimeOutDurationInSeconds = 2.0
|
||||||
|
|
||||||
|
[node name="Spawner" type="Node2D" parent="." unique_id=1331368036 node_paths=PackedStringArray("Timer")]
|
||||||
|
script = ExtResource("3_iqet6")
|
||||||
|
TimeBetweenSpawns = 1.5
|
||||||
|
Timer = NodePath("Timer")
|
||||||
|
|
||||||
|
[node name="Timer" type="Timer" parent="Spawner" unique_id=1142098929]
|
||||||
|
|
||||||
|
[node name="Score" type="ColorRect" parent="." unique_id=1990204205 node_paths=PackedStringArray("_animationPlayer", "_label")]
|
||||||
|
offset_right = 200.0
|
||||||
|
offset_bottom = 40.0
|
||||||
|
offset_transform_enabled = true
|
||||||
|
color = Color(1, 1, 1, 0.2784314)
|
||||||
|
script = ExtResource("4_t2jh2")
|
||||||
|
_animationPlayer = NodePath("../AnimationPlayer")
|
||||||
|
_label = NodePath("Label")
|
||||||
|
|
||||||
|
[node name="Label" type="Label" parent="Score" unique_id=1929317028]
|
||||||
|
layout_mode = 1
|
||||||
|
anchors_preset = -1
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
offset_left = 10.0
|
||||||
|
offset_right = -10.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
theme_override_colors/font_color = Color(0, 0, 0, 1)
|
||||||
|
text = "Score: 0"
|
||||||
|
vertical_alignment = 1
|
||||||
|
|
||||||
|
[node name="AnimationPlayer" type="AnimationPlayer" parent="." unique_id=1749711689]
|
||||||
|
libraries/ = SubResource("AnimationLibrary_rckqj")
|
||||||
|
|
||||||
|
[node name="Turret" type="Sprite2D" parent="." unique_id=1932581411]
|
||||||
|
modulate = Color(1.92523e-07, 0.88004553, 0.8802661, 1)
|
||||||
|
position = Vector2(539, 307)
|
||||||
|
texture = ExtResource("5_4ty2a")
|
||||||
|
script = ExtResource("6_rckqj")
|
||||||
|
_projectilePackedScene = ExtResource("7_rckqj")
|
||||||
|
|
||||||
|
[connection signal="timeout" from="Spawner/Timer" to="Spawner" method="OnTimer"]
|
||||||
Reference in New Issue
Block a user