mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-01-23 13:32:58 +08:00
Format code [skip actions]
This commit is contained in:
parent
98fbc4e512
commit
4320bc7d29
@ -268,14 +268,16 @@ public final class ResourceLoader {
|
|||||||
|
|
||||||
private static void loadRoutes() {
|
private static void loadRoutes() {
|
||||||
try {
|
try {
|
||||||
Files.newDirectoryStream(getResourcePath("BinOutput/LevelDesign/Routes/"),"*.json")
|
Files.newDirectoryStream(getResourcePath("BinOutput/LevelDesign/Routes/"), "*.json")
|
||||||
.forEach(
|
.forEach(
|
||||||
path -> {
|
path -> {
|
||||||
try {
|
try {
|
||||||
val data = JsonUtils.loadToClass(path, SceneRoutes.class);
|
val data = JsonUtils.loadToClass(path, SceneRoutes.class);
|
||||||
val routesArray = data.getRoutes();
|
val routesArray = data.getRoutes();
|
||||||
if (routesArray == null) return;
|
if (routesArray == null) return;
|
||||||
val routesMap = GameData.getSceneRouteData().getOrDefault(data.getSceneId(), new Int2ObjectOpenHashMap<>());
|
val routesMap =
|
||||||
|
GameData.getSceneRouteData()
|
||||||
|
.getOrDefault(data.getSceneId(), new Int2ObjectOpenHashMap<>());
|
||||||
for (Route route : routesArray) {
|
for (Route route : routesArray) {
|
||||||
routesMap.put(route.getLocalId(), route);
|
routesMap.put(route.getLocalId(), route);
|
||||||
}
|
}
|
||||||
|
@ -248,32 +248,57 @@ public class EntityGadget extends EntityBaseGadget {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(routeConfig instanceof ConfigRoute configRoute) {
|
if (routeConfig instanceof ConfigRoute configRoute) {
|
||||||
var route = this.getScene().getSceneRouteById(configRoute.getRouteId());
|
var route = this.getScene().getSceneRouteById(configRoute.getRouteId());
|
||||||
if(route != null) {
|
if (route != null) {
|
||||||
var points = route.getPoints();
|
var points = route.getPoints();
|
||||||
val currIndex = configRoute.getStartIndex();
|
val currIndex = configRoute.getStartIndex();
|
||||||
|
|
||||||
Position prevpos;
|
Position prevpos;
|
||||||
if(currIndex == 0) {
|
if (currIndex == 0) {
|
||||||
prevpos = getPosition();
|
prevpos = getPosition();
|
||||||
this.getScene().getScriptManager().callEvent(new ScriptArgs(this.getGroupId(), EventType.EVENT_PLATFORM_REACH_POINT, this.getConfigId(), configRoute.getRouteId()).setParam3(0).setEventSource(this.getConfigId()));
|
this.getScene()
|
||||||
}else {
|
.getScriptManager()
|
||||||
|
.callEvent(
|
||||||
|
new ScriptArgs(
|
||||||
|
this.getGroupId(),
|
||||||
|
EventType.EVENT_PLATFORM_REACH_POINT,
|
||||||
|
this.getConfigId(),
|
||||||
|
configRoute.getRouteId())
|
||||||
|
.setParam3(0)
|
||||||
|
.setEventSource(this.getConfigId()));
|
||||||
|
} else {
|
||||||
prevpos = points[currIndex].getPos();
|
prevpos = points[currIndex].getPos();
|
||||||
}
|
}
|
||||||
|
|
||||||
double time = 0;
|
double time = 0;
|
||||||
for(var i = currIndex; i < points.length;++i) {
|
for (var i = currIndex; i < points.length; ++i) {
|
||||||
time += points[i].getPos().computeDistance(prevpos) / points[i].getTargetVelocity();
|
time += points[i].getPos().computeDistance(prevpos) / points[i].getTargetVelocity();
|
||||||
prevpos = points[i].getPos();
|
prevpos = points[i].getPos();
|
||||||
val I = i;
|
val I = i;
|
||||||
configRoute.getScheduledIndexes().add(this.getScene().getScheduler().scheduleDelayedTask(() -> {
|
configRoute
|
||||||
if(points[I].isHasReachEvent() && I > currIndex) {
|
.getScheduledIndexes()
|
||||||
this.getScene().getScriptManager().callEvent(new ScriptArgs(this.getGroupId(), EventType.EVENT_PLATFORM_REACH_POINT, this.getConfigId(), configRoute.getRouteId()).setParam3(I).setEventSource(this.getConfigId()));
|
.add(
|
||||||
|
this.getScene()
|
||||||
|
.getScheduler()
|
||||||
|
.scheduleDelayedTask(
|
||||||
|
() -> {
|
||||||
|
if (points[I].isHasReachEvent() && I > currIndex) {
|
||||||
|
this.getScene()
|
||||||
|
.getScriptManager()
|
||||||
|
.callEvent(
|
||||||
|
new ScriptArgs(
|
||||||
|
this.getGroupId(),
|
||||||
|
EventType.EVENT_PLATFORM_REACH_POINT,
|
||||||
|
this.getConfigId(),
|
||||||
|
configRoute.getRouteId())
|
||||||
|
.setParam3(I)
|
||||||
|
.setEventSource(this.getConfigId()));
|
||||||
}
|
}
|
||||||
configRoute.setStartIndex(I);
|
configRoute.setStartIndex(I);
|
||||||
this.position.set(points[I].getPos());
|
this.position.set(points[I].getPos());
|
||||||
},(int)time));
|
},
|
||||||
|
(int) time));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -294,8 +319,8 @@ public class EntityGadget extends EntityBaseGadget {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(routeConfig instanceof ConfigRoute configRoute) {
|
if (routeConfig instanceof ConfigRoute configRoute) {
|
||||||
for(var task : configRoute.getScheduledIndexes()) {
|
for (var task : configRoute.getScheduledIndexes()) {
|
||||||
this.getScene().getScheduler().cancelTask(task);
|
this.getScene().getScheduler().cancelTask(task);
|
||||||
}
|
}
|
||||||
configRoute.getScheduledIndexes().clear();
|
configRoute.getScheduledIndexes().clear();
|
||||||
|
@ -4,10 +4,10 @@ import emu.grasscutter.game.world.Position;
|
|||||||
import emu.grasscutter.net.proto.MovingPlatformTypeOuterClass;
|
import emu.grasscutter.net.proto.MovingPlatformTypeOuterClass;
|
||||||
import emu.grasscutter.net.proto.PlatformInfoOuterClass;
|
import emu.grasscutter.net.proto.PlatformInfoOuterClass;
|
||||||
import emu.grasscutter.scripts.data.SceneGadget;
|
import emu.grasscutter.scripts.data.SceneGadget;
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Setter;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
public class ConfigRoute extends BaseRoute {
|
public class ConfigRoute extends BaseRoute {
|
||||||
|
|
||||||
|
@ -536,7 +536,7 @@ public final class Scene {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!isPaused) {
|
if (!isPaused) {
|
||||||
this.getScheduler().runTasks();
|
this.getScheduler().runTasks();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user