mirror of
https://github.com/Melledy/Grasscutter.git
synced 2024-11-27 07:34:27 +00:00
Implement hack for event source in triggers
This commit is contained in:
parent
df1b65b8a8
commit
02653620d4
@ -15,6 +15,8 @@ import emu.grasscutter.server.packet.send.PacketDungeonChallengeBeginNotify;
|
|||||||
import emu.grasscutter.server.packet.send.PacketDungeonChallengeFinishNotify;
|
import emu.grasscutter.server.packet.send.PacketDungeonChallengeFinishNotify;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|
||||||
@ -85,6 +87,7 @@ public class WorldChallenge {
|
|||||||
this.finish(true);
|
this.finish(true);
|
||||||
|
|
||||||
var scene = this.getScene();
|
var scene = this.getScene();
|
||||||
|
var scriptManager = scene.getScriptManager();
|
||||||
var dungeonManager = scene.getDungeonManager();
|
var dungeonManager = scene.getDungeonManager();
|
||||||
if (dungeonManager != null && dungeonManager.getDungeonData() != null) {
|
if (dungeonManager != null && dungeonManager.getDungeonData() != null) {
|
||||||
scene
|
scene
|
||||||
@ -99,12 +102,22 @@ public class WorldChallenge {
|
|||||||
String.valueOf(this.getChallengeId())));
|
String.valueOf(this.getChallengeId())));
|
||||||
}
|
}
|
||||||
|
|
||||||
scene
|
// TODO: record the time in PARAM2 and used in action
|
||||||
.getScriptManager()
|
// TODO: Set 'eventSource' in script arguments.
|
||||||
.callEvent(
|
// Event source should be set to '1' for timer challenges.
|
||||||
// TODO record the time in PARAM2 and used in action
|
|
||||||
new ScriptArgs(this.getGroup().id, EventType.EVENT_CHALLENGE_SUCCESS)
|
var eventSource = new AtomicReference<>("");
|
||||||
.setParam2(finishedTime));
|
// TODO: This is a hack to get the event source.
|
||||||
|
// This should be properly implemented.
|
||||||
|
scriptManager.getTriggersByEvent(EventType.EVENT_CHALLENGE_SUCCESS)
|
||||||
|
.forEach(trigger -> {
|
||||||
|
if (trigger.currentGroup.id == this.getGroup().id) {
|
||||||
|
eventSource.set(trigger.getSource());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
scriptManager.callEvent(new ScriptArgs(this.getGroup().id, EventType.EVENT_CHALLENGE_SUCCESS)
|
||||||
|
.setParam2(finishedTime).setEventSource(eventSource.get()));
|
||||||
|
|
||||||
this.getScene()
|
this.getScene()
|
||||||
.triggerDungeonEvent(
|
.triggerDungeonEvent(
|
||||||
DungeonPassConditionType.DUNGEON_COND_FINISH_CHALLENGE,
|
DungeonPassConditionType.DUNGEON_COND_FINISH_CHALLENGE,
|
||||||
@ -118,9 +131,21 @@ public class WorldChallenge {
|
|||||||
if (!this.inProgress()) return;
|
if (!this.inProgress()) return;
|
||||||
this.finish(false);
|
this.finish(false);
|
||||||
|
|
||||||
this.getScene()
|
// TODO: Set 'eventSource' in script arguments.
|
||||||
.getScriptManager()
|
// Event source should be set to '1' for timer challenges.
|
||||||
.callEvent(new ScriptArgs(this.getGroup().id, EventType.EVENT_CHALLENGE_FAIL));
|
var eventSource = new AtomicReference<>("");
|
||||||
|
// TODO: This is a hack to get the event source.
|
||||||
|
// This should be properly implemented.
|
||||||
|
var scriptManager = this.getScene().getScriptManager();
|
||||||
|
scriptManager.getTriggersByEvent(EventType.EVENT_CHALLENGE_FAIL)
|
||||||
|
.forEach(trigger -> {
|
||||||
|
if (trigger.currentGroup.id == this.getGroup().id) {
|
||||||
|
eventSource.set(trigger.getSource());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
scriptManager.callEvent(new ScriptArgs(this.getGroup().id, EventType.EVENT_CHALLENGE_FAIL)
|
||||||
|
.setEventSource(eventSource.get()));
|
||||||
challengeTriggers.forEach(t -> t.onFinish(this));
|
challengeTriggers.forEach(t -> t.onFinish(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user