From 8c9696a3f93c9756c30064eeb7e502d33853b409 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 16 Mar 2025 15:19:32 -0500 Subject: [PATCH] HZ related stuff --- src/engine/gameManager/HotzoneManager.java | 29 ++++++++++++++++++- src/engine/gameManager/SimulationManager.java | 5 ++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/engine/gameManager/HotzoneManager.java b/src/engine/gameManager/HotzoneManager.java index ad9b3125..fbf0d17c 100644 --- a/src/engine/gameManager/HotzoneManager.java +++ b/src/engine/gameManager/HotzoneManager.java @@ -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 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 newList = new ArrayList<>(); + newList.add(pc); + HotzoneManager.playersPresent.put(nation,newList); + } } } } diff --git a/src/engine/gameManager/SimulationManager.java b/src/engine/gameManager/SimulationManager.java index 40763ef8..1b5346b8 100644 --- a/src/engine/gameManager/SimulationManager.java +++ b/src/engine/gameManager/SimulationManager.java @@ -143,6 +143,11 @@ public enum SimulationManager { } }catch(Exception e){ + } + try{ + HotzoneManager.pulse(); + }catch(Exception e){ + } SimulationManager.executionTime = Duration.between(startTime, Instant.now());