Bullet parts / Improved clipping in #7282

This commit is contained in:
Anuken 2022-10-04 15:58:40 -04:00
parent f2894ff38d
commit ca4f710ec2
4 changed files with 18 additions and 33 deletions

View File

@ -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

View File

@ -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<DrawPart> 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);

View File

@ -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){

View File

@ -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)));
}
}