@@ -15,7 +15,7 @@ function Create(self)
1515 self .activeSound = CreateSoundContainer (" Destroyer Emission Sound" , " Dummy.rte" );
1616end
1717
18- function Update (self )
18+ function ThreadedUpdate (self )
1919 if self .Magazine then
2020 if self .inventorySwapTimer :IsPastSimTimeLimit () then
2121 self .activeSound :Stop ();
@@ -28,18 +28,18 @@ function Update(self)
2828 self .animTimer :Reset ();
2929 self .Frame = self .Frame < (self .FrameCount - 1 ) and self .Frame + 1 or 0 ;
3030 if self .Frame == 1 then
31- local effect = CreateMOPixel (" Destroyer Muzzle Glow" );
32- effect .Pos = self .MuzzlePos ;
33- effect .Vel = self .Vel * 0.5 ;
34- MovableMan : AddParticle ( effect );
35-
36- local damagePar = CreateMOPixel ( " Dummy.rte/Destroyer Emission Particle 2 " ) ;
37- damagePar .Pos = self .MuzzlePos ;
38- damagePar .Vel = self .Vel * 0.5 + Vector ( math.random ( 5 ) * ( 1 + self . charge ), 0 ): RadRotate ( 6.28 * math.random ()) ;
39- damagePar .Team = self . Team ;
40- damagePar .IgnoresTeamHits = true ;
41- damagePar . Lifetime = 100 * ( 1 + self . charge );
42- MovableMan : AddParticle ( damagePar );
31+ self . effect = CreateMOPixel (" Destroyer Muzzle Glow" );
32+ self . effect .Pos = self .MuzzlePos ;
33+ self . effect .Vel = self .Vel * 0.5 ;
34+
35+ self . damagePar = CreateMOPixel ( " Dummy.rte/Destroyer Emission Particle 2 " );
36+ self . damagePar . Pos = self . MuzzlePos ;
37+ self . damagePar .Vel = self .Vel * 0.5 + Vector ( math.random ( 5 ) * ( 1 + self . charge ), 0 ): RadRotate ( 6.28 * math.random ()) ;
38+ self . damagePar .Team = self .Team ;
39+ self . damagePar .IgnoresTeamHits = true ;
40+ self . damagePar .Lifetime = 100 * ( 1 + self . charge ) ;
41+
42+ self : RequestSyncedUpdate ( );
4343 end
4444 end
4545
@@ -83,13 +83,14 @@ function Update(self)
8383 else
8484 self .Frame = 0 ;
8585 end
86+
8687 if self .FiredFrame then
87- local par = CreateAEmitter (" Destroyer Cannon Shot" );
88- par .Team = self .Team ;
89- par .IgnoresTeamHits = true ;
90- par .Pos = self .MuzzlePos ;
91- par .Vel = Vector ((self .minFireVel + (self .maxFireVel - self .minFireVel ) * self .charge ) * self .FlipFactor , 0 ):RadRotate (self .RotAngle );
92- MovableMan : AddParticle ( par );
88+ self . par = CreateAEmitter (" Destroyer Cannon Shot" );
89+ self . par .Team = self .Team ;
90+ self . par .IgnoresTeamHits = true ;
91+ self . par .Pos = self .MuzzlePos ;
92+ self . par .Vel = Vector ((self .minFireVel + (self .maxFireVel - self .minFireVel ) * self .charge ) * self .FlipFactor , 0 ):RadRotate (self .RotAngle );
93+ self : RequestSyncedUpdate ( );
9394
9495 self .charge = 0 ;
9596 self .activeSound :Stop ();
@@ -98,6 +99,23 @@ function Update(self)
9899 end
99100end
100101
102+ function SyncedUpdate (self )
103+ if self .effect then
104+ MovableMan :AddParticle (self .effect );
105+ self .effect = nil ;
106+ end
107+
108+ if self .damagePar then
109+ MovableMan :AddParticle (self .par );
110+ self .damagePar = nil ;
111+ end
112+
113+ if self .par then
114+ MovableMan :AddParticle (self .par );
115+ self .par = nil ;
116+ end
117+ end
118+
101119function Destroy (self )
102120 self .activeSound :Stop ();
103121end
0 commit comments