Skip to content

Commit

Permalink
drawing
Browse files Browse the repository at this point in the history
  • Loading branch information
amylizzle committed Feb 20, 2025
1 parent 32f9e1f commit 2aebbc9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
11 changes: 3 additions & 8 deletions OpenDreamClient/Rendering/ClientDreamParticlesSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ public sealed class ClientDreamParticlesSystem : SharedDreamParticlesSystem
public override void Initialize() {
base.Initialize();
SubscribeLocalEvent<DreamParticlesComponent, ComponentHandleState>(OnDreamParticlesComponentChange);
SubscribeLocalEvent<DreamParticlesComponent, ComponentAdd>(HandleComponentAdd);
SubscribeLocalEvent<DreamParticlesComponent, ComponentRemove>(HandleComponentRemove);
RenderTargetPool = new(_clyde);
}
Expand Down Expand Up @@ -83,13 +82,9 @@ private void OnDreamParticlesComponentChange(EntityUid uid, DreamParticlesCompon
component.DriftType = state.DriftType;
if(_particlesManager.TryGetParticleSystem(uid, out var system))
system.UpdateSystem(GetParticleSystemArgs(component));
else
_particlesManager.CreateParticleSystem(uid, GetParticleSystemArgs(component));
}

private void HandleComponentAdd(EntityUid uid, DreamParticlesComponent component, ref ComponentAdd args)
{
_particlesManager.CreateParticleSystem(uid, GetParticleSystemArgs(component));
}

private void HandleComponentRemove(EntityUid uid, DreamParticlesComponent component, ref ComponentRemove args)
{
_particlesManager.DestroyParticleSystem(uid);
Expand All @@ -106,7 +101,7 @@ private ParticleSystemArgs GetParticleSystemArgs(DreamParticlesComponent compone
icon.SetAppearance(appearance.MustGetId());
icons.Add(icon);
}
textureFunc = () => random.Pick(icons).GetTexture(null!, null!, defaultRenderMetaData, null)!; //oh god, so hacky
textureFunc = () => random.Pick(icons).GetTexture(null!, null!, defaultRenderMetaData, null) ?? Texture.White; //oh god, so hacky
}
var result = new ParticleSystemArgs(textureFunc, new Vector2i(component.Width, component.Height), (uint)component.Count, component.Spawning);
GeneratorFloat lifespan = new();
Expand Down
3 changes: 2 additions & 1 deletion OpenDreamClient/Rendering/DreamViewOverlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -462,8 +462,9 @@ public void DrawIcon(DrawingHandleWorld handle, Vector2i renderTargetSize, Rende
if(iconMetaData.Particles is not null) {
foreach(var particleSystem in iconMetaData.Particles){
handle.UseShader(GetBlendAndColorShader(iconMetaData, ignoreColor: true));
particleSystem.Draw(handle, pixelPosition);
handle.SetTransform(CalculateDrawingMatrix(iconMetaData.TransformToApply, pixelPosition-particleSystem.RenderSize/2, particleSystem.RenderSize, renderTargetSize));
particleSystem.Draw(handle, pixelPosition);

}
}
//if frame is null, this doesn't require a draw, so return NOP
Expand Down
13 changes: 8 additions & 5 deletions OpenDreamRuntime/Objects/Types/DreamObjectParticles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ public DreamObjectParticles(DreamObjectDefinition objectDefinition) : base(objec
if(!(kv.Key == "parent_type" || kv.Key == "type" || kv.Key == "vars"))
SetVar(kv.Key, kv.Value);
}
//check if I need to manually send update events to the component?
}

protected override void SetVar(string varName, DreamValue value) {
Expand Down Expand Up @@ -80,12 +79,16 @@ protected override void SetVar(string varName, DreamValue value) {
_icons.Clear();
if(value.TryGetValueAsDreamList(out var iconList)){
foreach(DreamValue iconValue in iconList.GetValues()){
if(iconValue.TryGetValueAsDreamObject<DreamObjectIcon>(out var icon)){
_icons.Add(AtomManager.MustGetAppearance(icon).ToMutable());
if(DreamResourceManager.TryLoadIcon(iconValue, out var iconRsc)) {
MutableAppearance iconAppearance = MutableAppearance.Get();
iconAppearance.Icon = iconRsc.Id;
_icons.Add(iconAppearance);
}
}
} else if(value.TryGetValueAsDreamObject<DreamObjectIcon>(out var dreamObjectIcon)) {
_icons.Add(AtomManager.MustGetAppearance(dreamObjectIcon).ToMutable());
} else if(DreamResourceManager.TryLoadIcon(value, out var iconRsc)) {
MutableAppearance iconAppearance = MutableAppearance.Get();
iconAppearance.Icon = iconRsc.Id;
_icons.Add(iconAppearance);
}
List<ImmutableAppearance> immutableAppearances = new();
foreach(var icon in _icons){
Expand Down

0 comments on commit 2aebbc9

Please sign in to comment.