From 7ac00d0aaf39d5044440686d4d0c5867d12f1dc7 Mon Sep 17 00:00:00 2001 From: MEEPofFaith <54301439+MEEPofFaith@users.noreply.github.com> Date: Wed, 24 Aug 2022 10:48:06 -0700 Subject: [PATCH] Move `damageMultiplier` to `BulletType` (#7436) * Move bullet damage multiplier to bulletType * Is this better? I don't know much about optimization, is this any better than before? * Revert "Is this better?" This reverts commit b83723701f0e03625a229089613676c0a4522fba. --- core/src/mindustry/entities/bullet/BulletType.java | 7 +++++++ core/src/mindustry/entities/comp/BulletComp.java | 5 +---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/core/src/mindustry/entities/bullet/BulletType.java b/core/src/mindustry/entities/bullet/BulletType.java index 28bb749951..9a43f5a001 100644 --- a/core/src/mindustry/entities/bullet/BulletType.java +++ b/core/src/mindustry/entities/bullet/BulletType.java @@ -364,6 +364,13 @@ public class BulletType extends Content implements Cloneable{ } } + public float damageMultiplier(Bullet b){ + if(b.owner instanceof Unit u) return u.damageMultiplier() * state.rules.unitDamage(b.team); + if(b.owner instanceof Building) return state.rules.blockDamage(b.team); + + return 1f; + } + public void hit(Bullet b){ hit(b, b.x, b.y); } diff --git a/core/src/mindustry/entities/comp/BulletComp.java b/core/src/mindustry/entities/comp/BulletComp.java index 813b3979f0..32375d2ef7 100644 --- a/core/src/mindustry/entities/comp/BulletComp.java +++ b/core/src/mindustry/entities/comp/BulletComp.java @@ -82,10 +82,7 @@ abstract class BulletComp implements Timedc, Damagec, Hitboxc, Teamc, Posc, Draw @Override public float damageMultiplier(){ - if(owner instanceof Unit u) return u.damageMultiplier() * state.rules.unitDamage(team); - if(owner instanceof Building) return state.rules.blockDamage(team); - - return 1f; + return type.damageMultiplier(self()); } @Override