11
11
12
12
namespace Intersect . Client . Maps ;
13
13
14
-
15
- public partial class WeatherParticle : IWeatherParticle
14
+ public partial class WeatherParticle : IWeatherParticle , IDisposable
16
15
{
16
+ private readonly List < IWeatherParticle > _RemoveParticle ;
17
17
18
- private List < IWeatherParticle > _RemoveParticle ;
18
+ private readonly Animation animInstance ;
19
19
20
- private Animation animInstance ;
20
+ private readonly Rectangle bounds ;
21
21
22
- private Rectangle bounds ;
22
+ private readonly float cameraSpawnX ;
23
23
24
- private float cameraSpawnX ;
24
+ private readonly float cameraSpawnY ;
25
25
26
- private float cameraSpawnY ;
26
+ private readonly int originalX ;
27
27
28
- private int originalX ;
28
+ private readonly int originalY ;
29
29
30
- private int originalY ;
30
+ private readonly Point partSize ;
31
31
32
- private Point partSize ;
32
+ private readonly long TransmittionTimer ;
33
33
34
- private long TransmittionTimer ;
34
+ private readonly int xVelocity ;
35
35
36
- public float X { get ; set ; }
36
+ private readonly int yVelocity ;
37
37
38
- private int xVelocity ;
38
+ public float X { get ; set ; }
39
39
40
40
public float Y { get ; set ; }
41
41
42
- private int yVelocity ;
43
-
44
42
public WeatherParticle ( List < IWeatherParticle > RemoveParticle , int xvelocity , int yvelocity , AnimationDescriptor anim )
45
43
{
46
44
TransmittionTimer = Timing . Global . MillisecondsUtc ;
@@ -136,6 +134,10 @@ public void Update()
136
134
137
135
if ( ! newBounds . IntersectsWith ( new Rectangle ( ( int ) X , ( int ) Y , partSize . X , partSize . Y ) ) )
138
136
{
137
+ if ( _RemoveParticle . Contains ( this ) )
138
+ {
139
+ throw new Exception ( ) ;
140
+ }
139
141
_RemoveParticle . Add ( this ) ;
140
142
}
141
143
else
@@ -150,12 +152,34 @@ public void Update()
150
152
151
153
public void Dispose ( )
152
154
{
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
+
153
168
animInstance . Dispose ( ) ;
169
+ ReleaseManagedResources ( ) ;
154
170
}
155
171
156
- ~ WeatherParticle ( )
172
+ protected virtual void ReleaseManagedResources ( )
173
+ {
174
+ }
175
+
176
+ protected virtual void ReleaseUnmanagedResources ( )
157
177
{
158
- Dispose ( ) ;
178
+ // TODO release unmanaged resources here
159
179
}
160
180
181
+ ~ WeatherParticle ( )
182
+ {
183
+ Dispose ( false ) ;
184
+ }
161
185
}
0 commit comments