HZ related stuff
parent
128f677d0e
commit
8c9696a3f9
|
|
@ -7,10 +7,12 @@ import engine.net.DispatchMessage;
|
|||
import engine.net.client.msg.HotzoneChangeMsg;
|
||||
import engine.net.client.msg.chat.ChatSystemMsg;
|
||||
import engine.objects.*;
|
||||
import engine.server.MBServerStatics;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
|
|
@ -169,8 +171,33 @@ public class HotzoneManager {
|
|||
}
|
||||
|
||||
public static void pulse(){
|
||||
if(HotzoneManager.playersPresent == null){
|
||||
if(HotzoneManager.playersPresent == null)
|
||||
HotzoneManager.playersPresent = new HashMap<>();
|
||||
|
||||
if(ZoneManager.hotZone == null)
|
||||
return;
|
||||
|
||||
HashSet<AbstractWorldObject> inRange = WorldGrid.getObjectsInRangePartial(ZoneManager.hotZone.getLoc(),ZoneManager.hotZone.getBounds().getHalfExtents().x * 2, MBServerStatics.MASK_PLAYER);
|
||||
for(AbstractWorldObject awo : inRange){
|
||||
PlayerCharacter pc = (PlayerCharacter)awo;
|
||||
Guild nation = pc.guild.getNation();
|
||||
if(HotzoneManager.playersPresent.containsKey(nation)){
|
||||
//nation already here, add to list
|
||||
if(HotzoneManager.playersPresent.get(nation).contains(pc)){
|
||||
if(HotzoneManager.playersPresent.get(nation).size() >= 5){
|
||||
//more than 5, boot player out
|
||||
pc.setLoc(pc.bindLoc);
|
||||
pc.teleport(pc.bindLoc);
|
||||
}else {
|
||||
//less than 5, allow player in
|
||||
HotzoneManager.playersPresent.get(nation).add(pc);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
ArrayList<PlayerCharacter> newList = new ArrayList<>();
|
||||
newList.add(pc);
|
||||
HotzoneManager.playersPresent.put(nation,newList);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -143,6 +143,11 @@ public enum SimulationManager {
|
|||
}
|
||||
}catch(Exception e){
|
||||
|
||||
}
|
||||
try{
|
||||
HotzoneManager.pulse();
|
||||
}catch(Exception e){
|
||||
|
||||
}
|
||||
SimulationManager.executionTime = Duration.between(startTime, Instant.now());
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue