Skip to content

Remove sizeFactor, add entity scaling function instead#188

Merged
c86ec23b-fef1-4979-b2fa-b9adc351b8cc merged 8 commits intomainfrom
stats
Feb 11, 2026
Merged

Remove sizeFactor, add entity scaling function instead#188
c86ec23b-fef1-4979-b2fa-b9adc351b8cc merged 8 commits intomainfrom
stats

Conversation

@c86ec23b-fef1-4979-b2fa-b9adc351b8cc
Copy link
Collaborator

Should be faster? also probably more consistent with everything else

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR replaces the camera/tank “sizeFactor” pattern with an entity-level scaling mechanism (scaleFactor + scale()), aiming to make size updates more consistent and reduce per-tick recomputation.

Changes:

  • Removed CameraEntity.sizeFactor and migrated size math to ObjectEntity.scale() / scaleFactor, updating usages across tanks, barrels, bullets, addons, and factory spawning.
  • Refactored barrel/projectile scaling behavior (notably Rocket/Skimmer) to work with scale() rather than sizeFactor getters.
  • Adjusted a few gameplay/visibility behaviors (camera entity visibility filtering, drone AI view range, initial AI mouse position).

Reviewed changes

Copilot reviewed 25 out of 25 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/Native/Camera.ts Removes camera sizeFactor logic; scales player entity on level changes; tweaks invisible-entity send filter.
src/Native/Arena.ts Uses scaleFactor for factory tank spawn offset calculations.
src/Gamemodes/Misc/FactoryTest.ts Updates factory test offsets to use scaleFactor.
src/Entity/Tank/TankBody.ts Removes sizeFactor getter and per-tick size updates; relies on scale() + scaleFactor.
src/Entity/Tank/Projectile/Skimmer.ts Updates skimmer projectile scaling and barrel width behavior via scale() override.
src/Entity/Tank/Projectile/Rocket.ts Updates rocket projectile scaling + barrel width behavior; adjusts rocket barrel definition width.
src/Entity/Tank/Projectile/Minion.ts Initializes scaleFactor for minion projectile; removes sizeFactor getter.
src/Entity/Tank/Projectile/Drone.ts Removes size-dependent view range; uses constant view range.
src/Entity/Tank/Projectile/Bullet.ts Uses tank.scaleFactor for spawn offsets instead of sizeFactor.
src/Entity/Tank/Barrel.ts Switches barrel sizing math to scaleFactor; removes per-tick resize logic.
src/Entity/Tank/AutoTurret.ts Removes turret sizeFactor getter; ties turret scaling to owner/root scaling.
src/Entity/Tank/Addons.ts Updates addon sizing/rotation behavior to rely on scaling instead of per-tick recompute; guard uses scaleFactor.
src/Entity/Object.ts Adds scaleFactor field and scale() method; deletion animation now uses scale().
src/Entity/Misc/Mothership.ts Reorders setup so camera player is assigned before setLevel() scaling.
src/Entity/Misc/Dominator.ts Reworks dominator scaling and level setup around scale()/scaleFactor.
src/Entity/Misc/Boss/FallenSpike.ts Applies level-75 size via scale() instead of relying on initial boss sizing.
src/Entity/Misc/Boss/FallenMegaTrapper.ts Applies level-75 size via scale().
src/Entity/Misc/Boss/FallenAC.ts Applies level-75 size via scale().
src/Entity/Misc/BaseDrones.ts Removes sizeFactor hack; compensates by changing drone spawner barrel definition sizing.
src/Entity/Misc/ArenaCloser.ts Reworks arena closer scaling + level setup around scale()/scaleFactor.
src/Entity/Boss/FallenOverlord.ts Applies level-75 size via scale(); removes sizeFactor getter usage pattern.
src/Entity/Boss/FallenBooster.ts Applies level-75 size via scale(); removes sizeFactor getter usage pattern.
src/Entity/Boss/Defender.ts Removes sizeFactor logic usage; minor stat tweaks and cleanup.
src/Entity/Boss/AbstractBoss.ts Stops pre-scaling bosses in base constructor; relies on derived bosses to call scale() as needed.
src/Entity/AI.ts Changes initial AI mouse x coordinate from 20 to 0.
Comments suppressed due to low confidence (1)

src/Entity/Tank/Projectile/Bullet.ts:78

  • Bullet instances never initialize their own scaleFactor, but some projectiles (e.g. those that implement BarrelBase and spawn child Barrels) rely on this.scaleFactor for correct barrel sizing now that sizeFactor is removed. Right now this is handled ad-hoc in some derived constructors (Rocket/Skimmer/Minion), which makes it easy to miss cases and can produce incorrectly sized child barrels. Consider initializing this.scaleFactor in the base Bullet constructor based on the computed bullet size (or otherwise enforcing/centralizing the contract for BarrelBase implementers) so all barrel-spawning projectiles behave consistently.
        const bulletDefinition = barrel.definition.bullet;
        const scaleFactor = tank.scaleFactor;
        const statLevels = tank.cameraEntity.cameraData?.values.statLevels.values;

        this.relationsData.values.team = barrel.relationsData.values.team;
        this.relationsData.values.owner = tank;

        this.physicsData.values.sides = 1;
        this.physicsData.values.flags |= PhysicsFlags.noOwnTeamCollision | PhysicsFlags.canEscapeArena;
        if (tank.positionData.values.flags & PositionFlags.canMoveThroughWalls) this.positionData.values.flags |= PositionFlags.canMoveThroughWalls
        this.physicsData.values.size = (barrel.physicsData.values.width / 2) * bulletDefinition.sizeRatio;
        this.styleData.values.color = tank.rootParent.styleData.values.color;

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +40 to 47
super(game, camera, inputs);

camera.cameraData.values.player = this;
camera.setLevel(300);
camera.sizeFactor = (ArenaCloser.BASE_SIZE / 50);

super(game, camera, inputs);
this.scaleFactor = 1;
this.scale(ArenaCloser.BASE_SIZE / this.baseSize);

Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to Dominator: camera.setLevel(300) currently runs after player is set, which scales the initial Basic tank body/barrels and is then immediately followed by resetting scaleFactor/rescales and setTank(Tank.ArenaCloser). If the intent is to set stats/level without applying that level-based scaling to the body, consider calling setLevel() before assigning player (or otherwise skipping the initial scale) to avoid extra scaling and transient inconsistent state.

Copilot uses AI. Check for mistakes.
Comment on lines 218 to 224
/** Resizes the barrel; when the tank gets bigger, the barrel must as well. */
protected resize() {
const sizeFactor = this.tank.sizeFactor;
const size = this.physicsData.size = this.definition.size * sizeFactor;

this.physicsData.width = this.definition.width * sizeFactor;
this.positionData.angle = this.definition.angle + (this.definition.trapezoidDirection);
this.positionData.x = Math.cos(this.definition.angle) * (size / 2 + (this.definition.distance || 0)) - Math.sin(this.definition.angle) * this.definition.offset * sizeFactor;
this.positionData.y = Math.sin(this.definition.angle) * (size / 2 + (this.definition.distance || 0)) + Math.cos(this.definition.angle) * this.definition.offset * sizeFactor;

// Updates bullet accel too
this.bulletAccel = (20 + (this.tank.cameraEntity.cameraData?.values.statLevels.values[Stat.BulletSpeed] || 0) * 3) * this.definition.bullet.speed;
}

public tick(tick: number) {
this.resize();

this.bulletAccel = (20 + (this.tank.cameraEntity.cameraData?.values.statLevels.values[Stat.BulletSpeed] || 0) * 3) * this.definition.bullet.speed;
this.relationsData.values.team = this.tank.relationsData.values.team;
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resize() is now empty but still present, and tick() contains an oddly indented bulletAccel assignment. If resizing is fully replaced by the new scale() flow, consider removing resize() (and any related call sites) and cleaning up the tick() formatting to avoid leaving dead/placeholder code that looks like an incomplete refactor.

Copilot uses AI. Check for mistakes.
Comment on lines +59 to +66
super(arena.game, camera, inputs);

camera.cameraData.values.player = this;
camera.setLevel(75);
camera.sizeFactor = (Dominator.SIZE / 50);

super(arena.game, camera, inputs);
this.scaleFactor = 1;
this.scale(Dominator.SIZE / this.baseSize);

Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This constructor calls camera.setLevel(75) after assigning camera.cameraData.values.player = this, which triggers a scale of the temporary Basic tank body/barrels, and then immediately resets scaleFactor / rescales again before setTank(). Since the level is only used for stats here (and is above maxPlayerLevel anyway), consider reordering so setLevel() happens before assigning player (or otherwise avoiding the initial scale) to prevent redundant scaling work and transient inconsistent scaleFactor/size state.

Copilot uses AI. Check for mistakes.
// It's weird, but it's how it works
sizeRatio *= Math.SQRT1_2
this.sizeRatio = sizeRatio;
scaleFactor *= Math.SQRT1_2
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid automated semicolon insertion (93% of all statements in the enclosing function have an explicit semicolon).

Suggested change
scaleFactor *= Math.SQRT1_2
scaleFactor *= Math.SQRT1_2;

Copilot uses AI. Check for mistakes.
Removed unused resize method from Barrel class.
@abcxff abcxff self-requested a review February 10, 2026 16:04
abcxff
abcxff previously approved these changes Feb 10, 2026
@abcxff abcxff self-requested a review February 10, 2026 22:25
@c86ec23b-fef1-4979-b2fa-b9adc351b8cc c86ec23b-fef1-4979-b2fa-b9adc351b8cc merged commit 3d83b0e into main Feb 11, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants