Browse Source

powers thread

lakebane-master
fatboy 7 months ago
parent
commit
bb6828ec8e
  1. 13
      src/engine/gameManager/PowersManager.java
  2. 3
      src/engine/net/client/ClientMessagePump.java
  3. 24
      src/engine/workthreads/PowersThread.java

13
src/engine/gameManager/PowersManager.java

@ -60,6 +60,19 @@ public enum PowersManager {
public static String[] siegeBuffs = new String[]{"ART-004A","ARM-112A"}; public static String[] siegeBuffs = new String[]{"ART-004A","ARM-112A"};
public static String[] siegeDeBuffs = new String[]{"ACM-003A","WRT-003A"}; public static String[] siegeDeBuffs = new String[]{"ACM-003A","WRT-003A"};
public static ArrayList<PowerQueObject> static_power_que = new ArrayList<>();
public static class PowerQueObject{
public PowerQueObject(PerformActionMsg inmsg,ClientConnection inorigin,boolean insendCastToSelf){
this.msg = inmsg;
this.origin = inorigin;
this.sendCastToSelf = insendCastToSelf;
}
public PerformActionMsg msg;
public ClientConnection origin;
public boolean sendCastToSelf;
}
private PowersManager() { private PowersManager() {
} }

3
src/engine/net/client/ClientMessagePump.java

@ -1921,7 +1921,8 @@ public class ClientMessagePump implements NetMsgHandler {
} }
break; break;
case POWER: case POWER:
PowersManager.usePower((PerformActionMsg) msg, origin, false); //PowersManager.usePower((PerformActionMsg) msg, origin, false);
PowersManager.static_power_que.add(new PowersManager.PowerQueObject((PerformActionMsg) msg, origin, false));
break; break;
case REQUESTMELEEATTACK: case REQUESTMELEEATTACK:
CombatManager.setAttackTarget((AttackCmdMsg) msg, origin); CombatManager.setAttackTarget((AttackCmdMsg) msg, origin);

24
src/engine/workthreads/PowersThread.java

@ -0,0 +1,24 @@
package engine.workthreads;
import engine.gameManager.PowersManager;
import java.util.ArrayList;
public class PowersThread implements Runnable {
public PowersThread(){
}
@Override
public void run() {
while(true){
ArrayList<PowersManager.PowerQueObject> purge = new ArrayList<>();
for(PowersManager.PowerQueObject pqo : PowersManager.static_power_que){
purge.add(pqo);
PowersManager.usePower(pqo.msg,pqo.origin,pqo.sendCastToSelf);
}
PowersManager.static_power_que.removeAll(purge);
}
}
}
Loading…
Cancel
Save