Skip to content

Commit

Permalink
WIP #2: Expose APIs for weapons lock and auto beams
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Brindamour committed Sep 18, 2016
1 parent b8ace3e commit 7909b6c
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ public interface EngineeringConsoleManager {
Property<Map<OrdnanceType, Integer>> getOrdnanceCount();

Property<Boolean> getAutoDamcon();

Property<Boolean> getWeaponsLocked();

Property<Boolean> getAutoBeams();

void setSystemEnergyAllocated(ShipSystem system, int amount);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,17 @@ public Property<Boolean> getAutoDamcon() {
}
private final SettableProperty<Boolean> autoDamcon = new SettableProperty<>(true);

public Property<Boolean> getWeaponsLocked() {
return weaponsLocked;
}
private final SettableProperty<Boolean> weaponsLocked = new SettableProperty<>(false);

@Override
public Property<Boolean> getAutoBeams() {
return autoBeams;
}
private final SettableProperty<Boolean> autoBeams = new SettableProperty<>(true);

@Override
protected void updateSystemEnergyAllocated(ShipSystem system, int amount) {
Map<ShipSystem, Integer> energyAllocated = new HashMap<>(FakeEngineeringConsoleManager.this.systemEnergyAllocated.get());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import com.walkertribe.ian.enums.OrdnanceType;
import com.walkertribe.ian.enums.ShipSystem;
import com.walkertribe.ian.enums.TargetingMode;
import com.walkertribe.ian.protocol.core.eng.EngGridUpdatePacket.DamconStatus;
import com.walkertribe.ian.protocol.core.eng.EngSendDamconPacket;
import com.walkertribe.ian.protocol.core.eng.EngSetAutoDamconPacket;
Expand Down Expand Up @@ -339,6 +340,31 @@ public Property<Boolean> getAutoDamcon() {
return this.worldAwareServer.getSystemManager().getAutoDamcon();
}, systemManagerChangeObservable);

@Override
public Property<Boolean> getWeaponsLocked() {
return weaponsLocked;
}
private final DerivedProperty<Boolean> weaponsLocked = new DerivedProperty<>( () -> {
if (this.worldAwareServer == null || this.worldAwareServer.getSystemManager().getPlayerShip(1) == null) {
return false;
}
return this.worldAwareServer.getSystemManager().getPlayerShip(1).getWeaponsTarget() != 0;
}, systemManagerChangeObservable);

@Override
public Property<Boolean> getAutoBeams() {
return autoBeams;
}
private final DerivedProperty<Boolean> autoBeams = new DerivedProperty<>( () -> {
if (this.worldAwareServer == null || this.worldAwareServer.getSystemManager().getPlayerShip(1) == null) {
return true;
}
//assume AUTO if null
//DRAGONS: current bug in IAN - AUTO and MANUAL are switched
return this.worldAwareServer.getSystemManager().getPlayerShip(1).getTargetingMode() != TargetingMode.AUTO;
}, systemManagerChangeObservable);



@Override
public void incrementSystemEnergyAllocated(ShipSystem system, int amount) {
Expand Down
2 changes: 2 additions & 0 deletions src/com/brindyblitz/artemis/engconsole/ui/InGamePanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ public void handleKeyPress(KeyEvent e) {
System.out.println("Front Shields: " + this.engineeringConsoleManager.getSystemEnergyAllocated().get().get(FORE_SHIELDS) + "%");
System.out.println("Rear Shields: " + this.engineeringConsoleManager.getSystemEnergyAllocated().get().get(AFT_SHIELDS) + "%");
System.out.println("Auto Damcon: " + this.engineeringConsoleManager.getAutoDamcon().get());
System.out.println("Weapons Locked: " + this.engineeringConsoleManager.getWeaponsLocked().get());
System.out.println("Auto Beams: " + this.engineeringConsoleManager.getAutoBeams().get());

// for (Entry<GridCoord, Float> entry : this.engineeringConsoleManager.getGridHealth().entrySet()) {
// System.out.println(entry.getKey() + " = " + entry.getValue());
Expand Down

0 comments on commit 7909b6c

Please sign in to comment.