Add events to support scene group substitution (#2413)

* Add events to support scene group substitution

* make event members private with getter/setter

* delete stray unused var
This commit is contained in:
longfruit
2023-10-31 18:52:01 -07:00
committed by GitHub
parent 269f7b4fbf
commit cf6fb275be
9 changed files with 130 additions and 29 deletions

View File

@@ -252,12 +252,16 @@ public class EntityMonster extends GameEntity {
if (scriptManager.isInit() && this.getGroupId() > 0) {
Optional.ofNullable(scriptManager.getScriptMonsterSpawnService()).ifPresent(s -> s.onMonsterDead(this));
// prevent spawn monster after success
/*if (challenge.map(c -> c.inProgress()).orElse(true)) {
scriptManager.callEvent(new ScriptArgs(EventType.EVENT_ANY_MONSTER_DIE, this.getConfigId()).setGroupId(this.getGroupId()));
} else if (getScene().getChallenge() == null) {
}*/
scriptManager.callEvent(new ScriptArgs(this.getGroupId(), EventType.EVENT_ANY_MONSTER_DIE, this.getConfigId()));
// Ensure each EVENT_ANY_MONSTER_DIE runs to completion.
// Multiple such events firing at the same time may cause
// the same lua trigger to fire multiple times, when it
// should happen only once.
var future = scriptManager.callEvent(new ScriptArgs(this.getGroupId(), EventType.EVENT_ANY_MONSTER_DIE, this.getConfigId()));
try {
future.get();
} catch (Exception e) {
e.printStackTrace();
}
}
// Battle Pass trigger
scene.getPlayers().forEach(p -> p.getBattlePassManager().triggerMission(WatcherTriggerType.TRIGGER_MONSTER_DIE, this.getMonsterId(), 1));