diff --git a/OpenDreamClient/Rendering/ClientDreamParticlesSystem.cs b/OpenDreamClient/Rendering/ClientDreamParticlesSystem.cs index 7792795299..3805f2a53d 100644 --- a/OpenDreamClient/Rendering/ClientDreamParticlesSystem.cs +++ b/OpenDreamClient/Rendering/ClientDreamParticlesSystem.cs @@ -1,8 +1,10 @@ using JetBrains.Annotations; using OpenDreamShared.Rendering; +using Pidgin; using Robust.Client.Graphics; using Robust.Client.ResourceManagement; using Robust.Shared.Random; +using Robust.Shared.Timing; using Vector3 = Robust.Shared.Maths.Vector3; namespace OpenDreamClient.Rendering; @@ -12,13 +14,19 @@ public sealed class ClientDreamParticlesSystem : SharedDreamParticlesSystem { [Dependency] private readonly ParticlesManager _particlesManager = default!; [Dependency] private readonly IResourceCache _resourceCache = default!; + [Dependency] private readonly IGameTiming _gameTiming = default!; + [Dependency] private readonly ClientAppearanceSystem _appearanceSystem = default!; + [Dependency] private readonly IClyde _clyde = default!; + public RenderTargetPool RenderTargetPool = default!; private Random random = new(); + private RendererMetaData defaultRenderMetaData = new(); //used for icon GetTexture(), never needs anything but default settings public override void Initialize() { base.Initialize(); SubscribeLocalEvent(OnDreamParticlesComponentChange); SubscribeLocalEvent(HandleComponentAdd); SubscribeLocalEvent(HandleComponentRemove); + RenderTargetPool = new(_clyde); } private void OnDreamParticlesComponentChange(EntityUid uid, DreamParticlesComponent component, ref ComponentChange args) @@ -42,20 +50,25 @@ private ParticleSystemArgs GetParticleSystemArgs(DreamParticlesComponent compone Func textureFunc; if(component.TextureList is null || component.TextureList.Length == 0) textureFunc = () => Texture.White; - else - textureFunc = () => _resourceCache.GetResource(new Random().Pick(component.TextureList)); //TODO - + else{ + List icons = new(component.TextureList.Length); + foreach(var appearance in component.TextureList){ + DreamIcon icon = new DreamIcon(RenderTargetPool, _gameTiming, _clyde, _appearanceSystem); + icon.SetAppearance(appearance.MustGetId()); + icons.Add(icon); + } + textureFunc = () => random.Pick(icons).GetTexture(null!, null!, defaultRenderMetaData, null)!; //oh god, so hacky + } var result = new ParticleSystemArgs(textureFunc, new Vector2i(component.Width, component.Height), (uint)component.Count, component.Spawning); - GeneratorFloat lifespan = new(); result.Lifespan = GetGeneratorFloat(component.LifespanLow, component.LifespanHigh, component.LifespanType); result.Fadein = GetGeneratorFloat(component.FadeInLow, component.FadeInHigh, component.FadeInType); result.Fadeout = GetGeneratorFloat(component.FadeOutLow, component.FadeOutHigh, component.FadeOutType); - if(component.ColorList.Length > 0) + if(component.Gradient.Length > 0) result.Color = (float lifetime) => { - var colorIndex = (int)(lifetime * component.ColorList.Length); - colorIndex = Math.Clamp(colorIndex, 0, component.ColorList.Length - 1); - return component.ColorList[colorIndex]; + var colorIndex = (int)(lifetime * component.Gradient.Length); + colorIndex = Math.Clamp(colorIndex, 0, component.Gradient.Length - 1); + return component.Gradient[colorIndex]; }; else result.Color = (float lifetime) => Color.White; diff --git a/TestGame/code.dm b/TestGame/code.dm index d1b94607d4..2f4a238ed3 100644 --- a/TestGame/code.dm +++ b/TestGame/code.dm @@ -52,6 +52,25 @@ spawn(20) toggleBlink() +/particles/swarm/bees + icon = 'icons/bee.dmi' + icon_state = list("mini-bee"=1, "mini-bee2"=1) + friction = 0.1 + count = 10 + spawning = 0.35 + fade = 5 + fadein = 5 + lifespan = generator("num", 50, 80, LINEAR_RAND) + width = 64 + position = generator("box", list(-10,-10,0), list(10,10,50)) + bound1 = list(-32, -32, -100) + bound2 = list(32, 32, 100) + gravity = list(0, -0.1) + drift = generator("box", list(-0.4, -0.1, 0), list(0.4, 0.15, 0)) + velocity = generator("box", list(-2, -0.1, 0), list(2, 0.5, 0)) + height = 64 + + /mob icon = 'icons/mob.dmi' icon_state = "mob" @@ -62,6 +81,7 @@ desc = "Such a beautiful smile." gender = MALE see_invisible = 101 + particles = new /particles/swarm/bees New() ..() diff --git a/TestGame/icons/bee.dmi b/TestGame/icons/bee.dmi new file mode 100644 index 0000000000..e7e5289162 Binary files /dev/null and b/TestGame/icons/bee.dmi differ