Added logic payEnter command
This commit is contained in:
@@ -1765,6 +1765,7 @@ lenum.itemdrop = Drop an item.
|
|||||||
lenum.itemtake = Take an item from a building.
|
lenum.itemtake = Take an item from a building.
|
||||||
lenum.paydrop = Drop current payload.
|
lenum.paydrop = Drop current payload.
|
||||||
lenum.paytake = Pick up payload at current location.
|
lenum.paytake = Pick up payload at current location.
|
||||||
|
lenum.payenter = Enter/land on the payload block the unit is on.
|
||||||
lenum.flag = Numeric unit flag.
|
lenum.flag = Numeric unit flag.
|
||||||
lenum.mine = Mine at a position.
|
lenum.mine = Mine at a position.
|
||||||
lenum.build = Build a structure.
|
lenum.build = Build a structure.
|
||||||
|
|||||||
@@ -404,25 +404,27 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
|||||||
//region handler methods
|
//region handler methods
|
||||||
|
|
||||||
/** @return whether the player can select (but not actually control) this building. */
|
/** @return whether the player can select (but not actually control) this building. */
|
||||||
public boolean canControlSelect(Player player){
|
public boolean canControlSelect(Unit player){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Called when a player control-selects this building - not called for ControlBlock subclasses. */
|
/** Called when a player control-selects this building - not called for ControlBlock subclasses. */
|
||||||
public void onControlSelect(Player player){
|
public void onControlSelect(Unit player){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void acceptPlayerPayload(Player player, Cons<Payload> grabber){
|
public void handleUnitPayload(Unit player, Cons<Payload> grabber){
|
||||||
Fx.spawn.at(player);
|
Fx.spawn.at(player);
|
||||||
var unit = player.unit();
|
|
||||||
player.clearUnit();
|
if(player.isPlayer()){
|
||||||
//player.deathTimer = Player.deathDelay + 1f; //for instant respawn
|
player.getPlayer().clearUnit();
|
||||||
unit.remove();
|
}
|
||||||
grabber.get(new UnitPayload(unit));
|
|
||||||
Fx.unitDrop.at(unit);
|
player.remove();
|
||||||
|
grabber.get(new UnitPayload(player));
|
||||||
|
Fx.unitDrop.at(player);
|
||||||
if(Vars.net.client()){
|
if(Vars.net.client()){
|
||||||
Vars.netClient.clearRemovedEntity(unit.id);
|
Vars.netClient.clearRemovedEntity(player.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -367,8 +367,18 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
|||||||
throw new ValidateException(player, "Player cannot control a building.");
|
throw new ValidateException(player, "Player cannot control a building.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(player.team() == build.team && build.canControlSelect(player)){
|
if(player.team() == build.team && build.canControlSelect(player.unit())){
|
||||||
build.onControlSelect(player);
|
build.onControlSelect(player.unit());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Remote(called = Loc.server)
|
||||||
|
public static void unitBuildingControlSelect(Unit unit, Building build){
|
||||||
|
if(unit == null || unit.dead()) return;
|
||||||
|
|
||||||
|
//client skips checks to prevent ghost units
|
||||||
|
if(unit.team() == build.team && (net.client() || build.canControlSelect(unit))){
|
||||||
|
build.onControlSelect(unit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1112,7 +1122,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
|||||||
|
|
||||||
public @Nullable Building selectedControlBuild(){
|
public @Nullable Building selectedControlBuild(){
|
||||||
Building build = world.buildWorld(Core.input.mouseWorld().x, Core.input.mouseWorld().y);
|
Building build = world.buildWorld(Core.input.mouseWorld().x, Core.input.mouseWorld().y);
|
||||||
if(build != null && !player.dead() && build.canControlSelect(player) && build.team == player.team()){
|
if(build != null && !player.dead() && build.canControlSelect(player.unit()) && build.team == player.team()){
|
||||||
return build;
|
return build;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -448,6 +448,12 @@ public class LExecutor{
|
|||||||
ai.payTimer = LogicAI.transferDelay;
|
ai.payTimer = LogicAI.transferDelay;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
case payEnter -> {
|
||||||
|
Building build = world.buildWorld(unit.x, unit.y);
|
||||||
|
if(build != null && unit.team() == build.team && build.canControlSelect(unit)){
|
||||||
|
Call.unitBuildingControlSelect(unit, build);
|
||||||
|
}
|
||||||
|
}
|
||||||
case build -> {
|
case build -> {
|
||||||
if(state.rules.logicUnitBuild && unit.canBuild() && exec.obj(p3) instanceof Block block && block.canBeBuilt()){
|
if(state.rules.logicUnitBuild && unit.canBuild() && exec.obj(p3) instanceof Block block && block.canBeBuilt()){
|
||||||
int x = World.toTile(x1 - block.offset/tilesize), y = World.toTile(y1 - block.offset/tilesize);
|
int x = World.toTile(x1 - block.offset/tilesize), y = World.toTile(y1 - block.offset/tilesize);
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ public enum LUnitControl{
|
|||||||
itemTake("from", "item", "amount"),
|
itemTake("from", "item", "amount"),
|
||||||
payDrop,
|
payDrop,
|
||||||
payTake("takeUnits"),
|
payTake("takeUnits"),
|
||||||
|
payEnter,
|
||||||
mine("x", "y"),
|
mine("x", "y"),
|
||||||
flag("value"),
|
flag("value"),
|
||||||
build("x", "y", "block", "rotation", "config"),
|
build("x", "y", "block", "rotation", "config"),
|
||||||
|
|||||||
@@ -74,13 +74,13 @@ public class PayloadConveyor extends Block{
|
|||||||
public int step = -1, stepAccepted = -1;
|
public int step = -1, stepAccepted = -1;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canControlSelect(Player player){
|
public boolean canControlSelect(Unit player){
|
||||||
return this.item == null && !player.unit().spawnedByCore && player.unit().hitSize / tilesize <= payloadLimit && player.tileOn() != null && player.tileOn().build == this;
|
return this.item == null && !player.spawnedByCore && player.hitSize / tilesize <= payloadLimit && player.tileOn() != null && player.tileOn().build == this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onControlSelect(Player player){
|
public void onControlSelect(Unit player){
|
||||||
acceptPlayerPayload(player, p -> item = p);
|
handleUnitPayload(player, p -> item = p);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -78,16 +78,16 @@ public class PayloadBlock extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canControlSelect(Player player){
|
public boolean canControlSelect(Unit player){
|
||||||
return !player.unit().spawnedByCore && this.payload == null && acceptUnitPayload(player.unit()) && player.tileOn() != null && player.tileOn().build == this;
|
return !player.spawnedByCore && this.payload == null && acceptUnitPayload(player) && player.tileOn() != null && player.tileOn().build == this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onControlSelect(Player player){
|
public void onControlSelect(Unit player){
|
||||||
float x = player.x, y = player.y;
|
float x = player.x, y = player.y;
|
||||||
acceptPlayerPayload(player, p -> payload = (T)p);
|
handleUnitPayload(player, p -> payload = (T)p);
|
||||||
this.payVector.set(x, y).sub(this).clamp(-size * tilesize / 2f, -size * tilesize / 2f, size * tilesize / 2f, size * tilesize / 2f);
|
this.payVector.set(x, y).sub(this).clamp(-size * tilesize / 2f, -size * tilesize / 2f, size * tilesize / 2f, size * tilesize / 2f);
|
||||||
this.payRotation = player.unit().rotation;
|
this.payRotation = player.rotation;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -242,12 +242,15 @@ public class CoreBlock extends StorageBlock{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canControlSelect(Player player){
|
public boolean canControlSelect(Unit player){
|
||||||
return true;
|
return player.isPlayer();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onControlSelect(Player player){
|
public void onControlSelect(Unit unit){
|
||||||
|
if(!unit.isPlayer()) return;
|
||||||
|
Player player = unit.getPlayer();
|
||||||
|
|
||||||
Fx.spawn.at(player);
|
Fx.spawn.at(player);
|
||||||
if(net.client() && player == Vars.player){
|
if(net.client() && player == Vars.player){
|
||||||
control.input.controlledType = null;
|
control.input.controlledType = null;
|
||||||
|
|||||||
Reference in New Issue
Block a user