@@ -37,16 +37,17 @@ import CrocSkimmer from "./Projectile/CrocSkimmer";
3737import { BarrelAddon , BarrelAddonById } from "./BarrelAddons" ;
3838import { Swarm } from "./Projectile/Swarm" ;
3939import NecromancerSquare from "./Projectile/NecromancerSquare" ;
40+
4041/**
4142 * Class that determines when barrels can shoot, and when they can't.
4243 */
4344export class ShootCycle {
4445 /** The barrel this cycle is keeping track of. */
45- private barrelEntity : Barrel ;
46+ public barrelEntity : Barrel ;
4647 /** The current position in the cycle. */
47- private pos : number ;
48+ public pos : number ;
4849 /** The last known reload time of the barrel. */
49- private reloadTime : number ;
50+ public reloadTime : number ;
5051
5152 public constructor ( barrel : Barrel ) {
5253 this . barrelEntity = barrel ;
@@ -56,11 +57,6 @@ export class ShootCycle {
5657
5758 public tick ( ) {
5859 const reloadTime = this . barrelEntity . tank . reloadTime * this . barrelEntity . definition . reload ;
59- if ( reloadTime !== this . reloadTime ) {
60- this . pos *= reloadTime / this . reloadTime ;
61- this . reloadTime = this . barrelEntity . barrelData . reloadTime = reloadTime ;
62- }
63-
6460 const alwaysShoot = ( this . barrelEntity . definition . forceFire ) || ( this . barrelEntity . definition . bullet . type === "drone" ) || ( this . barrelEntity . definition . bullet . type === "minion" ) ;
6561
6662 if ( this . pos >= reloadTime ) {
@@ -143,7 +139,7 @@ export default class Barrel extends ObjectEntity {
143139 this . barrelData . values . trapezoidDirection = barrelDefinition . trapezoidDirection ;
144140 this . shootCycle = new ShootCycle ( this ) ;
145141
146- this . bulletAccel = ( 20 + ( owner . cameraEntity . cameraData ?. values . statLevels . values [ Stat . BulletSpeed ] || 0 ) * 3 ) * barrelDefinition . bullet . speed ;
142+ this . calculateStatData ( ) ;
147143 }
148144
149145 /** Shoots a bullet from the barrel. */
@@ -214,9 +210,19 @@ export default class Barrel extends ObjectEntity {
214210 if ( this . definition . bullet . color ) projectile . styleData . values . color = this . definition . bullet . color ;
215211 }
216212 }
213+
214+ public calculateStatData ( ) {
215+ const reloadTime = this . tank . reloadTime * this . definition . reload ;
216+
217+ if ( reloadTime !== this . shootCycle . reloadTime ) {
218+ this . shootCycle . pos *= reloadTime / this . shootCycle . reloadTime ;
219+ this . shootCycle . reloadTime = this . barrelData . reloadTime = reloadTime ;
220+ }
221+
222+ this . bulletAccel = ( 20 + ( this . tank . cameraEntity . cameraData ?. values . statLevels . values [ Stat . BulletSpeed ] || 0 ) * 3 ) * this . definition . bullet . speed ;
223+ }
217224
218225 public tick ( tick : number ) {
219- this . bulletAccel = ( 20 + ( this . tank . cameraEntity . cameraData ?. values . statLevels . values [ Stat . BulletSpeed ] || 0 ) * 3 ) * this . definition . bullet . speed ;
220226 this . relationsData . values . team = this . tank . relationsData . values . team ;
221227
222228 if ( ! this . tank . rootParent . deletionAnimation ) {
0 commit comments