This commit is contained in:
Ilya246
2022-06-14 04:49:13 +04:00
committed by GitHub
parent 1be8f11ec8
commit 58bfd0e46c
5 changed files with 7 additions and 5 deletions

View File

@@ -42,6 +42,8 @@ public class Rules{
public boolean coreCapture = false;
/** Whether reactors can explode and damage other blocks. */
public boolean reactorExplosions = true;
/** Whether to allow manual unit control. */
public boolean possessionAllowed = true;
/** Whether schematics are allowed. */
public boolean schematicsAllowed = true;
/** Whether friendly explosions can occur and set fire/damage other blocks. */

View File

@@ -127,7 +127,7 @@ public class OverlayRenderer{
Sized select = input.selectedUnit();
if(select == null) select = input.selectedControlBuild();
if(!Core.input.keyDown(Binding.control)) select = null;
if(!Core.input.keyDown(Binding.control) || !state.rules.possessionAllowed) select = null;
unitFade = Mathf.lerpDelta(unitFade, Mathf.num(select != null), 0.1f);

View File

@@ -254,7 +254,7 @@ public class DesktopInput extends InputHandler{
//validate commanding units
selectedUnits.removeAll(u -> !u.isCommandable() || !u.isValid());
if(!scene.hasMouse() && !locked){
if(!scene.hasMouse() && !locked && state.rules.possessionAllowed){
if(Core.input.keyDown(Binding.control) && Core.input.keyTap(Binding.select)){
Unit on = selectedUnit();
var build = selectedControlBuild();

View File

@@ -475,7 +475,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
if(player == null) return;
//make sure player is allowed to control the unit
if(net.server() && !netServer.admins.allowAction(player, ActionType.control, action -> action.unit = unit)){
if(net.server() && (!state.rules.possessionAllowed || !netServer.admins.allowAction(player, ActionType.control, action -> action.unit = unit))){
throw new ValidateException(player, "Player cannot control a unit.");
}

View File

@@ -658,10 +658,10 @@ public class MobileInput extends InputHandler implements GestureListener{
payloadTarget = null;
//control a unit/block detected on first tap of double-tap
if(unitTapped != null){
if(unitTapped != null && state.rules.possessionAllowed){
Call.unitControl(player, unitTapped);
recentRespawnTimer = 1f;
}else if(buildingTapped != null){
}else if(buildingTapped != null && state.rules.possessionAllowed){
Call.buildingControlSelect(player, buildingTapped);
recentRespawnTimer = 1f;
}else if(!checkConfigTap() && !tryBeginMine(cursor)){