Skip to content

Commit

Permalink
Fix autogenerated component state stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
amylizzle committed Feb 20, 2025
1 parent 58950e8 commit 22c4f3d
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 214 deletions.
53 changes: 2 additions & 51 deletions OpenDreamClient/Rendering/ClientDreamParticlesSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,62 +24,13 @@ public sealed class ClientDreamParticlesSystem : SharedDreamParticlesSystem

public override void Initialize() {
base.Initialize();
SubscribeLocalEvent<DreamParticlesComponent, ComponentHandleState>(OnDreamParticlesComponentChange);
SubscribeLocalEvent<DreamParticlesComponent, AfterAutoHandleStateEvent>(OnDreamParticlesComponentChange);
SubscribeLocalEvent<DreamParticlesComponent, ComponentRemove>(HandleComponentRemove);
RenderTargetPool = new(_clyde);
}

private void OnDreamParticlesComponentChange(EntityUid uid, DreamParticlesComponent component, ref ComponentHandleState args)
private void OnDreamParticlesComponentChange(EntityUid uid, DreamParticlesComponent component, ref AfterAutoHandleStateEvent args)
{
if (args.Current is not DreamParticlesComponentState state)
return;
component.Width = state.Width;
component.Width = state.Width;
component.Height = state.Height;
component.Count = state.Count;
component.Spawning = state.Spawning;
component.Bound1 = state.Bound1;
component.Bound2 = state.Bound2;
component.Gravity = state.Gravity;
component.Gradient = state.Gradient;
component.Transform = state.Transform;
component.TextureList = state.TextureList;
component.LifespanHigh = state.LifespanHigh;
component.LifespanLow = state.LifespanLow;
component.LifespanType = state.LifespanType;
component.FadeInHigh = state.FadeInHigh;
component.FadeInLow = state.FadeInLow;
component.FadeInType = state.FadeInType;
component.FadeOutHigh = state.FadeOutHigh;
component.FadeOutLow = state.FadeOutLow;
component.FadeOutType = state.FadeOutType;
component.SpawnPositionHigh = state.SpawnPositionHigh;
component.SpawnPositionLow = state.SpawnPositionLow;
component.SpawnPositionType = state.SpawnPositionType;
component.SpawnVelocityHigh = state.SpawnVelocityHigh;
component.SpawnVelocityLow = state.SpawnVelocityLow;
component.SpawnVelocityType = state.SpawnVelocityType;
component.AccelerationHigh = state.AccelerationHigh;
component.AccelerationLow = state.AccelerationLow;
component.AccelerationType = state.AccelerationType;
component.FrictionHigh = state.FrictionHigh;
component.FrictionLow = state.FrictionLow;
component.FrictionType = state.FrictionType;
component.ScaleHigh = state.ScaleHigh;
component.ScaleLow = state.ScaleLow;
component.ScaleType = state.ScaleType;
component.RotationHigh = state.RotationHigh;
component.RotationLow = state.RotationLow;
component.RotationType = state.RotationType;
component.GrowthHigh = state.GrowthHigh;
component.GrowthLow = state.GrowthLow;
component.GrowthType = state.GrowthType;
component.SpinHigh = state.SpinHigh;
component.SpinLow = state.SpinLow;
component.SpinType = state.SpinType;
component.DriftHigh = state.DriftHigh;
component.DriftLow = state.DriftLow;
component.DriftType = state.DriftType;
if(_particlesManager.TryGetParticleSystem(uid, out var system))
system.UpdateSystem(GetParticleSystemArgs(component));
else
Expand Down
1 change: 1 addition & 0 deletions OpenDreamShared/OpenDreamShared.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@
<ProjectReference Include="..\RobustToolbox\Robust.Shared\Robust.Shared.csproj" />
</ItemGroup>
<Import Project="..\RobustToolbox\MSBuild\Robust.Properties.targets" />
<Import Project="..\RobustToolbox\MSBuild\Robust.CompNetworkGenerator.targets" />
</Project>
151 changes: 47 additions & 104 deletions OpenDreamShared/Rendering/DreamParticlesComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,116 +12,59 @@

namespace OpenDreamShared.Rendering;

[RegisterComponent, NetworkedComponent]
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState(true)]
public sealed partial class DreamParticlesComponent : Component {
[ViewVariables(VVAccess.ReadWrite)] public int Width;
[ViewVariables(VVAccess.ReadWrite)] public int Height;
[ViewVariables(VVAccess.ReadWrite)] public int Count;
[ViewVariables(VVAccess.ReadWrite)] public float Spawning;
[ViewVariables(VVAccess.ReadWrite)] public Vector3 Bound1;
[ViewVariables(VVAccess.ReadWrite)] public Vector3 Bound2;
[ViewVariables(VVAccess.ReadWrite)] public Vector3 Gravity;
[ViewVariables(VVAccess.ReadWrite)] public Color[] Gradient = [];
[ViewVariables(VVAccess.ReadWrite)] public Matrix3x2 Transform;
[ViewVariables(VVAccess.ReadWrite)] public ImmutableAppearance[] TextureList = [];
[ViewVariables(VVAccess.ReadWrite)] public float LifespanHigh;
[ViewVariables(VVAccess.ReadWrite)] public float LifespanLow;
[ViewVariables(VVAccess.ReadWrite)] public ParticlePropertyType LifespanType;
[ViewVariables(VVAccess.ReadWrite)] public int FadeInHigh;
[ViewVariables(VVAccess.ReadWrite)] public int FadeInLow;
[ViewVariables(VVAccess.ReadWrite)] public ParticlePropertyType FadeInType;
[ViewVariables(VVAccess.ReadWrite)] public int FadeOutHigh;
[ViewVariables(VVAccess.ReadWrite)] public int FadeOutLow;
[ViewVariables(VVAccess.ReadWrite)] public ParticlePropertyType FadeOutType;
[ViewVariables(VVAccess.ReadWrite), AutoNetworkedField] public int Width;
[ViewVariables(VVAccess.ReadWrite), AutoNetworkedField] public int Height;
[ViewVariables(VVAccess.ReadWrite), AutoNetworkedField] public int Count;
[ViewVariables(VVAccess.ReadWrite), AutoNetworkedField] public float Spawning;
[ViewVariables(VVAccess.ReadWrite), AutoNetworkedField] public Vector3 Bound1;
[ViewVariables(VVAccess.ReadWrite), AutoNetworkedField] public Vector3 Bound2;
[ViewVariables(VVAccess.ReadWrite), AutoNetworkedField] public Vector3 Gravity;
[ViewVariables(VVAccess.ReadWrite), AutoNetworkedField] public Color[] Gradient = [];
[ViewVariables(VVAccess.ReadWrite), AutoNetworkedField] public Matrix3x2 Transform;
[ViewVariables(VVAccess.ReadWrite), AutoNetworkedField] public ImmutableAppearance[] TextureList = [];
[ViewVariables(VVAccess.ReadWrite), AutoNetworkedField] public float LifespanHigh;
[ViewVariables(VVAccess.ReadWrite), AutoNetworkedField] public float LifespanLow;
[ViewVariables(VVAccess.ReadWrite), AutoNetworkedField] public ParticlePropertyType LifespanType;
[ViewVariables(VVAccess.ReadWrite), AutoNetworkedField] public int FadeInHigh;
[ViewVariables(VVAccess.ReadWrite), AutoNetworkedField] public int FadeInLow;
[ViewVariables(VVAccess.ReadWrite), AutoNetworkedField] public ParticlePropertyType FadeInType;
[ViewVariables(VVAccess.ReadWrite), AutoNetworkedField] public int FadeOutHigh;
[ViewVariables(VVAccess.ReadWrite), AutoNetworkedField] public int FadeOutLow;
[ViewVariables(VVAccess.ReadWrite), AutoNetworkedField] public ParticlePropertyType FadeOutType;

[ViewVariables(VVAccess.ReadWrite)] public Vector3 SpawnPositionHigh;
[ViewVariables(VVAccess.ReadWrite)] public Vector3 SpawnPositionLow;
[ViewVariables(VVAccess.ReadWrite)] public ParticlePropertyType SpawnPositionType;
[ViewVariables(VVAccess.ReadWrite), AutoNetworkedField] public Vector3 SpawnPositionHigh;
[ViewVariables(VVAccess.ReadWrite), AutoNetworkedField] public Vector3 SpawnPositionLow;
[ViewVariables(VVAccess.ReadWrite), AutoNetworkedField] public ParticlePropertyType SpawnPositionType;
//Starting velocity of the particles
[ViewVariables(VVAccess.ReadWrite)] public Vector3 SpawnVelocityHigh;
[ViewVariables(VVAccess.ReadWrite)] public Vector3 SpawnVelocityLow;
[ViewVariables(VVAccess.ReadWrite)] public ParticlePropertyType SpawnVelocityType;
[ViewVariables(VVAccess.ReadWrite), AutoNetworkedField] public Vector3 SpawnVelocityHigh;
[ViewVariables(VVAccess.ReadWrite), AutoNetworkedField] public Vector3 SpawnVelocityLow;
[ViewVariables(VVAccess.ReadWrite), AutoNetworkedField] public ParticlePropertyType SpawnVelocityType;
//Acceleration applied to the particles per second
[ViewVariables(VVAccess.ReadWrite)] public Vector3 AccelerationHigh;
[ViewVariables(VVAccess.ReadWrite)] public Vector3 AccelerationLow;
[ViewVariables(VVAccess.ReadWrite)] public ParticlePropertyType AccelerationType;
[ViewVariables(VVAccess.ReadWrite)] public Vector3 FrictionHigh;
[ViewVariables(VVAccess.ReadWrite)] public Vector3 FrictionLow;
[ViewVariables(VVAccess.ReadWrite)] public ParticlePropertyType FrictionType;
[ViewVariables(VVAccess.ReadWrite), AutoNetworkedField] public Vector3 AccelerationHigh;
[ViewVariables(VVAccess.ReadWrite), AutoNetworkedField] public Vector3 AccelerationLow;
[ViewVariables(VVAccess.ReadWrite), AutoNetworkedField] public ParticlePropertyType AccelerationType;
[ViewVariables(VVAccess.ReadWrite), AutoNetworkedField] public Vector3 FrictionHigh;
[ViewVariables(VVAccess.ReadWrite), AutoNetworkedField] public Vector3 FrictionLow;
[ViewVariables(VVAccess.ReadWrite), AutoNetworkedField] public ParticlePropertyType FrictionType;
//Scaling applied to the particles in (x,y)
[ViewVariables(VVAccess.ReadWrite)] public Vector2 ScaleHigh = Vector2.One;
[ViewVariables(VVAccess.ReadWrite)] public Vector2 ScaleLow = Vector2.One;
[ViewVariables(VVAccess.ReadWrite)] public ParticlePropertyType ScaleType;
[ViewVariables(VVAccess.ReadWrite), AutoNetworkedField] public Vector2 ScaleHigh = Vector2.One;
[ViewVariables(VVAccess.ReadWrite), AutoNetworkedField] public Vector2 ScaleLow = Vector2.One;
[ViewVariables(VVAccess.ReadWrite), AutoNetworkedField] public ParticlePropertyType ScaleType;
//Rotation applied to the particles in degrees
[ViewVariables(VVAccess.ReadWrite)] public float RotationHigh;
[ViewVariables(VVAccess.ReadWrite)] public float RotationLow;
[ViewVariables(VVAccess.ReadWrite)] public ParticlePropertyType RotationType;
[ViewVariables(VVAccess.ReadWrite), AutoNetworkedField] public float RotationHigh;
[ViewVariables(VVAccess.ReadWrite), AutoNetworkedField] public float RotationLow;
[ViewVariables(VVAccess.ReadWrite), AutoNetworkedField] public ParticlePropertyType RotationType;
//Increase in scale per second
[ViewVariables(VVAccess.ReadWrite)] public Vector2 GrowthHigh;
[ViewVariables(VVAccess.ReadWrite)] public Vector2 GrowthLow;
[ViewVariables(VVAccess.ReadWrite)] public ParticlePropertyType GrowthType;
[ViewVariables(VVAccess.ReadWrite), AutoNetworkedField] public Vector2 GrowthHigh;
[ViewVariables(VVAccess.ReadWrite), AutoNetworkedField] public Vector2 GrowthLow;
[ViewVariables(VVAccess.ReadWrite), AutoNetworkedField] public ParticlePropertyType GrowthType;
//Change in rotation per second
[ViewVariables(VVAccess.ReadWrite)] public float SpinHigh;
[ViewVariables(VVAccess.ReadWrite)] public float SpinLow;
[ViewVariables(VVAccess.ReadWrite)] public ParticlePropertyType SpinType;
[ViewVariables(VVAccess.ReadWrite)] public Vector3 DriftHigh;
[ViewVariables(VVAccess.ReadWrite)] public Vector3 DriftLow;
[ViewVariables(VVAccess.ReadWrite)] public ParticlePropertyType DriftType;
[Serializable, NetSerializable]
public sealed class DreamParticlesComponentState : ComponentState
{
public int Width;
public int Height;
public int Count;
public float Spawning;
public Vector3 Bound1;
public Vector3 Bound2;
public Vector3 Gravity;
public Color[] Gradient = [];
public Matrix3x2 Transform;
public ImmutableAppearance[] TextureList = [];
public float LifespanHigh;
public float LifespanLow;
public ParticlePropertyType LifespanType;
public int FadeInHigh;
public int FadeInLow;
public ParticlePropertyType FadeInType;
public int FadeOutHigh;
public int FadeOutLow;
public ParticlePropertyType FadeOutType;

public Vector3 SpawnPositionHigh;
public Vector3 SpawnPositionLow;
public ParticlePropertyType SpawnPositionType;
//Starting velocity of the particles
public Vector3 SpawnVelocityHigh;
public Vector3 SpawnVelocityLow;
public ParticlePropertyType SpawnVelocityType;
//Acceleration applied to the particles per second
public Vector3 AccelerationHigh;
public Vector3 AccelerationLow;
public ParticlePropertyType AccelerationType;
public Vector3 FrictionHigh;
public Vector3 FrictionLow;
public ParticlePropertyType FrictionType;
//Scaling applied to the particles in (x,y)
public Vector2 ScaleHigh;
public Vector2 ScaleLow;
public ParticlePropertyType ScaleType;
//Rotation applied to the particles in degrees
public float RotationHigh;
public float RotationLow;
public ParticlePropertyType RotationType;
//Increase in scale per second
public Vector2 GrowthHigh;
public Vector2 GrowthLow;
public ParticlePropertyType GrowthType;
//Change in rotation per second
public float SpinHigh;
public float SpinLow;
public ParticlePropertyType SpinType;
public Vector3 DriftHigh;
public Vector3 DriftLow;
public ParticlePropertyType DriftType;
}
[ViewVariables(VVAccess.ReadWrite), AutoNetworkedField] public float SpinHigh;
[ViewVariables(VVAccess.ReadWrite), AutoNetworkedField] public float SpinLow;
[ViewVariables(VVAccess.ReadWrite), AutoNetworkedField] public ParticlePropertyType SpinType;
[ViewVariables(VVAccess.ReadWrite), AutoNetworkedField] public Vector3 DriftHigh;
[ViewVariables(VVAccess.ReadWrite), AutoNetworkedField] public Vector3 DriftLow;
[ViewVariables(VVAccess.ReadWrite), AutoNetworkedField] public ParticlePropertyType DriftType;
}
60 changes: 1 addition & 59 deletions OpenDreamShared/Rendering/SharedDreamParticleSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,62 +5,4 @@

namespace OpenDreamShared.Rendering;

public abstract class SharedDreamParticlesSystem : EntitySystem {
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<DreamParticlesComponent, ComponentGetState>(GetCompState);
}
private void GetCompState(Entity<DreamParticlesComponent> ent, ref ComponentGetState args)
{
args.State = new DreamParticlesComponentState
{
Width = ent.Comp.Width,
Height = ent.Comp.Height,
Count = ent.Comp.Count,
Spawning = ent.Comp.Spawning,
Bound1 = ent.Comp.Bound1,
Bound2 = ent.Comp.Bound2,
Gravity = ent.Comp.Gravity,
Gradient = ent.Comp.Gradient,
Transform = ent.Comp.Transform,
TextureList = ent.Comp.TextureList,
LifespanHigh = ent.Comp.LifespanHigh,
LifespanLow = ent.Comp.LifespanLow,
LifespanType = ent.Comp.LifespanType,
FadeInHigh = ent.Comp.FadeInHigh,
FadeInLow = ent.Comp.FadeInLow,
FadeInType = ent.Comp.FadeInType,
FadeOutHigh = ent.Comp.FadeOutHigh,
FadeOutLow = ent.Comp.FadeOutLow,
FadeOutType = ent.Comp.FadeOutType,
SpawnPositionHigh = ent.Comp.SpawnPositionHigh,
SpawnPositionLow = ent.Comp.SpawnPositionLow,
SpawnPositionType = ent.Comp.SpawnPositionType,
SpawnVelocityHigh = ent.Comp.SpawnVelocityHigh,
SpawnVelocityLow = ent.Comp.SpawnVelocityLow,
SpawnVelocityType = ent.Comp.SpawnVelocityType,
AccelerationHigh = ent.Comp.AccelerationHigh,
AccelerationLow = ent.Comp.AccelerationLow,
AccelerationType = ent.Comp.AccelerationType,
FrictionHigh = ent.Comp.FrictionHigh,
FrictionLow = ent.Comp.FrictionLow,
FrictionType = ent.Comp.FrictionType,
ScaleHigh = ent.Comp.ScaleHigh,
ScaleLow = ent.Comp.ScaleLow,
ScaleType = ent.Comp.ScaleType,
RotationHigh = ent.Comp.RotationHigh,
RotationLow = ent.Comp.RotationLow,
RotationType = ent.Comp.RotationType,
GrowthHigh = ent.Comp.GrowthHigh,
GrowthLow = ent.Comp.GrowthLow,
GrowthType = ent.Comp.GrowthType,
SpinHigh = ent.Comp.SpinHigh,
SpinLow = ent.Comp.SpinLow,
SpinType = ent.Comp.SpinType,
DriftHigh = ent.Comp.DriftHigh,
DriftLow = ent.Comp.DriftLow,
DriftType = ent.Comp.DriftType
};
}
}
public abstract class SharedDreamParticlesSystem : EntitySystem {}

0 comments on commit 22c4f3d

Please sign in to comment.