mirror of
https://github.com/Anuken/Mindustry.git
synced 2026-01-25 22:12:16 -08:00
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:
parent
e07a739ae2
commit
82bcf5966e
8 changed files with 38 additions and 2 deletions
|
|
@ -2438,6 +2438,7 @@ lenum.shootp = Shoot at a unit/building with velocity prediction.
|
|||
lenum.config = Building configuration, e.g. sorter item.
|
||||
lenum.enabled = Whether the block is enabled.
|
||||
|
||||
laccess.currentammotype = Current ammo item/liquid of a turret.
|
||||
laccess.color = Illuminator color.
|
||||
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.
|
||||
|
|
|
|||
|
|
@ -214,6 +214,8 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
|
|||
case ammoCapacity -> type.ammoCapacity;
|
||||
case x -> World.conv(x);
|
||||
case y -> World.conv(y);
|
||||
case velocityX -> vel.x * 60f / tilesize;
|
||||
case velocityY -> vel.y * 60f / tilesize;
|
||||
case dead -> dead || !isAdded() ? 1 : 0;
|
||||
case team -> team.id;
|
||||
case shooting -> isShooting() ? 1 : 0;
|
||||
|
|
@ -282,6 +284,8 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
|
|||
y = World.unconv((float)value);
|
||||
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 team -> {
|
||||
if(!net.client()){
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ public enum LAccess{
|
|||
powerNetOut,
|
||||
ammo,
|
||||
ammoCapacity,
|
||||
currentAmmoType,
|
||||
health,
|
||||
maxHealth,
|
||||
heat,
|
||||
|
|
@ -28,6 +29,8 @@ public enum LAccess{
|
|||
rotation,
|
||||
x,
|
||||
y,
|
||||
velocityX,
|
||||
velocityY,
|
||||
shootX,
|
||||
shootY,
|
||||
cameraX,
|
||||
|
|
@ -68,7 +71,7 @@ public enum LAccess{
|
|||
all = values(),
|
||||
senseable = Seq.select(all, t -> t.params.length <= 1).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){
|
||||
this.params = params;
|
||||
|
|
@ -79,5 +82,4 @@ public enum LAccess{
|
|||
this.params = params;
|
||||
isObj = obj;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1497,6 +1497,7 @@ public class LExecutor{
|
|||
}
|
||||
case ambientLight -> state.rules.ambientLight.fromDouble(value.num());
|
||||
case solarMultiplier -> state.rules.solarMultiplier = Math.max(value.numf(), 0f);
|
||||
case dragMultiplier -> state.rules.dragMultiplier = Math.max(value.numf(), 0f);
|
||||
case ban -> {
|
||||
Object cont = value.obj();
|
||||
if(cont instanceof Block b){
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ public enum LogicRule{
|
|||
lighting,
|
||||
ambientLight,
|
||||
solarMultiplier,
|
||||
dragMultiplier,
|
||||
ban,
|
||||
unban,
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import arc.struct.*;
|
|||
import mindustry.content.*;
|
||||
import mindustry.entities.bullet.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.logic.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.world.consumers.*;
|
||||
import mindustry.world.meta.*;
|
||||
|
|
@ -77,6 +78,14 @@ public class ContinuousLiquidTurret extends ContinuousTurret{
|
|||
super.updateTile();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object senseObject(LAccess sensor){
|
||||
return switch(sensor){
|
||||
case currentAmmoType -> liquids.current();
|
||||
default -> super.senseObject(sensor);
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConsume(){
|
||||
return hasCorrectAmmo() && super.canConsume();
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import mindustry.entities.bullet.*;
|
|||
import mindustry.game.EventType.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.logic.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.ui.*;
|
||||
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
|
||||
public void updateTile(){
|
||||
unit.ammo((float)unit.type().ammoCapacity * totalAmmo / maxAmmo);
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import mindustry.core.*;
|
|||
import mindustry.entities.*;
|
||||
import mindustry.entities.bullet.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.logic.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.consumers.*;
|
||||
|
|
@ -72,6 +73,14 @@ public class LiquidTurret extends Turret{
|
|||
super.updateTile();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object senseObject(LAccess sensor){
|
||||
return switch(sensor){
|
||||
case currentAmmoType -> liquids.current();
|
||||
default -> super.senseObject(sensor);
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void findTarget(){
|
||||
if(extinguish && liquids.current().canExtinguish()){
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue