Updated Bullet to use floats

This commit is contained in:
Anuken
2018-05-09 09:46:24 -07:00
parent 83d1707b56
commit ce2b73b737
14 changed files with 50 additions and 92 deletions

View File

@@ -142,18 +142,13 @@ project(":ios") {
compile "com.badlogicgames.gdx:gdx-backend-robovm:$gdxVersion" compile "com.badlogicgames.gdx:gdx-backend-robovm:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-ios" compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-ios"
} }
robovm {
iosSignIdentity = "a"
iosProvisioningProfile = ""
}
} }
project(":core") { project(":core") {
apply plugin: "java" apply plugin: "java"
dependencies { dependencies {
boolean comp = System.properties["release"] == null || System.properties["release"] == "false" boolean comp = true//System.properties["release"] == null || System.properties["release"] == "false"
if(!comp){ if(!comp){
println("NOTICE: Compiling release build.") println("NOTICE: Compiling release build.")
@@ -161,7 +156,7 @@ project(":core") {
println("Compiling DEBUG build.") println("Compiling DEBUG build.")
} }
if(new File('../uCore').exists() && comp){ if(new File(projectDir.parent, '../uCore').exists() && comp){
compile project(":uCore") compile project(":uCore")
}else{ }else{
compile "com.github.anuken:ucore:$uCoreVersion" compile "com.github.anuken:ucore:$uCoreVersion"

View File

@@ -106,22 +106,22 @@ public class Vars{
new Locale("de"), new Locale("pt", "BR"), new Locale("ko"), new Locale("in", "ID"), new Locale("ita"), new Locale("es")}; new Locale("de"), new Locale("pt", "BR"), new Locale("ko"), new Locale("in", "ID"), new Locale("ita"), new Locale("es")};
public static final Color[] playerColors = { public static final Color[] playerColors = {
Color.valueOf("82759a"), Color.valueOf("82759a"),
Color.valueOf("c0c1c5"), Color.valueOf("c0c1c5"),
Color.valueOf("fff0e7"), Color.valueOf("fff0e7"),
Color.valueOf("7d2953"), Color.valueOf("7d2953"),
Color.valueOf("ff074e"), Color.valueOf("ff074e"),
Color.valueOf("ff072a"), Color.valueOf("ff072a"),
Color.valueOf("ff76a6"), Color.valueOf("ff76a6"),
Color.valueOf("a95238"), Color.valueOf("a95238"),
Color.valueOf("ffa108"), Color.valueOf("ffa108"),
Color.valueOf("feeb2c"), Color.valueOf("feeb2c"),
Color.valueOf("ffcaa8"), Color.valueOf("ffcaa8"),
Color.valueOf("008551"), Color.valueOf("008551"),
Color.valueOf("00e339"), Color.valueOf("00e339"),
Color.valueOf("423c7b"), Color.valueOf("423c7b"),
Color.valueOf("4b5ef1"), Color.valueOf("4b5ef1"),
Color.valueOf("2cabfe"), Color.valueOf("2cabfe"),
}; };
//server port //server port

View File

@@ -258,19 +258,11 @@ public class NetClient extends Module {
ui.restart.show(); ui.restart.show();
}); });
Net.handleClient(FriendlyFireChangePacket.class, packet -> state.friendlyFire = packet.enabled);
Net.handleClient(NetErrorPacket.class, packet -> { Net.handleClient(NetErrorPacket.class, packet -> {
ui.showError(packet.message); ui.showError(packet.message);
disconnectQuietly(); disconnectQuietly();
}); });
Net.handleClient(PlayerAdminPacket.class, packet -> {
Player player = playerGroup.getByID(packet.id);
player.isAdmin = packet.admin;
ui.listfrag.rebuild();
});
Net.handleClient(TracePacket.class, packet -> { Net.handleClient(TracePacket.class, packet -> {
Player player = playerGroup.getByID(packet.info.playerid); Player player = playerGroup.getByID(packet.info.playerid);
ui.traces.show(player, packet.info); ui.traces.show(player, packet.info);

View File

@@ -107,7 +107,7 @@ public class Bullet extends BulletEntity<BulletType>{
} }
@Override @Override
public int getDamage(){ public float getDamage(){
return damage == -1 ? type.damage : damage; return damage == -1 ? type.damage : damage;
} }

View File

@@ -11,8 +11,7 @@ public abstract class BulletType extends BaseBulletType<Bullet>{
public StatusEffect status = StatusEffects.none; public StatusEffect status = StatusEffects.none;
public float statusIntensity = 0.5f; public float statusIntensity = 0.5f;
//TODO use float damage public BulletType(float speed, float damage){
public BulletType(float speed, int damage){
this.speed = speed; this.speed = speed;
this.damage = damage; this.damage = damage;
lifetime = 40f; lifetime = 40f;

View File

@@ -31,7 +31,7 @@ public class Lightning extends TimedEntity implements Poolable{
public Color color = Palette.lancerLaser; public Color color = Palette.lancerLaser;
public static void create(Team team, Effect effect, Color color, int damage, float x, float y, float targetAngle, int length){ public static void create(Team team, Effect effect, Color color, float damage, float x, float y, float targetAngle, int length){
Lightning l = Pools.obtain(Lightning.class); Lightning l = Pools.obtain(Lightning.class);
l.x = x; l.x = x;
@@ -68,10 +68,10 @@ public class Lightning extends TimedEntity implements Poolable{
Rectangle hitbox = entity.hitbox.getRect(entity.x, entity.y, range); Rectangle hitbox = entity.hitbox.getRect(entity.x, entity.y, range);
if(hitbox.contains(x2, y2) || hitbox.contains(fx, fy)){ if(hitbox.contains(x2, y2) || hitbox.contains(fx, fy)){
int result = damage; float result = damage;
if(entity.status.current() == StatusEffects.wet) if(entity.status.current() == StatusEffects.wet)
result = (int)(result * wetDamageMultiplier); result = (result * wetDamageMultiplier);
entity.damage(result); entity.damage(result);
Effects.effect(effect, x2, y2, fangle); Effects.effect(effect, x2, y2, fangle);

View File

@@ -5,6 +5,7 @@ import com.badlogic.gdx.utils.reflect.ClassReflection;
import com.badlogic.gdx.utils.reflect.Method; import com.badlogic.gdx.utils.reflect.Method;
import com.badlogic.gdx.utils.reflect.ReflectionException; import com.badlogic.gdx.utils.reflect.ReflectionException;
import io.anuke.mindustry.Vars; import io.anuke.mindustry.Vars;
import io.anuke.mindustry.entities.Player;
import io.anuke.mindustry.game.Team; import io.anuke.mindustry.game.Team;
import io.anuke.mindustry.net.Net.SendMode; import io.anuke.mindustry.net.Net.SendMode;
import io.anuke.mindustry.net.Packets.InvokePacket; import io.anuke.mindustry.net.Packets.InvokePacket;
@@ -17,6 +18,8 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy; import java.lang.annotation.RetentionPolicy;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import static io.anuke.mindustry.Vars.playerGroup;
/**Class for invoking static methods of other classes remotely.*/ /**Class for invoking static methods of other classes remotely.*/
public class Invoke { public class Invoke {
private static ObjectMap<Class, ObjectMap<String, Method>> methods = new ObjectMap<>(); private static ObjectMap<Class, ObjectMap<String, Method>> methods = new ObjectMap<>();
@@ -52,6 +55,10 @@ public class Invoke {
on(NetEvents.class, methodName, args); on(NetEvents.class, methodName, args);
} }
public static void eventRemote(String methodName, Object... args){
on(NetEvents.class, methodName, args);
}
//TODO refactor to serializer map! //TODO refactor to serializer map!
static void writeObjects(ByteBuffer buffer, Object[] objects){ static void writeObjects(ByteBuffer buffer, Object[] objects){
for(Object o : objects){ for(Object o : objects){
@@ -76,6 +83,8 @@ public class Invoke {
}else if(type == Entity.class){ }else if(type == Entity.class){
buffer.put((byte)((Entity)o).getGroup().getID()); buffer.put((byte)((Entity)o).getGroup().getID());
buffer.putInt(((Entity)o).id); buffer.putInt(((Entity)o).id);
}else if(type == Player.class){
buffer.putInt(((Player)o).id);
}else if(type == Team.class){ }else if(type == Team.class){
buffer.put((byte)((Team)o).ordinal()); buffer.put((byte)((Team)o).ordinal());
}else if(type == String.class){ }else if(type == String.class){
@@ -110,6 +119,9 @@ public class Invoke {
byte group = buffer.get(); byte group = buffer.get();
int id = buffer.getInt(); int id = buffer.getInt();
obj = Entities.getGroup(group).getByID(id); obj = Entities.getGroup(group).getByID(id);
}else if(type == Player.class){
int id = buffer.getInt();
obj = playerGroup.getByID(id);
}else if(type == Team.class){ }else if(type == Team.class){
obj = Team.values()[buffer.get()]; obj = Team.values()[buffer.get()];
}else if(type == String.class){ }else if(type == String.class){

View File

@@ -18,13 +18,10 @@ import static io.anuke.mindustry.Vars.*;
public class NetEvents { public class NetEvents {
public static void handleFriendlyFireChange(boolean enabled){ public static void friendlyFireChange(boolean enabled){
FriendlyFireChangePacket packet = Pools.obtain(FriendlyFireChangePacket.class); state.friendlyFire = enabled;
packet.enabled = enabled;
netCommon.sendMessage(enabled ? "[accent]Friendly fire enabled." : "[accent]Friendly fire disabled."); if(Net.server()) netCommon.sendMessage(enabled ? "[accent]Friendly fire enabled." : "[accent]Friendly fire disabled.");
Net.send(packet, SendMode.tcp);
} }
public static void handleGameOver(){ public static void handleGameOver(){
@@ -117,12 +114,12 @@ public class NetEvents {
Net.send(packet, SendMode.tcp); Net.send(packet, SendMode.tcp);
} }
public static void handleAdminSet(Player player, boolean admin){ public static void adminSet(Player player, boolean admin){
PlayerAdminPacket packet = Pools.obtain(PlayerAdminPacket.class);
packet.admin = admin;
packet.id = player.id;
player.isAdmin = admin; player.isAdmin = admin;
Net.send(packet, SendMode.tcp);
if(Net.client()){
ui.listfrag.rebuild();
}
} }
public static void handleAdministerRequest(Player target, AdminAction action){ public static void handleAdministerRequest(Player target, AdminAction action){

View File

@@ -477,24 +477,6 @@ public class Packets {
public void read(ByteBuffer buffer) { } public void read(ByteBuffer buffer) { }
} }
public static class FriendlyFireChangePacket implements Packet{
public boolean enabled;
@Override
public void write(ByteBuffer buffer) {
buffer.put(enabled ? 1 : (byte)0);
}
@Override
public void read(ByteBuffer buffer) {
enabled = buffer.get() == 1;
}
}
public static class CustomMapPacket extends Streamable{
}
public static class MapAckPacket implements Packet{ public static class MapAckPacket implements Packet{
@Override @Override
public void write(ByteBuffer buffer) { } public void write(ByteBuffer buffer) { }
@@ -517,23 +499,6 @@ public class Packets {
} }
} }
public static class PlayerAdminPacket implements Packet{
public boolean admin;
public int id;
@Override
public void write(ByteBuffer buffer) {
buffer.put(admin ? (byte)1 : 0);
buffer.putInt(id);
}
@Override
public void read(ByteBuffer buffer) {
admin = buffer.get() == 1;
id = buffer.getInt();
}
}
public static class AdministerRequestPacket implements Packet{ public static class AdministerRequestPacket implements Packet{
public AdminAction action; public AdminAction action;
public int id; public int id;

View File

@@ -32,12 +32,9 @@ public class Registrator {
EntityRequestPacket.class, EntityRequestPacket.class,
ConnectConfirmPacket.class, ConnectConfirmPacket.class,
GameOverPacket.class, GameOverPacket.class,
FriendlyFireChangePacket.class,
CustomMapPacket.class,
MapAckPacket.class, MapAckPacket.class,
EntitySpawnPacket.class, EntitySpawnPacket.class,
NetErrorPacket.class, NetErrorPacket.class,
PlayerAdminPacket.class,
AdministerRequestPacket.class, AdministerRequestPacket.class,
TracePacket.class, TracePacket.class,
InvokePacket.class, InvokePacket.class,

View File

@@ -2,6 +2,7 @@ package io.anuke.mindustry.ui.dialogs;
import io.anuke.mindustry.entities.Player; import io.anuke.mindustry.entities.Player;
import io.anuke.mindustry.net.Administration.PlayerInfo; import io.anuke.mindustry.net.Administration.PlayerInfo;
import io.anuke.mindustry.net.Invoke;
import io.anuke.mindustry.net.Net; import io.anuke.mindustry.net.Net;
import io.anuke.mindustry.net.NetConnection; import io.anuke.mindustry.net.NetConnection;
import io.anuke.mindustry.net.NetEvents; import io.anuke.mindustry.net.NetEvents;
@@ -49,7 +50,7 @@ public class AdminsDialog extends FloatingDialog {
for(Player player : playerGroup.all()){ for(Player player : playerGroup.all()){
NetConnection c = Net.getConnection(player.clientid); NetConnection c = Net.getConnection(player.clientid);
if(c != null){ if(c != null){
NetEvents.handleAdminSet(player, false); Invoke.event("adminSet", player, false);
break; break;
} }
} }

View File

@@ -3,6 +3,7 @@ package io.anuke.mindustry.ui.fragments;
import io.anuke.mindustry.Vars; import io.anuke.mindustry.Vars;
import io.anuke.mindustry.core.GameState.State; import io.anuke.mindustry.core.GameState.State;
import io.anuke.mindustry.entities.Player; import io.anuke.mindustry.entities.Player;
import io.anuke.mindustry.net.Invoke;
import io.anuke.mindustry.net.Net; import io.anuke.mindustry.net.Net;
import io.anuke.mindustry.net.NetConnection; import io.anuke.mindustry.net.NetConnection;
import io.anuke.mindustry.net.NetEvents; import io.anuke.mindustry.net.NetEvents;
@@ -48,7 +49,7 @@ public class PlayerListFragment implements Fragment{
get().addCheck("$text.server.friendlyfire", b -> { get().addCheck("$text.server.friendlyfire", b -> {
state.friendlyFire = b; state.friendlyFire = b;
NetEvents.handleFriendlyFireChange(b); Invoke.event("friendlyFireChange", b);
}).growX().update(i -> i.setChecked(state.friendlyFire)).disabled(b -> Net.client()).padRight(5); }).growX().update(i -> i.setChecked(state.friendlyFire)).disabled(b -> Net.client()).padRight(5);
new button("$text.server.bans", () -> { new button("$text.server.bans", () -> {
@@ -155,12 +156,12 @@ public class PlayerListFragment implements Fragment{
if(netServer.admins.isAdmin(id, connection.address)){ if(netServer.admins.isAdmin(id, connection.address)){
ui.showConfirm("$text.confirm", "$text.confirmunadmin", () -> { ui.showConfirm("$text.confirm", "$text.confirmunadmin", () -> {
netServer.admins.unAdminPlayer(id); netServer.admins.unAdminPlayer(id);
NetEvents.handleAdminSet(player, false); Invoke.event("adminSet", player, false);
}); });
}else{ }else{
ui.showConfirm("$text.confirm", "$text.confirmadmin", () -> { ui.showConfirm("$text.confirm", "$text.confirmadmin", () -> {
netServer.admins.adminPlayer(id, connection.address); netServer.admins.adminPlayer(id, connection.address);
NetEvents.handleAdminSet(player, true); Invoke.event("adminSet", player, true);
}); });
} }
}).update(b ->{ }).update(b ->{

Binary file not shown.

View File

@@ -1,6 +1,5 @@
#Wed May 02 11:26:02 EDT 2018
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-bin.zip
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip