1111
1212namespace Intersect . Client . Maps ;
1313
14-
15- public partial class WeatherParticle : IWeatherParticle
14+ public partial class WeatherParticle : IWeatherParticle , IDisposable
1615{
16+ private readonly List < IWeatherParticle > _RemoveParticle ;
1717
18- private List < IWeatherParticle > _RemoveParticle ;
18+ private readonly Animation animInstance ;
1919
20- private Animation animInstance ;
20+ private readonly Rectangle bounds ;
2121
22- private Rectangle bounds ;
22+ private readonly float cameraSpawnX ;
2323
24- private float cameraSpawnX ;
24+ private readonly float cameraSpawnY ;
2525
26- private float cameraSpawnY ;
26+ private readonly int originalX ;
2727
28- private int originalX ;
28+ private readonly int originalY ;
2929
30- private int originalY ;
30+ private readonly Point partSize ;
3131
32- private Point partSize ;
32+ private readonly long TransmittionTimer ;
3333
34- private long TransmittionTimer ;
34+ private readonly int xVelocity ;
3535
36- public float X { get ; set ; }
36+ private readonly int yVelocity ;
3737
38- private int xVelocity ;
38+ public float X { get ; set ; }
3939
4040 public float Y { get ; set ; }
4141
42- private int yVelocity ;
43-
4442 public WeatherParticle ( List < IWeatherParticle > RemoveParticle , int xvelocity , int yvelocity , AnimationDescriptor anim )
4543 {
4644 TransmittionTimer = Timing . Global . MillisecondsUtc ;
@@ -136,6 +134,10 @@ public void Update()
136134
137135 if ( ! newBounds . IntersectsWith ( new Rectangle ( ( int ) X , ( int ) Y , partSize . X , partSize . Y ) ) )
138136 {
137+ if ( _RemoveParticle . Contains ( this ) )
138+ {
139+ throw new Exception ( ) ;
140+ }
139141 _RemoveParticle . Add ( this ) ;
140142 }
141143 else
@@ -150,12 +152,34 @@ public void Update()
150152
151153 public void Dispose ( )
152154 {
155+ Dispose ( true ) ;
156+ GC . SuppressFinalize ( this ) ;
157+ }
158+
159+ private void Dispose ( bool disposing )
160+ {
161+ ReleaseUnmanagedResources ( ) ;
162+
163+ if ( ! disposing )
164+ {
165+ return ;
166+ }
167+
153168 animInstance . Dispose ( ) ;
169+ ReleaseManagedResources ( ) ;
154170 }
155171
156- ~ WeatherParticle ( )
172+ protected virtual void ReleaseManagedResources ( )
173+ {
174+ }
175+
176+ protected virtual void ReleaseUnmanagedResources ( )
157177 {
158- Dispose ( ) ;
178+ // TODO release unmanaged resources here
159179 }
160180
181+ ~ WeatherParticle ( )
182+ {
183+ Dispose ( false ) ;
184+ }
161185}
0 commit comments