From ca4f710ec2ef7a948f18ece6b515fb1f71480dc4 Mon Sep 17 00:00:00 2001 From: Anuken Date: Tue, 4 Oct 2022 15:58:40 -0400 Subject: [PATCH] Bullet parts / Improved clipping in #7282 --- core/assets/bundles/bundle.properties | 2 +- .../mindustry/entities/bullet/BulletType.java | 15 +++++++++ core/src/mindustry/graphics/Trail.java | 2 +- .../mindustry/maps/filters/MirrorFilter.java | 32 +------------------ 4 files changed, 18 insertions(+), 33 deletions(-) diff --git a/core/assets/bundles/bundle.properties b/core/assets/bundles/bundle.properties index cffae5e7f3..1a569c9eb5 100644 --- a/core/assets/bundles/bundle.properties +++ b/core/assets/bundles/bundle.properties @@ -1169,7 +1169,7 @@ rules.cleanupdeadteams = Clean Up Defeated Team Buildings (PvP) rules.corecapture = Capture Core On Destruction rules.polygoncoreprotection = Polygonal Core Protection rules.placerangecheck = Placement Range Check -rules.enemyCheat = Infinite AI (Red Team) Resources +rules.enemyCheat = Infinite Enemy Team Resources rules.blockhealthmultiplier = Block Health Multiplier rules.blockdamagemultiplier = Block Damage Multiplier rules.unitbuildspeedmultiplier = Unit Production Speed Multiplier diff --git a/core/src/mindustry/entities/bullet/BulletType.java b/core/src/mindustry/entities/bullet/BulletType.java index 9a43f5a001..e285488d41 100644 --- a/core/src/mindustry/entities/bullet/BulletType.java +++ b/core/src/mindustry/entities/bullet/BulletType.java @@ -14,6 +14,7 @@ import mindustry.annotations.Annotations.*; import mindustry.content.*; import mindustry.ctype.*; import mindustry.entities.*; +import mindustry.entities.part.*; import mindustry.game.EventType.*; import mindustry.game.*; import mindustry.gen.*; @@ -190,6 +191,8 @@ public class BulletType extends Content implements Cloneable{ public int despawnUnitCount = 1; /** Random offset distance from the original bullet despawn/hit coordinate. */ public float despawnUnitRadius = 0.1f; + /** Extra visual parts for this bullet. */ + public Seq parts = new Seq<>(); /** Color of trail behind bullet. */ public Color trailColor = Pal.missileYellowBack; @@ -481,6 +484,7 @@ public class BulletType extends Content implements Cloneable{ public void draw(Bullet b){ drawTrail(b); + drawParts(b); } public void drawTrail(Bullet b){ @@ -493,6 +497,17 @@ public class BulletType extends Content implements Cloneable{ } } + public void drawParts(Bullet b){ + if(parts.size > 0){ + DrawPart.params.set(b.fin(), 0f, 0f, 0f, 0f, 0f, b.x, b.y, b.rotation()); + DrawPart.params.life = b.fin(); + + for(int i = 0; i < parts.size; i++){ + parts.get(i).draw(DrawPart.params); + } + } + } + public void drawLight(Bullet b){ if(lightOpacity <= 0f || lightRadius <= 0f) return; Drawf.light(b, lightRadius, lightColor, lightOpacity); diff --git a/core/src/mindustry/graphics/Trail.java b/core/src/mindustry/graphics/Trail.java index aa59d77ae8..7594257642 100644 --- a/core/src/mindustry/graphics/Trail.java +++ b/core/src/mindustry/graphics/Trail.java @@ -9,7 +9,7 @@ import arc.util.*; public class Trail{ public int length; - protected final FloatSeq points; + protected FloatSeq points; protected float lastX = -1, lastY = -1, lastAngle = -1, counter = 0f, lastW = 0f; public Trail(int length){ diff --git a/core/src/mindustry/maps/filters/MirrorFilter.java b/core/src/mindustry/maps/filters/MirrorFilter.java index b7d2d200e2..f37dcf14b3 100644 --- a/core/src/mindustry/maps/filters/MirrorFilter.java +++ b/core/src/mindustry/maps/filters/MirrorFilter.java @@ -1,6 +1,5 @@ package mindustry.maps.filters; -import arc.func.*; import arc.graphics.g2d.*; import arc.math.geom.*; import arc.scene.ui.*; @@ -95,35 +94,6 @@ public class MirrorFilter extends GenerateFilter{ void clipHalfLine(Vec2 v, float xmin, float ymin, float xmax, float ymax){ //finds the coordinates of the intersection of the half line created by the vector at (0,0) with the clipping rectangle - - if(v.x < 0){ - if(v.y < 0){ - if(v.x * ymin > v.y * xmin){ - v.set(xmin, xmin * v.y/v.x); - }else{ - v.set(ymin * v.x/v.y, ymin); - } - }else{ - if(v.x * ymax < v.y * xmin){ - v.set(xmin, xmin * v.y/v.x); - }else{ - v.set(ymax * v.x/v.y, ymax); - } - } - }else{ - if(v.y < 0){ - if(v.x * ymin < v.y * xmax){ - v.set(xmax, xmax * v.y/v.x); - }else{ - v.set(ymin * v.x/v.y, ymin); - } - }else{ - if(v.x * ymax > v.y * xmax){ - v.set(xmax, xmax * v.y/v.x); - }else{ - v.set(ymax * v.x/v.y, ymax); - } - } - } + v.scl(1f / Math.max(Math.abs(v.x < 0 ? v.x / xmin : v.x / xmax), Math.abs(v.y < 0 ? v.y / ymin : v.y / ymax))); } }