Clean up entity regions

This commit is contained in:
KingRainbow44
2023-05-04 21:28:45 -04:00
parent 8ee3dec5df
commit 0b87485bdf
2 changed files with 26 additions and 27 deletions

View File

@@ -643,30 +643,32 @@ public class SceneScriptManager {
.toList();
entities.forEach(region::addEntity);
int targetID = 0;
var targetId = 0;
if (entities.size() > 0) {
targetID = entities.get(0).getId();
targetId = entities.get(0).getId();
}
if (region.hasNewEntities()) {
if (region.entityHasEntered()) {
Grasscutter.getLogger()
.trace("Call EVENT_ENTER_REGION_{}", region.getMetaRegion().config_id);
callEvent(
this.callEvent(
new ScriptArgs(region.getGroupId(), EventType.EVENT_ENTER_REGION, region.getConfigId())
.setSourceEntityId(region.getId())
.setTargetEntityId(targetID));
.setTargetEntityId(targetId));
region.resetNewEntities();
}
for (int entityId : region.getEntities()) {
if (getScene().getEntityById(entityId) == null
|| !region.getMetaRegion().contains(getScene().getEntityById(entityId).getPosition())) {
for (var entityId : region.getEntities()) {
var entity = this.getScene().getEntityById(entityId);
if (entity == null || !region.getMetaRegion()
.contains(entity.getPosition())) {
region.removeEntity(entityId);
}
}
if (region.entityLeave()) {
callEvent(
if (region.entityHasLeft()) {
this.callEvent(
new ScriptArgs(region.getGroupId(), EventType.EVENT_LEAVE_REGION, region.getConfigId())
.setSourceEntityId(region.getId())
.setTargetEntityId(region.getFirstEntityId()));