Skip to content

Commit

Permalink
Merge pull request #1702 from BenjaminUrquhart/psys-fix
Browse files Browse the repository at this point in the history
Add GlobalSpaceParticles field to Particle Systems (2023.8+)
  • Loading branch information
Miepee authored Mar 1, 2024
2 parents 3d5c24c + 0a138c3 commit c58373a
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions UndertaleModLib/Models/UndertaleParticleSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ public class UndertaleParticleSystem : UndertaleNamedResource, IDisposable

public int DrawOrder { get; set; }

public bool GlobalSpaceParticles { get; set; }

public UndertaleSimpleResourcesList<UndertaleParticleSystemEmitter, UndertaleChunkPSEM> Emitters { get; set; } = new();

/// <inheritdoc />
Expand All @@ -25,6 +27,8 @@ public void Serialize(UndertaleWriter writer)
writer.Write(OriginX);
writer.Write(OriginY);
writer.Write(DrawOrder);
if (writer.undertaleData.IsVersionAtLeast(2023, 8))
writer.Write(GlobalSpaceParticles);
writer.WriteUndertaleObject(Emitters);
}

Expand All @@ -35,6 +39,8 @@ public void Unserialize(UndertaleReader reader)
OriginX = reader.ReadInt32();
OriginY = reader.ReadInt32();
DrawOrder = reader.ReadInt32();
if (reader.undertaleData.IsVersionAtLeast(2023, 8))
GlobalSpaceParticles = reader.ReadBoolean();
Emitters = reader.ReadUndertaleObject<UndertaleSimpleResourcesList<UndertaleParticleSystemEmitter, UndertaleChunkPSEM>>();
}

Expand All @@ -43,6 +49,9 @@ public static uint UnserializeChildObjectCount(UndertaleReader reader)
{
reader.Position += 16;

if (reader.undertaleData.IsVersionAtLeast(2023, 8))
reader.Position += 4;

return 1 + UndertaleSimpleResourcesList<UndertaleParticleSystemEmitter, UndertaleChunkPSEM>.UnserializeChildObjectCount(reader);
}

Expand Down

0 comments on commit c58373a

Please sign in to comment.