mirror of
https://github.com/Anuken/Mindustry.git
synced 2026-03-26 08:41:12 -07:00
Bullet refactoring
This commit is contained in:
parent
47b627d669
commit
0b28f97d8f
21 changed files with 75 additions and 22 deletions
|
|
@ -5,7 +5,7 @@ import com.badlogic.gdx.Gdx;
|
|||
import com.badlogic.gdx.files.FileHandle;
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import io.anuke.mindustry.core.*;
|
||||
import io.anuke.mindustry.entities.Bullet;
|
||||
import io.anuke.mindustry.entities.bullet.Bullet;
|
||||
import io.anuke.mindustry.entities.Player;
|
||||
import io.anuke.mindustry.entities.TileEntity;
|
||||
import io.anuke.mindustry.entities.effect.Fire;
|
||||
|
|
|
|||
|
|
@ -7,8 +7,8 @@ import io.anuke.mindustry.content.StatusEffects;
|
|||
import io.anuke.mindustry.content.fx.BulletFx;
|
||||
import io.anuke.mindustry.content.fx.EnvironmentFx;
|
||||
import io.anuke.mindustry.content.fx.Fx;
|
||||
import io.anuke.mindustry.entities.Bullet;
|
||||
import io.anuke.mindustry.entities.BulletType;
|
||||
import io.anuke.mindustry.entities.bullet.Bullet;
|
||||
import io.anuke.mindustry.entities.bullet.BulletType;
|
||||
import io.anuke.mindustry.entities.effect.DamageArea;
|
||||
import io.anuke.mindustry.entities.effect.Fire;
|
||||
import io.anuke.mindustry.entities.effect.Lightning;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
package io.anuke.mindustry.content.bullets;
|
||||
|
||||
import io.anuke.mindustry.entities.Bullet;
|
||||
import io.anuke.mindustry.entities.BulletType;
|
||||
import io.anuke.mindustry.entities.bullet.Bullet;
|
||||
import io.anuke.mindustry.entities.bullet.BulletType;
|
||||
|
||||
public class WeaponBullets {
|
||||
public static final BulletType
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ import io.anuke.mindustry.game.EventType.ResetEvent;
|
|||
import io.anuke.mindustry.game.EventType.WaveEvent;
|
||||
import io.anuke.mindustry.game.Team;
|
||||
import io.anuke.mindustry.game.TeamInfo;
|
||||
import io.anuke.mindustry.game.TeamInfo.TeamData;
|
||||
import io.anuke.mindustry.net.Net;
|
||||
import io.anuke.mindustry.type.Item;
|
||||
import io.anuke.mindustry.type.ItemType;
|
||||
|
|
@ -106,6 +105,7 @@ public class Logic extends Module {
|
|||
Timers.update();
|
||||
}
|
||||
|
||||
/*
|
||||
boolean gameOver = true;
|
||||
|
||||
for(TeamData data : state.teams.getTeams(true)){
|
||||
|
|
@ -115,7 +115,7 @@ public class Logic extends Module {
|
|||
}
|
||||
}
|
||||
|
||||
/* if(gameOver && !state.gameOver){ //TODO better gameover state, victory state?
|
||||
if(gameOver && !state.gameOver){ //TODO better gameover state, victory state?
|
||||
state.gameOver = true;
|
||||
if(Net.server()) NetEvents.handleGameOver();
|
||||
Events.fire(GameOverEvent.class);
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import com.badlogic.gdx.graphics.Color;
|
|||
import com.badlogic.gdx.utils.IntMap;
|
||||
import com.badlogic.gdx.utils.IntSet;
|
||||
import io.anuke.mindustry.core.GameState.State;
|
||||
import io.anuke.mindustry.entities.BulletType;
|
||||
import io.anuke.mindustry.entities.bullet.BulletType;
|
||||
import io.anuke.mindustry.entities.Player;
|
||||
import io.anuke.mindustry.entities.SyncEntity;
|
||||
import io.anuke.mindustry.entities.units.BaseUnit;
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import com.badlogic.gdx.utils.TimeUtils;
|
|||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.content.Mechs;
|
||||
import io.anuke.mindustry.core.GameState.State;
|
||||
import io.anuke.mindustry.entities.BulletType;
|
||||
import io.anuke.mindustry.entities.bullet.BulletType;
|
||||
import io.anuke.mindustry.entities.Player;
|
||||
import io.anuke.mindustry.entities.SyncEntity;
|
||||
import io.anuke.mindustry.gen.CallServer;
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import com.badlogic.gdx.utils.Queue;
|
|||
import io.anuke.mindustry.content.Mechs;
|
||||
import io.anuke.mindustry.content.Weapons;
|
||||
import io.anuke.mindustry.content.fx.ExplosionFx;
|
||||
import io.anuke.mindustry.entities.bullet.BulletType;
|
||||
import io.anuke.mindustry.entities.effect.DamageArea;
|
||||
import io.anuke.mindustry.game.Team;
|
||||
import io.anuke.mindustry.graphics.Palette;
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import com.badlogic.gdx.Gdx;
|
|||
import com.badlogic.gdx.math.Vector2;
|
||||
import com.badlogic.gdx.math.Vector3;
|
||||
import com.badlogic.gdx.utils.TimeUtils;
|
||||
import io.anuke.mindustry.entities.bullet.BulletType;
|
||||
import io.anuke.ucore.core.Timers;
|
||||
import io.anuke.ucore.entities.DestructibleEntity;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package io.anuke.mindustry.entities;
|
||||
|
||||
import io.anuke.mindustry.content.fx.Fx;
|
||||
import io.anuke.mindustry.entities.bullet.Bullet;
|
||||
import io.anuke.mindustry.net.Net;
|
||||
import io.anuke.mindustry.net.NetEvents;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
|
|
@ -108,7 +109,7 @@ public class TileEntity extends Entity{
|
|||
}
|
||||
}
|
||||
|
||||
public boolean collide(Bullet other){
|
||||
public boolean collide(io.anuke.mindustry.entities.bullet.Bullet other){
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package io.anuke.mindustry.entities;
|
|||
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
import io.anuke.mindustry.content.blocks.Blocks;
|
||||
import io.anuke.mindustry.entities.bullet.Bullet;
|
||||
import io.anuke.mindustry.game.Team;
|
||||
import io.anuke.mindustry.game.TeamInfo.TeamData;
|
||||
import io.anuke.mindustry.type.Item;
|
||||
|
|
@ -40,7 +41,7 @@ public abstract class Unit extends SyncEntity implements SerializableEntity {
|
|||
|
||||
@Override
|
||||
public boolean collides(SolidEntity other){
|
||||
return other instanceof Bullet && state.teams.areEnemies((((Bullet) other).team), team);
|
||||
return other instanceof io.anuke.mindustry.entities.bullet.Bullet && state.teams.areEnemies((((Bullet) other).team), team);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -0,0 +1,45 @@
|
|||
package io.anuke.mindustry.entities.bullet;
|
||||
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import io.anuke.mindustry.content.bullets.TurretBullets;
|
||||
import io.anuke.mindustry.graphics.Palette;
|
||||
import io.anuke.ucore.util.Angles;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
|
||||
/**A BulletType for most ammo-based bullets shot from turrets and units.*/
|
||||
public abstract class BasicBulletType extends BulletType {
|
||||
public Color backColor = Palette.bulletYellowBack, frontColor = Palette.bulletYellow;
|
||||
public String bulletSprite = "bullet";
|
||||
public float bulletWidth = 5f, bulletHeight = 7f;
|
||||
|
||||
public boolean frag;
|
||||
public int fragBullets = 9;
|
||||
public float fragVelocityMin = 0.2f, fragVelocityMax = 1f;
|
||||
public BulletType fragBullet = TurretBullets.basicLeadFrag;
|
||||
|
||||
public BasicBulletType(float speed, float damage) {
|
||||
super(speed, damage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hit(Bullet b, float x, float y) {
|
||||
super.hit(b, x, y);
|
||||
|
||||
if(frag) {
|
||||
for (int i = 0; i < fragBullets; i++) {
|
||||
float len = Mathf.random(1f, 7f);
|
||||
float a = Mathf.random(360f);
|
||||
Bullet bullet = Bullet.create(fragBullet, b,
|
||||
x + Angles.trnsx(a, len), y + Angles.trnsy(a, len), a);
|
||||
bullet.velocity.scl(Mathf.random(fragVelocityMin, fragVelocityMax));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void despawned(Bullet b) {
|
||||
if(frag){
|
||||
hit(b);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +1,9 @@
|
|||
package io.anuke.mindustry.entities;
|
||||
package io.anuke.mindustry.entities.bullet;
|
||||
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
import com.badlogic.gdx.utils.Pools;
|
||||
import io.anuke.mindustry.entities.SyncEntity;
|
||||
import io.anuke.mindustry.entities.Unit;
|
||||
import io.anuke.mindustry.game.Team;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.ucore.entities.BulletEntity;
|
||||
|
|
@ -1,7 +1,8 @@
|
|||
package io.anuke.mindustry.entities;
|
||||
package io.anuke.mindustry.entities.bullet;
|
||||
|
||||
import io.anuke.mindustry.content.StatusEffects;
|
||||
import io.anuke.mindustry.content.fx.BulletFx;
|
||||
import io.anuke.mindustry.entities.StatusEffect;
|
||||
import io.anuke.ucore.core.Effects;
|
||||
import io.anuke.ucore.entities.BaseBulletType;
|
||||
|
||||
|
|
@ -6,7 +6,7 @@ import com.badlogic.gdx.math.Vector2;
|
|||
import io.anuke.mindustry.content.bullets.TurretBullets;
|
||||
import io.anuke.mindustry.content.fx.ExplosionFx;
|
||||
import io.anuke.mindustry.content.fx.Fx;
|
||||
import io.anuke.mindustry.entities.Bullet;
|
||||
import io.anuke.mindustry.entities.bullet.Bullet;
|
||||
import io.anuke.mindustry.entities.Unit;
|
||||
import io.anuke.mindustry.entities.Units;
|
||||
import io.anuke.mindustry.game.Team;
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import io.anuke.mindustry.content.blocks.Blocks;
|
|||
import io.anuke.mindustry.content.bullets.TurretBullets;
|
||||
import io.anuke.mindustry.content.fx.BlockFx;
|
||||
import io.anuke.mindustry.content.fx.EnvironmentFx;
|
||||
import io.anuke.mindustry.entities.Bullet;
|
||||
import io.anuke.mindustry.entities.bullet.Bullet;
|
||||
import io.anuke.mindustry.entities.SerializableEntity;
|
||||
import io.anuke.mindustry.entities.Units;
|
||||
import io.anuke.mindustry.game.Team;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
package io.anuke.mindustry.entities.units;
|
||||
|
||||
import io.anuke.mindustry.entities.Bullet;
|
||||
import io.anuke.mindustry.entities.BulletType;
|
||||
import io.anuke.mindustry.entities.bullet.Bullet;
|
||||
import io.anuke.mindustry.entities.bullet.BulletType;
|
||||
import io.anuke.mindustry.entities.TileEntity;
|
||||
import io.anuke.mindustry.entities.Unit;
|
||||
import io.anuke.mindustry.game.Team;
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ package io.anuke.mindustry.entities.units;
|
|||
import com.badlogic.gdx.utils.Array;
|
||||
import com.badlogic.gdx.utils.ObjectMap;
|
||||
import io.anuke.mindustry.content.fx.ExplosionFx;
|
||||
import io.anuke.mindustry.entities.Bullet;
|
||||
import io.anuke.mindustry.entities.bullet.Bullet;
|
||||
import io.anuke.mindustry.entities.TileEntity;
|
||||
import io.anuke.mindustry.entities.Unit;
|
||||
import io.anuke.mindustry.net.Net;
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ package io.anuke.mindustry.type;
|
|||
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import io.anuke.mindustry.content.fx.Fx;
|
||||
import io.anuke.mindustry.entities.BulletType;
|
||||
import io.anuke.mindustry.entities.bullet.BulletType;
|
||||
import io.anuke.ucore.core.Effects.Effect;
|
||||
|
||||
public class AmmoType {
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ package io.anuke.mindustry.type;
|
|||
import com.badlogic.gdx.utils.ObjectMap;
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.content.fx.Fx;
|
||||
import io.anuke.mindustry.entities.Bullet;
|
||||
import io.anuke.mindustry.entities.bullet.Bullet;
|
||||
import io.anuke.mindustry.entities.Player;
|
||||
import io.anuke.mindustry.entities.Unit;
|
||||
import io.anuke.mindustry.net.Net;
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import com.badlogic.gdx.Gdx;
|
|||
import com.badlogic.gdx.files.FileHandle;
|
||||
import io.anuke.mindustry.content.UnitTypes;
|
||||
import io.anuke.mindustry.content.bullets.TurretBullets;
|
||||
import io.anuke.mindustry.entities.Bullet;
|
||||
import io.anuke.mindustry.entities.bullet.Bullet;
|
||||
import io.anuke.mindustry.entities.Player;
|
||||
import io.anuke.mindustry.entities.TileEntity;
|
||||
import io.anuke.mindustry.entities.units.BaseUnit;
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
|||
import com.badlogic.gdx.utils.Array;
|
||||
import io.anuke.mindustry.content.fx.Fx;
|
||||
import io.anuke.mindustry.entities.*;
|
||||
import io.anuke.mindustry.entities.bullet.BulletType;
|
||||
import io.anuke.mindustry.graphics.Layer;
|
||||
import io.anuke.mindustry.graphics.Palette;
|
||||
import io.anuke.mindustry.type.AmmoEntry;
|
||||
|
|
@ -229,7 +230,7 @@ public abstract class Turret extends Block{
|
|||
}
|
||||
|
||||
protected void bullet(Tile tile, BulletType type, float angle){
|
||||
Bullet.create(type, tile.entity, tile.getTeam(), tile.drawx() + tr.x, tile.drawy() + tr.y, angle);
|
||||
io.anuke.mindustry.entities.bullet.Bullet.create(type, tile.entity, tile.getTeam(), tile.drawx() + tr.x, tile.drawy() + tr.y, angle);
|
||||
}
|
||||
|
||||
protected void effects(Tile tile){
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue