From b0d65dcedb26014580632a9b0d8d597f0c7f8ccc Mon Sep 17 00:00:00 2001 From: DeltaNedas <39013340+DeltaNedas@users.noreply.github.com> Date: Tue, 7 Jan 2020 14:30:18 +0000 Subject: [PATCH] let mechs override drawStats and do custom power cell stuff (#1309) * let mechs override drawStats and do custom power cell stuff * Update Player.java * Update Mech.java * Update Player.java --- core/src/mindustry/entities/type/Player.java | 10 +++---- core/src/mindustry/type/Mech.java | 29 +++++++++++++++++++- 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/core/src/mindustry/entities/type/Player.java b/core/src/mindustry/entities/type/Player.java index 6f28acb17c..af1c2e5d8b 100644 --- a/core/src/mindustry/entities/type/Player.java +++ b/core/src/mindustry/entities/type/Player.java @@ -350,13 +350,13 @@ public class Player extends Unit implements BuilderMinerTrait, ShooterTrait{ Draw.reset(); } + public void drawBackItems(){ + drawBackItems(itemtime, isLocal); + } + @Override public void drawStats(){ - Draw.color(Color.black, team.color, healthf() + Mathf.absin(Time.time(), healthf() * 5f, 1f - healthf())); - Draw.rect(getPowerCellRegion(), x + Angles.trnsx(rotation, mech.cellTrnsY, 0f), y + Angles.trnsy(rotation, mech.cellTrnsY, 0f), rotation - 90); - Draw.reset(); - drawBackItems(itemtime, isLocal); - drawLight(); + mech.drawStats(this); } @Override diff --git a/core/src/mindustry/type/Mech.java b/core/src/mindustry/type/Mech.java index 49745ba129..d9ac986df2 100644 --- a/core/src/mindustry/type/Mech.java +++ b/core/src/mindustry/type/Mech.java @@ -2,9 +2,11 @@ package mindustry.type; import arc.Core; import arc.graphics.Color; -import arc.graphics.g2d.TextureRegion; +import arc.graphics.g2d.*; +import arc.math.*; import arc.scene.ui.layout.Table; import arc.util.ArcAnnotate.*; +import arc.util.Time; import mindustry.ctype.ContentType; import mindustry.entities.type.Player; import mindustry.ctype.UnlockableContent; @@ -32,6 +34,13 @@ public class Mech extends UnlockableContent{ public boolean canHeal = false; public float compoundSpeed, compoundSpeedBoost; + /** draw the health and team indicator */ + public boolean drawCell = true; + /** draw the items on its back */ + public boolean drawItems = true; + /** draw the engine light if it's flying/boosting */ + public boolean drawLight = true; + public float weaponOffsetX, weaponOffsetY, engineOffset = 5f, engineSize = 2.5f; public @NonNull Weapon weapon; @@ -52,6 +61,24 @@ public class Mech extends UnlockableContent{ public void draw(Player player){ } + public void drawStats(Player player){ + if(drawCell){ + float health = player.healthf(); + Draw.color(Color.black, player.getTeam().color, health + Mathf.absin(Time.time(), health * 5f, 1f - health)); + Draw.rect(player.getPowerCellRegion(), + player.x + Angles.trnsx(player.rotation, cellTrnsY, 0f), + player.y + Angles.trnsy(player.rotation, cellTrnsY, 0f), + player.rotation - 90); + Draw.reset(); + } + if(drawItems){ + player.drawBackItems(); + } + if(drawLight){ + player.drawLight(); + } + } + public float getExtraArmor(Player player){ return 0f; }