Implement Hartie suggestions

This commit is contained in:
scooterboo 2024-11-07 03:51:25 -08:00
parent 978ee9c940
commit e05bb01e0c
2 changed files with 12 additions and 0 deletions

View File

@ -10,6 +10,7 @@ import org.anime_game_servers.multi_proto.gi.messages.scene.entity.SceneEntityIn
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;
@Getter
public class EntityRegion extends GameEntity{
@ -72,6 +73,16 @@ public class EntityRegion extends GameEntity{
this.entityLeave = false;
this.leftEntities.clear();
}
public void clearDeadEntities() {
entities.removeAll(entities.stream()
.filter(entity -> this.getScene().getEntityById(entity.id) == null)
.collect(Collectors.toSet()));
notContainEntities.removeAll(notContainEntities.stream()
.filter(entity -> this.getScene().getEntityById(entity.id) == null)
.collect(Collectors.toSet()));
}
@Override public Int2FloatMap getFightProperties() {return null;}
@Override public Position getPosition() {return position;}

View File

@ -570,6 +570,7 @@ public class SceneScriptManager {
for (var region : this.regions.values()) {
val metaRegion = region.getMetaRegion();
region.clearDeadEntities();
getScene().getEntities().values().stream()
.filter(e -> e.getEntityType() == EntityType.Avatar)