Unfinished/WIP turret

This commit is contained in:
Anuken
2022-06-16 13:46:20 -04:00
parent 9807974de3
commit 52b5ed57bf
12 changed files with 158 additions and 8 deletions
@@ -38,11 +38,8 @@ public class ItemTurret extends Turret{
/** Makes copies of all bullets and limits their range. */
public void limitRange(float margin){
for(var entry : ammoTypes.copy().entries()){
var bullet = entry.value;
float realRange = bullet.rangeChange + range;
//doesn't handle drag
bullet.lifetime = (realRange + margin) / bullet.speed;
for(var entry : ammoTypes.entries()){
limitRange(entry.value, margin);
}
}
@@ -19,6 +19,10 @@ public class PowerTurret extends Turret{
stats.add(Stat.ammo, StatValues.ammo(ObjectMap.of(this, shootType)));
}
public void limitRange(float margin){
limitRange(shootType, margin);
}
public class PowerTurretBuild extends TurretBuild{
@Override
@@ -186,6 +186,12 @@ public class Turret extends ReloadTurret{
drawer.getRegionsToOutline(this, out);
}
public void limitRange(BulletType bullet, float margin){
float realRange = bullet.rangeChange + range;
//doesn't handle drag
bullet.lifetime = (realRange + margin) / bullet.speed;
}
public static abstract class AmmoEntry{
public int amount;
@@ -1,11 +1,15 @@
package mindustry.world.blocks.environment;
import arc.*;
import arc.graphics.*;
import arc.graphics.g2d.*;
import arc.util.*;
import mindustry.graphics.*;
import mindustry.graphics.MultiPacker.*;
import mindustry.world.*;
/**
* Do not use in mods. This class provides no new functionality, and is only used for the Mindustry sprite generator.
* Use the standard Floor class instead.
* Blends water together with a standard floor. No new mechanics.
* */
public class ShallowLiquid extends Floor{
public @Nullable Floor liquidBase, floorBase;
@@ -26,4 +30,29 @@ public class ShallowLiquid extends Floor{
cacheLayer = liquidBase.cacheLayer;
shallow = true;
}
@Override
public void createIcons(MultiPacker packer){
//TODO might not be necessary at all, but I am not sure yet
//super.createIcons(packer);
if(liquidBase != null && floorBase != null){
var overlay = Core.atlas.getPixmap(liquidBase.region);
int index = 0;
for(TextureRegion region : floorBase.variantRegions()){
var res = Core.atlas.getPixmap(region).crop();
for(int x = 0; x < res.width; x++){
for(int y = 0; y < res.height; y++){
res.setRaw(x, y, Pixmap.blend((overlay.getRaw(x, y) & 0xffffff00) | (int)(liquidOpacity * 255), res.getRaw(x, y)));
}
}
String baseName = this.name + "" + (++index);
packer.add(PageType.environment, baseName, res);
packer.add(PageType.editor, "editor-" + baseName, res);
res.dispose();
}
}
}
}