riversong code showcase

This commit is contained in:
Daniele Marotta
2026-05-21 15:52:18 +02:00
commit 4c9eea1c02
462 changed files with 23406 additions and 0 deletions

View File

@@ -0,0 +1,43 @@
using System;
using Cysharp.Threading.Tasks;
using UnityEngine;
namespace DanieleMarotta.RiversongCodeShowcase
{
[GameSystemGroup(typeof(LateGameSystemGroup))]
public class GlobalShaderParametersSystem : GameSystem, IInitializable, IDisposable, IUpdatable
{
[InjectService]
private World _world;
[InjectService]
private ISignalBus _signalBus;
public GlobalShaderParametersSystem(IServiceLocator serviceLocator) : base(serviceLocator)
{
}
public UniTask InitializeAsync()
{
_signalBus.Subscribe<WorldReadySignal>(OnWorldReady);
return UniTask.CompletedTask;
}
public void Dispose()
{
_signalBus.Unsubscribe<WorldReadySignal>(OnWorldReady);
}
public void Update()
{
var t = Time.unscaledTime;
Shader.SetGlobalVector(ShaderProperties.UnscaledTime, new Vector4(t / 20, t, t * 2, t * 3));
}
private void OnWorldReady(WorldReadySignal signal)
{
Shader.SetGlobalVector(ShaderProperties.WorldSize, new Vector4(_world.Size.x, _world.Size.y, 0, 0));
Shader.SetGlobalVector(ShaderProperties.InverseWorldSize, new Vector2(1 / (float)_world.Size.x, 1 / (float)_world.Size.y));
}
}
}