-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding some old godot utilities from some application
- Loading branch information
1 parent
0e645de
commit cc45e8a
Showing
21 changed files
with
300 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Normalize EOL for all files that Git considers text files. | ||
* text=auto eol=lf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Godot 4+ specific ignores | ||
.godot/ |
13 changes: 13 additions & 0 deletions
13
PereViader.Utils.Godot/.idea/.idea.PereViader.Utils.Godot/.idea/.gitignore
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
4 changes: 4 additions & 0 deletions
4
PereViader.Utils.Godot/.idea/.idea.PereViader.Utils.Godot/.idea/encodings.xml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
8 changes: 8 additions & 0 deletions
8
PereViader.Utils.Godot/.idea/.idea.PereViader.Utils.Godot/.idea/indexLayout.xml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
6 changes: 6 additions & 0 deletions
6
PereViader.Utils.Godot/.idea/.idea.PereViader.Utils.Godot/.idea/vcs.xml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<Project Sdk="Godot.NET.Sdk/4.1.1"> | ||
<PropertyGroup> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<EnableDynamicLoading>true</EnableDynamicLoading> | ||
<Nullable>enable</Nullable> | ||
<WarningsAsErrors>true</WarningsAsErrors> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<PackageReference Include="PereViader.Utils.Common" Version="1.0.2" /> | ||
</ItemGroup> | ||
</Project> |
2 changes: 2 additions & 0 deletions
2
PereViader.Utils.Godot/PereViader.Utils.Godot.csproj.DotSettings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<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/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=scripts/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio 2012 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PereViader.Utils.Godot", "PereViader.Utils.Godot.csproj", "{14494561-92F7-44F4-AF11-FBF5CEE11162}" | ||
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 | ||
{14494561-92F7-44F4-AF11-FBF5CEE11162}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{14494561-92F7-44F4-AF11-FBF5CEE11162}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{14494561-92F7-44F4-AF11-FBF5CEE11162}.ExportDebug|Any CPU.ActiveCfg = ExportDebug|Any CPU | ||
{14494561-92F7-44F4-AF11-FBF5CEE11162}.ExportDebug|Any CPU.Build.0 = ExportDebug|Any CPU | ||
{14494561-92F7-44F4-AF11-FBF5CEE11162}.ExportRelease|Any CPU.ActiveCfg = ExportRelease|Any CPU | ||
{14494561-92F7-44F4-AF11-FBF5CEE11162}.ExportRelease|Any CPU.Build.0 = ExportRelease|Any CPU | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[gd_scene format=3 uid="uid://c4s0cdav7j12w"] | ||
|
||
[node name="Node2D" type="Node2D"] |
11 changes: 11 additions & 0 deletions
11
PereViader.Utils.Godot/Scripts/AnimationPlayerExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using Godot; | ||
|
||
namespace PereViader.Utils.Godot; | ||
|
||
public static class AnimationPlayerExtensions | ||
{ | ||
public static void CompleteCurrentAnimation(this AnimationPlayer animationPlayer) | ||
{ | ||
animationPlayer.Advance(double.MaxValue); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
PereViader.Utils.Godot/Scripts/AudioStreamPlayerExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Godot; | ||
using PereViader.Utils.Common.Extensions; | ||
|
||
namespace PereViader.Utils.Godot; | ||
|
||
public static class AudioStreamPlayerExtensions | ||
{ | ||
public static Task AwaitFinished(this AudioStreamPlayer audioStreamPlayer, CancellationToken cancellationToken) | ||
{ | ||
TaskCompletionSource<object> tcs = new(); | ||
tcs.LinkCancellationToken(cancellationToken); | ||
|
||
void Finished() | ||
{ | ||
audioStreamPlayer.Finished -= Finished; | ||
tcs.TrySetResult(default!); | ||
} | ||
|
||
audioStreamPlayer.Finished += Finished; | ||
return tcs.Task; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace PereViader.Utils.Godot; | ||
|
||
public sealed class Awaiter<T> : IDisposable | ||
{ | ||
private TaskCompletionSource<T>? _tcs; | ||
|
||
public void Receive(T value) | ||
{ | ||
var currentTcs = _tcs; | ||
_tcs = null; | ||
currentTcs?.TrySetResult(value); | ||
} | ||
|
||
public void Cancel() | ||
{ | ||
var currentTcs = _tcs; | ||
_tcs = null; | ||
currentTcs?.TrySetCanceled(); | ||
} | ||
|
||
public Task<T> AwaitNext(CancellationToken cancellationToken = default) | ||
{ | ||
_tcs ??= new TaskCompletionSource<T>(); | ||
|
||
return _tcs.Task.WaitAsync(cancellationToken); | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
_tcs?.TrySetCanceled(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace PereViader.Utils.Godot; | ||
|
||
public static class EnumerableExtensions | ||
{ | ||
public static IEnumerable<(T value, int index)> ZipIndex<T>(this IEnumerable<T> enumerable) | ||
{ | ||
int index = 0; | ||
foreach (var value in enumerable) | ||
{ | ||
yield return (value, index); | ||
index++; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace PereViader.Utils.Godot; | ||
|
||
public static class FlowExtensions | ||
{ | ||
public delegate bool FirstTimeActionDelegate(bool isFirstTime); | ||
|
||
public static void RepeatUntilSuccess(FirstTimeActionDelegate action) | ||
{ | ||
var succeeded = action.Invoke(true); | ||
while (!succeeded) | ||
{ | ||
succeeded = action.Invoke(false); | ||
} | ||
} | ||
|
||
public delegate Task<bool> FirstTimeActionDelegateAsync(bool isFirstTime, CancellationToken cancellationToken); | ||
|
||
public static async Task RepeatUntilSuccess(FirstTimeActionDelegateAsync action, CancellationToken cancellationToken = default) | ||
{ | ||
cancellationToken.ThrowIfCancellationRequested(); | ||
var succeeded = await action.Invoke(true, cancellationToken); | ||
while (!succeeded) | ||
{ | ||
cancellationToken.ThrowIfCancellationRequested(); | ||
succeeded = await action.Invoke(false, cancellationToken); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using PereViader.Utils.Common.Extensions; | ||
using Godot; | ||
|
||
namespace PereViader.Utils.Godot; | ||
|
||
public static class SceneTreeExtensions | ||
{ | ||
public static Task AwaitTime(this SceneTree sceneTree, double seconds, bool processAlways = true, bool processInPhysics = false, bool ignoreTimeScale = false, CancellationToken cancellationToken = default) | ||
{ | ||
var timer = sceneTree | ||
.CreateTimer(seconds, processAlways, processInPhysics, ignoreTimeScale); | ||
|
||
var tcs = new TaskCompletionSource<object>(); | ||
timer.Timeout += () => tcs.SetResult(default!); | ||
tcs.LinkCancellationToken(cancellationToken); | ||
return tcs.Task; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using System.Threading.Tasks; | ||
|
||
namespace PereViader.Utils.Godot; | ||
|
||
public static class TaskExtensions | ||
{ | ||
public static async void RunAsync(this Task task) | ||
{ | ||
try | ||
{ | ||
await task; | ||
} | ||
catch (TaskCanceledException) | ||
{ | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using Godot; | ||
|
||
namespace PereViader.Utils.Godot; | ||
|
||
public static class TimerExtensions | ||
{ | ||
public static SignalAwaiter StartAndAwait(this Timer timer) | ||
{ | ||
var signal = timer.ToSignal(timer, Timer.SignalName.Timeout); | ||
timer.Start(); | ||
return signal; | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
[remap] | ||
|
||
importer="texture" | ||
type="CompressedTexture2D" | ||
uid="uid://c63aaqjwap5pw" | ||
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/hdr_compression=1 | ||
compress/normal_map=0 | ||
compress/channel_pack=0 | ||
mipmaps/generate=false | ||
mipmaps/limit=-1 | ||
roughness/mode=0 | ||
roughness/src_normal="" | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
; 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="PereViader.Utils.Godot" | ||
run/main_scene="res://Samples/Sample.tscn" | ||
config/features=PackedStringArray("4.1", "Mobile") | ||
config/icon="res://icon.svg" | ||
|
||
[dotnet] | ||
|
||
project/assembly_name="PereViader.Utils.Godot" | ||
|
||
[rendering] | ||
|
||
renderer/rendering_method="mobile" |