Sensors, SetProp, and SetRule (#9943)
* some fun things for world proc only * fix the format artifact * SetProp and reformating * Wildcard imports * Wildcard imports * velocity conversion * compacting description Co-authored-by: Anuken <arnukren@gmail.com> * Update core/src/mindustry/world/blocks/defense/turrets/Turret.java --------- Co-authored-by: Anuken <arnukren@gmail.com>
This commit is contained in:
@@ -2438,6 +2438,7 @@ lenum.shootp = Shoot at a unit/building with velocity prediction.
|
|||||||
lenum.config = Building configuration, e.g. sorter item.
|
lenum.config = Building configuration, e.g. sorter item.
|
||||||
lenum.enabled = Whether the block is enabled.
|
lenum.enabled = Whether the block is enabled.
|
||||||
|
|
||||||
|
laccess.currentammotype = Current ammo item/liquid of a turret.
|
||||||
laccess.color = Illuminator color.
|
laccess.color = Illuminator color.
|
||||||
laccess.controller = Unit controller. If processor controlled, returns processor.\nOtherwise, returns the unit itself.
|
laccess.controller = Unit controller. If processor controlled, returns processor.\nOtherwise, returns the unit itself.
|
||||||
laccess.dead = Whether a unit/building is dead or no longer valid.
|
laccess.dead = Whether a unit/building is dead or no longer valid.
|
||||||
|
|||||||
@@ -214,6 +214,8 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
|
|||||||
case ammoCapacity -> type.ammoCapacity;
|
case ammoCapacity -> type.ammoCapacity;
|
||||||
case x -> World.conv(x);
|
case x -> World.conv(x);
|
||||||
case y -> World.conv(y);
|
case y -> World.conv(y);
|
||||||
|
case velocityX -> vel.x * 60f / tilesize;
|
||||||
|
case velocityY -> vel.y * 60f / tilesize;
|
||||||
case dead -> dead || !isAdded() ? 1 : 0;
|
case dead -> dead || !isAdded() ? 1 : 0;
|
||||||
case team -> team.id;
|
case team -> team.id;
|
||||||
case shooting -> isShooting() ? 1 : 0;
|
case shooting -> isShooting() ? 1 : 0;
|
||||||
@@ -282,6 +284,8 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
|
|||||||
y = World.unconv((float)value);
|
y = World.unconv((float)value);
|
||||||
if(!isLocal()) snapInterpolation();
|
if(!isLocal()) snapInterpolation();
|
||||||
}
|
}
|
||||||
|
case velocityX -> vel.x = (float)(value * tilesize / 60d);
|
||||||
|
case velocityY -> vel.y = (float)(value * tilesize / 60d);
|
||||||
case rotation -> rotation = (float)value;
|
case rotation -> rotation = (float)value;
|
||||||
case team -> {
|
case team -> {
|
||||||
if(!net.client()){
|
if(!net.client()){
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ public enum LAccess{
|
|||||||
powerNetOut,
|
powerNetOut,
|
||||||
ammo,
|
ammo,
|
||||||
ammoCapacity,
|
ammoCapacity,
|
||||||
|
currentAmmoType,
|
||||||
health,
|
health,
|
||||||
maxHealth,
|
maxHealth,
|
||||||
heat,
|
heat,
|
||||||
@@ -28,6 +29,8 @@ public enum LAccess{
|
|||||||
rotation,
|
rotation,
|
||||||
x,
|
x,
|
||||||
y,
|
y,
|
||||||
|
velocityX,
|
||||||
|
velocityY,
|
||||||
shootX,
|
shootX,
|
||||||
shootY,
|
shootY,
|
||||||
cameraX,
|
cameraX,
|
||||||
@@ -68,7 +71,7 @@ public enum LAccess{
|
|||||||
all = values(),
|
all = values(),
|
||||||
senseable = Seq.select(all, t -> t.params.length <= 1).toArray(LAccess.class),
|
senseable = Seq.select(all, t -> t.params.length <= 1).toArray(LAccess.class),
|
||||||
controls = Seq.select(all, t -> t.params.length > 0).toArray(LAccess.class),
|
controls = Seq.select(all, t -> t.params.length > 0).toArray(LAccess.class),
|
||||||
settable = {x, y, rotation, speed, armor, health, shield, team, flag, totalPower, payloadType};
|
settable = {x, y, velocityX, velocityY, rotation, speed, armor, health, shield, team, flag, totalPower, payloadType};
|
||||||
|
|
||||||
LAccess(String... params){
|
LAccess(String... params){
|
||||||
this.params = params;
|
this.params = params;
|
||||||
@@ -79,5 +82,4 @@ public enum LAccess{
|
|||||||
this.params = params;
|
this.params = params;
|
||||||
isObj = obj;
|
isObj = obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1497,6 +1497,7 @@ public class LExecutor{
|
|||||||
}
|
}
|
||||||
case ambientLight -> state.rules.ambientLight.fromDouble(value.num());
|
case ambientLight -> state.rules.ambientLight.fromDouble(value.num());
|
||||||
case solarMultiplier -> state.rules.solarMultiplier = Math.max(value.numf(), 0f);
|
case solarMultiplier -> state.rules.solarMultiplier = Math.max(value.numf(), 0f);
|
||||||
|
case dragMultiplier -> state.rules.dragMultiplier = Math.max(value.numf(), 0f);
|
||||||
case ban -> {
|
case ban -> {
|
||||||
Object cont = value.obj();
|
Object cont = value.obj();
|
||||||
if(cont instanceof Block b){
|
if(cont instanceof Block b){
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ public enum LogicRule{
|
|||||||
lighting,
|
lighting,
|
||||||
ambientLight,
|
ambientLight,
|
||||||
solarMultiplier,
|
solarMultiplier,
|
||||||
|
dragMultiplier,
|
||||||
ban,
|
ban,
|
||||||
unban,
|
unban,
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import arc.struct.*;
|
|||||||
import mindustry.content.*;
|
import mindustry.content.*;
|
||||||
import mindustry.entities.bullet.*;
|
import mindustry.entities.bullet.*;
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
|
import mindustry.logic.*;
|
||||||
import mindustry.type.*;
|
import mindustry.type.*;
|
||||||
import mindustry.world.consumers.*;
|
import mindustry.world.consumers.*;
|
||||||
import mindustry.world.meta.*;
|
import mindustry.world.meta.*;
|
||||||
@@ -77,6 +78,14 @@ public class ContinuousLiquidTurret extends ContinuousTurret{
|
|||||||
super.updateTile();
|
super.updateTile();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object senseObject(LAccess sensor){
|
||||||
|
return switch(sensor){
|
||||||
|
case currentAmmoType -> liquids.current();
|
||||||
|
default -> super.senseObject(sensor);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canConsume(){
|
public boolean canConsume(){
|
||||||
return hasCorrectAmmo() && super.canConsume();
|
return hasCorrectAmmo() && super.canConsume();
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import mindustry.entities.bullet.*;
|
|||||||
import mindustry.game.EventType.*;
|
import mindustry.game.EventType.*;
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.graphics.*;
|
import mindustry.graphics.*;
|
||||||
|
import mindustry.logic.*;
|
||||||
import mindustry.type.*;
|
import mindustry.type.*;
|
||||||
import mindustry.ui.*;
|
import mindustry.ui.*;
|
||||||
import mindustry.world.consumers.*;
|
import mindustry.world.consumers.*;
|
||||||
@@ -107,6 +108,14 @@ public class ItemTurret extends Turret{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object senseObject(LAccess sensor){
|
||||||
|
return switch(sensor){
|
||||||
|
case currentAmmoType -> ammo.size > 0 ? ((ItemEntry)ammo.peek()).item : null;
|
||||||
|
default -> super.senseObject(sensor);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateTile(){
|
public void updateTile(){
|
||||||
unit.ammo((float)unit.type().ammoCapacity * totalAmmo / maxAmmo);
|
unit.ammo((float)unit.type().ammoCapacity * totalAmmo / maxAmmo);
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import mindustry.core.*;
|
|||||||
import mindustry.entities.*;
|
import mindustry.entities.*;
|
||||||
import mindustry.entities.bullet.*;
|
import mindustry.entities.bullet.*;
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
|
import mindustry.logic.*;
|
||||||
import mindustry.type.*;
|
import mindustry.type.*;
|
||||||
import mindustry.world.*;
|
import mindustry.world.*;
|
||||||
import mindustry.world.consumers.*;
|
import mindustry.world.consumers.*;
|
||||||
@@ -72,6 +73,14 @@ public class LiquidTurret extends Turret{
|
|||||||
super.updateTile();
|
super.updateTile();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object senseObject(LAccess sensor){
|
||||||
|
return switch(sensor){
|
||||||
|
case currentAmmoType -> liquids.current();
|
||||||
|
default -> super.senseObject(sensor);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void findTarget(){
|
protected void findTarget(){
|
||||||
if(extinguish && liquids.current().canExtinguish()){
|
if(extinguish && liquids.current().canExtinguish()){
|
||||||
|
|||||||
Reference in New Issue
Block a user