-
Notifications
You must be signed in to change notification settings - Fork 91
Remove sizeFactor, add entity scaling function instead #188
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
35da093
7f0dc64
d8ceca0
8c74cd9
5dc2157
d41a052
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,24 +16,31 @@ | |
| along with this program. If not, see <https://www.gnu.org/licenses/> | ||
| */ | ||
|
|
||
| import { Color, ColorsHexCode, NameFlags, StyleFlags, EntityTags, Tank, ClientBound } from "../../Const/Enums"; | ||
| import ArenaEntity from "../../Native/Arena"; | ||
| import ClientCamera, { CameraEntity } from "../../Native/Camera"; | ||
|
|
||
| import { Entity } from "../../Native/Entity"; | ||
| import { AI, AIState, Inputs } from "../AI"; | ||
|
|
||
| import ObjectEntity from "../Object"; | ||
| import LivingEntity from "../Live"; | ||
| import Bullet from "../Tank/Projectile/Bullet"; | ||
| import TankBody from "../Tank/TankBody"; | ||
| import TeamBase from "./TeamBase"; | ||
|
|
||
| import { TeamEntity } from "./TeamEntity"; | ||
| import { Color, ColorsHexCode, NameFlags, StyleFlags, EntityTags, Tank, ClientBound } from "../../Const/Enums"; | ||
| import { randomFrom } from "../../util"; | ||
|
|
||
| /** | ||
| * Dominator Tank | ||
| */ | ||
| export default class Dominator extends TankBody { | ||
| /** Size of a dominator */ | ||
| public static SIZE = 160; | ||
|
|
||
| /** All dominator tank classes */ | ||
| public static DOMINATOR_CLASSES: Tank[] = [Tank.DominatorD, Tank.DominatorG, Tank.DominatorT]; | ||
|
|
||
| /** The AI that controls how the Dominator aims. */ | ||
| public ai: AI; | ||
|
|
@@ -44,22 +51,20 @@ export default class Dominator extends TankBody { | |
| public prefix: string | null = ""; | ||
|
|
||
| public constructor(arena: ArenaEntity, base: TeamBase, pTankId: Tank | null = null) { | ||
| let tankId: Tank; | ||
| if (pTankId === null) { | ||
| const r = Math.random() * 3; | ||
|
|
||
| if (r < 1) tankId = Tank.DominatorD; | ||
| else if (r < 2) tankId = Tank.DominatorG; | ||
| else tankId = Tank.DominatorT; | ||
| } else tankId = pTankId; | ||
| const tankId = pTankId || randomFrom(Dominator.DOMINATOR_CLASSES); | ||
|
|
||
| const inputs = new Inputs(); | ||
| const camera = new CameraEntity(arena.game); | ||
|
|
||
| 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); | ||
|
|
||
|
Comment on lines
+59
to
+66
|
||
| this.setTank(tankId); | ||
|
|
||
| this.relationsData.values.team = arena; | ||
| this.physicsData.values.size = Dominator.SIZE; | ||
|
|
@@ -73,7 +78,6 @@ export default class Dominator extends TankBody { | |
| this.ai.viewRange = 2000; | ||
| this.ai.doAimPrediction = true; | ||
|
|
||
| this.setTank(tankId); | ||
| const def = (this.definition = Object.assign({}, this.definition)); | ||
| def.speed = camera.cameraData.values.movementSpeed = 0; | ||
| this.nameData.values.name = "Dominator"; | ||
|
|
@@ -118,7 +122,7 @@ export default class Dominator extends TankBody { | |
| this.styleData.color = killerTeam.teamData.values.teamColor | ||
| this.game.broadcast() | ||
| .u8(ClientBound.Notification) | ||
| .stringNT(`The ${this.prefix}${this.nameData.values.name} is now controlled by ${killerTeam.teamName}`) | ||
| .stringNT(`The ${this.prefix}${this.nameData.values.name} is now controlled by ${killerTeam.teamName || "a mysterious group"}`) | ||
| .u32(ColorsHexCode[killerTeam.teamData.values.teamColor]) | ||
| .float(7500) | ||
| .stringNT("").send(); | ||
|
|
@@ -127,9 +131,12 @@ export default class Dominator extends TankBody { | |
| const camera = client.camera; | ||
| if (!camera) continue; | ||
|
|
||
| if (camera.relationsData.values.team === this.relationsData.values.team) client.notify(`Press H to take control of the ${this.nameData.values.name}`, ColorsHexCode[killerTeam.teamData.values.teamColor]) | ||
| if (camera.relationsData.values.team === this.relationsData.values.team) { | ||
| client.notify(`Press H to take control of the ${this.nameData.values.name}`, ColorsHexCode[killerTeam.teamData.values.teamColor]); | ||
| } | ||
| } | ||
| } else { | ||
| // set to neutral team | ||
| this.relationsData.team = this.game.arena | ||
| this.styleData.color = this.game.arena.teamData.teamColor; | ||
|
|
||
|
|
@@ -142,7 +149,7 @@ export default class Dominator extends TankBody { | |
| } | ||
|
|
||
| this.base.styleData.color = this.styleData.values.color; | ||
| this.base.relationsData.team = this.relationsData.values.team;; | ||
| this.base.relationsData.team = this.relationsData.values.team; | ||
|
|
||
| this.healthData.health = this.healthData.values.maxHealth; | ||
|
|
||
|
|
||
There was a problem hiding this comment.
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 afterplayeris set, which scales the initial Basic tank body/barrels and is then immediately followed by resettingscaleFactor/rescales andsetTank(Tank.ArenaCloser). If the intent is to set stats/level without applying that level-based scaling to the body, consider callingsetLevel()before assigningplayer(or otherwise skipping the initial scale) to avoid extra scaling and transient inconsistent state.