Packer compile fix / Mapping fix
This commit is contained in:
@@ -35,6 +35,7 @@ public class Recipes implements ContentList{
|
||||
|
||||
//projectors
|
||||
new Recipe(defense, DefenseBlocks.mendProjector, new ItemStack(Items.lead, 200), new ItemStack(Items.densealloy, 150), new ItemStack(Items.titanium, 150), new ItemStack(Items.silicon, 250));
|
||||
new Recipe(defense, DefenseBlocks.overdriveProjector, new ItemStack(Items.lead, 200), new ItemStack(Items.densealloy, 150), new ItemStack(Items.titanium, 150), new ItemStack(Items.silicon, 250));
|
||||
|
||||
//extra blocks
|
||||
new Recipe(defense, DefenseBlocks.shockMine, new ItemStack(Items.lead, 50), new ItemStack(Items.silicon, 25))
|
||||
|
||||
@@ -8,7 +8,7 @@ import io.anuke.mindustry.world.blocks.defense.*;
|
||||
|
||||
public class DefenseBlocks extends BlockList implements ContentList{
|
||||
public static Block copperWall, copperWallLarge, compositeWall, compositeWallLarge, thoriumWall, thoriumWallLarge, door, doorLarge,
|
||||
phaseWall, phaseWallLarge, surgeWall, surgeWallLarge, mendProjector, shockMine;
|
||||
phaseWall, phaseWallLarge, surgeWall, surgeWallLarge, mendProjector, overdriveProjector, shockMine;
|
||||
|
||||
@Override
|
||||
public void load(){
|
||||
@@ -72,7 +72,12 @@ public class DefenseBlocks extends BlockList implements ContentList{
|
||||
|
||||
mendProjector = new MendProjector("mend-projector"){{
|
||||
consumes.power(0.25f);
|
||||
health = 100 * 4 * wallHealthMultiplier;
|
||||
size = 2;
|
||||
consumes.item(Items.phasematter).optional(true);
|
||||
}};
|
||||
|
||||
overdriveProjector = new OverdriveProjector("overdrive-projector"){{
|
||||
consumes.power(0.25f);
|
||||
size = 2;
|
||||
consumes.item(Items.phasematter).optional(true);
|
||||
}};
|
||||
|
||||
@@ -10,7 +10,7 @@ import io.anuke.mindustry.world.blocks.units.*;
|
||||
public class UnitBlocks extends BlockList implements ContentList{
|
||||
public static Block repairPoint, dronePad,
|
||||
fabricatorPad, interceptorPad, monsoonPad, daggerPad, titanPad,
|
||||
dropPoint, reconstructor, overdriveProjector, shieldProjector, commandCenter;
|
||||
reconstructor, commandCenter;
|
||||
|
||||
@Override
|
||||
public void load(){
|
||||
@@ -64,11 +64,6 @@ public class UnitBlocks extends BlockList implements ContentList{
|
||||
consumes.items(new ItemStack[]{new ItemStack(Items.silicon, 20), new ItemStack(Items.thorium, 30)});
|
||||
}};
|
||||
|
||||
dropPoint = new DropPoint("drop-point"){{
|
||||
shadow = "shadow-round-1";
|
||||
itemCapacity = 40;
|
||||
}};
|
||||
|
||||
repairPoint = new RepairPoint("repair-point"){{
|
||||
shadow = "shadow-round-1";
|
||||
repairSpeed = 0.1f;
|
||||
@@ -78,14 +73,6 @@ public class UnitBlocks extends BlockList implements ContentList{
|
||||
size = 2;
|
||||
}};
|
||||
|
||||
overdriveProjector = new OverdriveProjector("overdrive-projector"){{
|
||||
size = 2;
|
||||
}};
|
||||
|
||||
shieldProjector = new ShieldProjector("shield-projector"){{
|
||||
size = 2;
|
||||
}};
|
||||
|
||||
commandCenter = new CommandCenter("command-center"){{
|
||||
size = 2;
|
||||
}};
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package io.anuke.mindustry.core;
|
||||
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import com.badlogic.gdx.utils.IntMap;
|
||||
import com.badlogic.gdx.utils.ObjectMap;
|
||||
import com.badlogic.gdx.utils.ObjectSet;
|
||||
import io.anuke.mindustry.content.*;
|
||||
@@ -38,7 +37,7 @@ public class ContentLoader{
|
||||
|
||||
private ObjectMap<String, MappableContent>[] contentNameMap = new ObjectMap[ContentType.values().length];
|
||||
private Array<Content>[] contentMap = new Array[ContentType.values().length];
|
||||
private IntMap<IntMap<MappableContent>> temporaryMapper;
|
||||
private MappableContent[][] temporaryMapper;
|
||||
private ObjectSet<Consumer<Content>> initialization = new ObjectSet<>();
|
||||
private ContentList[] content = {
|
||||
//effects
|
||||
@@ -183,7 +182,7 @@ public class ContentLoader{
|
||||
contentMap[content.getContentType().ordinal()].add(content);
|
||||
}
|
||||
|
||||
public void setTemporaryMapper(IntMap<IntMap<MappableContent>> temporaryMapper){
|
||||
public void setTemporaryMapper(MappableContent[][] temporaryMapper){
|
||||
this.temporaryMapper = temporaryMapper;
|
||||
}
|
||||
|
||||
@@ -199,13 +198,13 @@ public class ContentLoader{
|
||||
}
|
||||
|
||||
public <T extends Content> T getByID(ContentType type, int id){
|
||||
if(temporaryMapper != null && temporaryMapper.containsKey(type.ordinal()) && temporaryMapper.get(type.ordinal()).containsKey(id)){
|
||||
return (T)temporaryMapper.get(type.ordinal()).get(id);
|
||||
}
|
||||
|
||||
//offset negative values by 256, as they are probably a product of byte overflow
|
||||
if(id < 0) id += 256;
|
||||
|
||||
if(temporaryMapper != null && temporaryMapper[type.ordinal()] != null){
|
||||
return (T)temporaryMapper[type.ordinal()][id];
|
||||
}
|
||||
|
||||
if(id >= contentMap[type.ordinal()].size || id < 0){
|
||||
throw new RuntimeException("No " + type.name() + " with ID '" + id + "' found!");
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package io.anuke.mindustry.io;
|
||||
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import com.badlogic.gdx.utils.IntMap;
|
||||
import io.anuke.mindustry.game.Content;
|
||||
import io.anuke.mindustry.game.Difficulty;
|
||||
import io.anuke.mindustry.game.MappableContent;
|
||||
@@ -32,19 +31,20 @@ public abstract class SaveFileVersion{
|
||||
return new SaveMeta(version, time, playtime, build, sector, mode, map, wave, Difficulty.values()[difficulty]);
|
||||
}
|
||||
|
||||
public IntMap<IntMap<MappableContent>> readContentHeader(DataInputStream stream) throws IOException{
|
||||
IntMap<IntMap<MappableContent>> map = new IntMap<>();
|
||||
public MappableContent[][] readContentHeader(DataInputStream stream) throws IOException{
|
||||
|
||||
byte mapped = stream.readByte();
|
||||
|
||||
MappableContent[][] map = new MappableContent[mapped][0];
|
||||
|
||||
for (int i = 0; i < mapped; i++) {
|
||||
ContentType type = ContentType.values()[stream.readByte()];
|
||||
map.put(type.ordinal(), new IntMap<>());
|
||||
short total = stream.readShort();
|
||||
map[i] = new MappableContent[total];
|
||||
|
||||
for (int j = 0; j < total; j++) {
|
||||
int id = stream.readUnsignedByte();
|
||||
String name = stream.readUTF();
|
||||
if(content.getContentMap()[type.ordinal()].size == 0) continue;
|
||||
map.get(type.ordinal()).put(id, content.getByName(type, name));
|
||||
map[i][j] = content.getByName(type, name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,10 +69,7 @@ public abstract class SaveFileVersion{
|
||||
stream.writeByte(arr.first().getContentType().ordinal());
|
||||
stream.writeShort(arr.size);
|
||||
for(Content c : arr){
|
||||
MappableContent m = (MappableContent)c;
|
||||
if(m.id > 255) throw new RuntimeException("Content " + c + " has ID > 255!");
|
||||
stream.writeByte(m.id);
|
||||
stream.writeUTF(m.getContentName());
|
||||
stream.writeUTF(((MappableContent)c).getContentName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,105 @@
|
||||
package io.anuke.mindustry.world.blocks.defense;
|
||||
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||
import io.anuke.mindustry.content.StatusEffects;
|
||||
import io.anuke.mindustry.content.fx.BlockFx;
|
||||
import io.anuke.mindustry.entities.TileEntity;
|
||||
import io.anuke.mindustry.entities.Units;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.ucore.core.Effects;
|
||||
import io.anuke.ucore.core.Graphics;
|
||||
import io.anuke.ucore.core.Timers;
|
||||
import io.anuke.ucore.graphics.Draw;
|
||||
import io.anuke.ucore.graphics.Hue;
|
||||
import io.anuke.ucore.graphics.Lines;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
|
||||
public class OverdriveProjector extends Block {
|
||||
public class OverdriveProjector extends Block{
|
||||
private static Color color = Color.valueOf("feb380");
|
||||
private static Color phase = Color.valueOf("ffd59e");
|
||||
|
||||
public OverdriveProjector(String name) {
|
||||
protected int timerUse = timers ++;
|
||||
|
||||
protected TextureRegion topRegion;
|
||||
protected float reload = 250f;
|
||||
protected float range = 50f;
|
||||
protected float healPercent = 6f;
|
||||
protected float phaseBoost = 10f;
|
||||
protected float useTime = 300f;
|
||||
|
||||
public OverdriveProjector(String name){
|
||||
super(name);
|
||||
solid = true;
|
||||
update = true;
|
||||
hasPower = true;
|
||||
hasItems = true;
|
||||
itemCapacity = 10;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(){
|
||||
super.load();
|
||||
topRegion = Draw.region(name + "-top");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(Tile tile){
|
||||
OverdriveEntity entity = tile.entity();
|
||||
entity.heat = Mathf.lerpDelta(entity.heat, entity.cons.valid() ? 1f : 0f, 0.08f);
|
||||
entity.charge += entity.heat * Timers.delta();
|
||||
|
||||
entity.phaseHeat = Mathf.lerpDelta(entity.phaseHeat, (float)entity.items.get(consumes.item()) / itemCapacity, 0.1f);
|
||||
|
||||
if(entity.timer.get(timerUse, useTime) && entity.items.total() > 0){
|
||||
entity.items.remove(consumes.item(), 1);
|
||||
}
|
||||
|
||||
if(entity.charge >= reload){
|
||||
float realRange = range + entity.phaseHeat * 20f;
|
||||
|
||||
Effects.effect(BlockFx.commandSend, Hue.mix(color, phase, entity.phaseHeat), tile.drawx(), tile.drawy(), realRange);
|
||||
Units.getNearby(tile.getTeam(), tile.drawx(), tile.drawy(), realRange, unit -> unit.applyEffect(StatusEffects.overdrive, 1f));
|
||||
entity.charge = 0f;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawSelect(Tile tile){
|
||||
Draw.color(color);
|
||||
Lines.dashCircle(tile.drawx(), tile.drawy() - 1f, range);
|
||||
Draw.color();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Tile tile){
|
||||
super.draw(tile);
|
||||
|
||||
OverdriveEntity entity = tile.entity();
|
||||
float f = 1f - (Timers.time() / 100f) % 1f;
|
||||
|
||||
Draw.color(color, phase, entity.phaseHeat);
|
||||
Draw.alpha(entity.heat * Mathf.absin(Timers.time(), 10f, 1f) * 0.5f);
|
||||
Graphics.setAdditiveBlending();
|
||||
Draw.rect(topRegion, tile.drawx(), tile.drawy());
|
||||
|
||||
Graphics.setNormalBlending();
|
||||
Draw.alpha(1f);
|
||||
Lines.stroke((2f * f + 0.2f)* entity.heat);
|
||||
Lines.circle(tile.drawx(), tile.drawy(), (1f-f) * 9f);
|
||||
|
||||
Draw.reset();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getEntity(){
|
||||
return new OverdriveEntity();
|
||||
}
|
||||
|
||||
class OverdriveEntity extends TileEntity{
|
||||
float heat;
|
||||
float charge;
|
||||
float phaseHeat;
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
package io.anuke.mindustry.world.blocks.units;
|
||||
|
||||
import io.anuke.mindustry.content.StatusEffects;
|
||||
|
||||
public class OverdriveProjector extends Projector{
|
||||
|
||||
public OverdriveProjector(String name){
|
||||
super(name);
|
||||
|
||||
status = StatusEffects.overdrive;
|
||||
}
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
package io.anuke.mindustry.world.blocks.units;
|
||||
|
||||
import io.anuke.mindustry.entities.TileEntity;
|
||||
import io.anuke.mindustry.entities.Units;
|
||||
import io.anuke.mindustry.graphics.Palette;
|
||||
import io.anuke.mindustry.type.StatusEffect;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.ucore.core.Timers;
|
||||
import io.anuke.ucore.graphics.Draw;
|
||||
import io.anuke.ucore.graphics.Lines;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
|
||||
public abstract class Projector extends Block{
|
||||
protected final int timerApply = timers++;
|
||||
protected final float applyTime = 4f;
|
||||
|
||||
protected float range = 80f;
|
||||
|
||||
protected StatusEffect status;
|
||||
protected float intensity = 1f;
|
||||
|
||||
public Projector(String name){
|
||||
super(name);
|
||||
hasPower = true;
|
||||
update = true;
|
||||
solid = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawSelect(Tile tile){
|
||||
Draw.color(Palette.accent);
|
||||
Lines.dashCircle(tile.drawx(), tile.drawy(), range);
|
||||
Draw.reset();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(Tile tile){
|
||||
ProjectorEntity entity = tile.entity();
|
||||
|
||||
if(entity.cons.valid()){
|
||||
entity.heat = Mathf.lerpDelta(entity.heat, 1f, 0.01f);
|
||||
}else{
|
||||
entity.heat = Mathf.lerpDelta(entity.heat, 0f, 0.01f);
|
||||
}
|
||||
|
||||
if(entity.heat > 0.6f && Timers.get(timerApply, applyTime)){
|
||||
Units.getNearby(tile.getTeam(), tile.drawx(), tile.drawy(), range, unit -> {
|
||||
unit.applyEffect(status, intensity);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getEntity(){
|
||||
return new ProjectorEntity();
|
||||
}
|
||||
|
||||
public class ProjectorEntity extends TileEntity{
|
||||
public float heat;
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
package io.anuke.mindustry.world.blocks.units;
|
||||
|
||||
import io.anuke.mindustry.content.StatusEffects;
|
||||
|
||||
public class ShieldProjector extends Projector{
|
||||
|
||||
public ShieldProjector(String name){
|
||||
super(name);
|
||||
|
||||
status = StatusEffects.shielded;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user