Run spotlessApply on previous commit

This commit is contained in:
KingRainbow44 2023-04-23 23:12:01 -04:00
parent c9d6225194
commit e85d269518
No known key found for this signature in database
GPG Key ID: FC2CB64B00D257BE
19 changed files with 579 additions and 276 deletions

View File

@ -1,13 +1,12 @@
package emu.grasscutter.data.binout;
import static emu.grasscutter.game.ability.AbilityLocalIdGenerator.*;
import emu.grasscutter.data.binout.AbilityModifier.AbilityModifierAction;
import emu.grasscutter.game.ability.AbilityLocalIdGenerator;
import java.util.HashMap;
import java.util.Map;
import static emu.grasscutter.game.ability.AbilityLocalIdGenerator.*;
public class AbilityData {
public String abilityName;
public Map<String, AbilityModifier> modifiers;
@ -19,44 +18,67 @@ public class AbilityData {
// onAbilityStart
// onKill
public final Map<Integer, AbilityModifierAction> localIdToAction
= new HashMap<>();
public final Map<Integer, AbilityModifierAction> localIdToAction = new HashMap<>();
private boolean _initialized = false;
public void initialize() {
if(_initialized) return;
if (_initialized) return;
_initialized = true;
if(modifiers == null) return;
if (modifiers == null) return;
var _modifiers = modifiers.values().toArray(new AbilityModifier[0]);
var modifierIndex = 0; for (var modifier : _modifiers) {
var modifierIndex = 0;
for (var modifier : _modifiers) {
long configIndex = 0L;
this.initializeActionSubCategory(modifierIndex, configIndex++, modifier.onAdded, localIdToAction);
this.initializeActionSubCategory(modifierIndex, configIndex++, modifier.onRemoved, localIdToAction);
this.initializeActionSubCategory(modifierIndex, configIndex++, modifier.onBeingHit, localIdToAction);
this.initializeActionSubCategory(modifierIndex, configIndex++, modifier.onAttackLanded, localIdToAction);
this.initializeActionSubCategory(modifierIndex, configIndex++, modifier.onHittingOther, localIdToAction);
this.initializeActionSubCategory(modifierIndex, configIndex++, modifier.onThinkInterval, localIdToAction);
this.initializeActionSubCategory(modifierIndex, configIndex++, modifier.onKill, localIdToAction);
this.initializeActionSubCategory(modifierIndex, configIndex++, modifier.onCrash, localIdToAction);
this.initializeActionSubCategory(modifierIndex, configIndex++, modifier.onAvatarIn, localIdToAction);
this.initializeActionSubCategory(modifierIndex, configIndex++, modifier.onAvatarOut, localIdToAction);
this.initializeActionSubCategory(modifierIndex, configIndex++, modifier.onReconnect, localIdToAction);
this.initializeActionSubCategory(modifierIndex, configIndex++, modifier.onChangeAuthority, localIdToAction);
this.initializeActionSubCategory(modifierIndex, configIndex++, modifier.onVehicleIn, localIdToAction);
this.initializeActionSubCategory(modifierIndex, configIndex++, modifier.onVehicleOut, localIdToAction);
this.initializeActionSubCategory(modifierIndex, configIndex++, modifier.onZoneEnter, localIdToAction);
this.initializeActionSubCategory(modifierIndex, configIndex++, modifier.onZoneExit, localIdToAction);
this.initializeActionSubCategory(modifierIndex, configIndex++, modifier.onHeal, localIdToAction);
this.initializeActionSubCategory(modifierIndex, configIndex++, modifier.onBeingHealed, localIdToAction);
this.initializeActionSubCategory(
modifierIndex, configIndex++, modifier.onAdded, localIdToAction);
this.initializeActionSubCategory(
modifierIndex, configIndex++, modifier.onRemoved, localIdToAction);
this.initializeActionSubCategory(
modifierIndex, configIndex++, modifier.onBeingHit, localIdToAction);
this.initializeActionSubCategory(
modifierIndex, configIndex++, modifier.onAttackLanded, localIdToAction);
this.initializeActionSubCategory(
modifierIndex, configIndex++, modifier.onHittingOther, localIdToAction);
this.initializeActionSubCategory(
modifierIndex, configIndex++, modifier.onThinkInterval, localIdToAction);
this.initializeActionSubCategory(
modifierIndex, configIndex++, modifier.onKill, localIdToAction);
this.initializeActionSubCategory(
modifierIndex, configIndex++, modifier.onCrash, localIdToAction);
this.initializeActionSubCategory(
modifierIndex, configIndex++, modifier.onAvatarIn, localIdToAction);
this.initializeActionSubCategory(
modifierIndex, configIndex++, modifier.onAvatarOut, localIdToAction);
this.initializeActionSubCategory(
modifierIndex, configIndex++, modifier.onReconnect, localIdToAction);
this.initializeActionSubCategory(
modifierIndex, configIndex++, modifier.onChangeAuthority, localIdToAction);
this.initializeActionSubCategory(
modifierIndex, configIndex++, modifier.onVehicleIn, localIdToAction);
this.initializeActionSubCategory(
modifierIndex, configIndex++, modifier.onVehicleOut, localIdToAction);
this.initializeActionSubCategory(
modifierIndex, configIndex++, modifier.onZoneEnter, localIdToAction);
this.initializeActionSubCategory(
modifierIndex, configIndex++, modifier.onZoneExit, localIdToAction);
this.initializeActionSubCategory(
modifierIndex, configIndex++, modifier.onHeal, localIdToAction);
this.initializeActionSubCategory(
modifierIndex, configIndex++, modifier.onBeingHealed, localIdToAction);
modifierIndex++;
}
}
private void initializeActionSubCategory(long modifierIndex, long configIndex, AbilityModifierAction[] actions, Map<Integer, AbilityModifierAction> localIdToAction) {
if(actions == null) return;
private void initializeActionSubCategory(
long modifierIndex,
long configIndex,
AbilityModifierAction[] actions,
Map<Integer, AbilityModifierAction> localIdToAction) {
if (actions == null) return;
var generator = new AbilityLocalIdGenerator(ConfigAbilitySubContainerType.MODIFIER_ACTION);
generator.modifierIndex = modifierIndex;

View File

@ -1,19 +1,23 @@
package emu.grasscutter.data.binout;
import java.io.Serializable;
import com.google.gson.annotations.SerializedName;
import emu.grasscutter.data.common.DynamicFloat;
import emu.grasscutter.game.props.ElementType;
import java.io.Serializable;
public class AbilityModifier implements Serializable {
private static final long serialVersionUID = -2001232313615923575L;
@SerializedName(value="onAdded", alternate={"KCICDEJLIJD"})
@SerializedName(
value = "onAdded",
alternate = {"KCICDEJLIJD"})
public AbilityModifierAction[] onAdded;
@SerializedName(value="onThinkInterval", alternate={"PBDDACFFPOE"})
@SerializedName(
value = "onThinkInterval",
alternate = {"PBDDACFFPOE"})
public AbilityModifierAction[] onThinkInterval;
public AbilityModifierAction[] onRemoved;
public AbilityModifierAction[] onBeingHit;
public AbilityModifierAction[] onAttackLanded;
@ -38,74 +42,241 @@ public class AbilityModifier implements Serializable {
public static class AbilityModifierAction implements Serializable {
public enum Type {
ActCameraRadialBlur, ActCameraShake, AddAvatarSkillInfo, AddChargeBarValue,
AddClimateMeter, AddElementDurability, AddGlobalValue, AddGlobalValueToTarget,
AddRegionalPlayVarValue, ApplyModifier, AttachAbilityStateResistance, AttachBulletAimPoint,
AttachEffect, AttachEffectFirework, AttachElementTypeResistance, AttachModifier,
AttachUIEffect, AvatarCameraParam, AvatarEnterCameraShot, AvatarEnterFocus,
AvatarEnterViewBias, AvatarExitCameraShot, AvatarExitClimb, AvatarExitFocus,
AvatarExitViewBias, AvatarShareCDSkillStart, AvatarSkillStart, BroadcastNeuronStimulate,
CalcDvalinS04RebornPoint, CallLuaTask, ChangeEnviroWeather, ChangeFollowDampTime,
ChangeGadgetUIInteractHint, ChangePlayMode, ChangeTag, ChangeUGCRayTag,
ClearEndura, ClearGlobalPos, ClearGlobalValue, ClearLocalGadgets,
ClearLockTarget, ClearPos, ConfigAbilityAction, ControlEmotion,
CopyGlobalValue, CreateGadget, CreateMovingPlatform, CreateTile,
DamageByAttackValue, DebugLog, DestroyTile, DoBlink,
DoTileAction, DoWatcherSystemAction, DoWidgetSystemAction, DropSubfield,
DummyAction, DungeonFogEffects, ElementAttachForActivityGacha, EnableAIStealthy,
EnableAfterImage, EnableAvatarFlyStateTrail, EnableAvatarMoveOnWater, EnableBulletCollisionPluginTrigger,
EnableGadgetIntee, EnableHeadControl, EnableHitBoxByName, EnableMainInterface,
EnablePartControl, EnablePositionSynchronization, EnablePushColliderName, EnableRocketJump,
EnableSceneTransformByName, EnterCameraLock, EntityDoSkill, EquipAffixStart,
ExecuteGadgetLua, FireAISoundEvent, FireChargeBarEffect, FireEffect,
FireEffectFirework, FireEffectForStorm, FireFishingEvent, FireHitEffect,
FireSubEmitterEffect, FireUIEffect, FixedMonsterRushMove, ForceAirStateFly,
ForceEnableShakeOffButton, GenerateElemBall, GetFightProperty, GetInteractIdToGlobalValue,
GetPos, HealHP, HideUIBillBoard, IgnoreMoveColToRockCol,
KillGadget, KillPlayEntity, KillSelf, KillServerGadget,
LoseHP, ModifyAvatarSkillCD, ModifyVehicleSkillCD, PlayEmoSync,
Predicated, PushDvalinS01Process, PushInterActionByConfigPath, PushPos,
Randomed, ReTriggerAISkillInitialCD, RefreshUICombatBarLayout, RegisterAIActionPoint,
ReleaseAIActionPoint, RemoveAvatarSkillInfo, RemoveModifier, RemoveModifierByAbilityStateResistanceID,
RemoveServerBuff, RemoveUniqueModifier, RemoveVelocityForce, Repeated,
ResetAIAttackTarget, ResetAIResistTauntLevel, ResetAIThreatBroadcastRange, ResetAnimatorTrigger,
ReviveDeadAvatar, ReviveElemEnergy, ReviveStamina, SectorCityManeuver,
SendEffectTrigger, SendEffectTriggerToLineEffect, SendEvtElectricCoreMoveEnterP1, SendEvtElectricCoreMoveInterrupt,
ServerLuaCall, ServerLuaTriggerEvent, ServerMonsterLog, SetAIHitFeeling,
SetAISkillCDAvailableNow, SetAISkillCDMultiplier, SetAISkillGCD, SetAnimatorBool,
SetAnimatorFloat, SetAnimatorInt, SetAnimatorTrigger, SetAvatarCanShakeOff,
SetAvatarHitBuckets, SetCanDieImmediately, SetChargeBarValue, SetDvalinS01FlyState,
SetEmissionScaler, SetEntityScale, SetExtraAbilityEnable, SetExtraAbilityState,
SetGlobalDir, SetGlobalPos, SetGlobalValue, SetGlobalValueByTargetDistance,
SetGlobalValueToOverrideMap, SetKeepInAirVelocityForce, SetMaterialParamFloatByTransform, SetNeuronEnable,
SetOverrideMapValue, SetPartControlTarget, SetPoseBool, SetPoseFloat,
SetPoseInt, SetRandomOverrideMapValue, SetRegionalPlayVarValue, SetSelfAttackTarget,
SetSkillAnchor, SetSpecialCamera, SetSurroundAnchor, SetSystemValueToOverrideMap,
SetTargetNumToGlobalValue, SetUICombatBarAsh, SetUICombatBarSpark, SetVelocityIgnoreAirGY,
SetWeaponAttachPointRealName, SetWeaponBindState, ShowExtraAbility, ShowProgressBarAction,
ShowReminder, ShowScreenEffect, ShowTextMap, ShowUICombatBar,
StartDither, SumTargetWeightToSelfGlobalValue, Summon, SyncToStageScript,
TriggerAbility, TriggerAttackEvent, TriggerAttackTargetMapEvent, TriggerAudio,
TriggerAuxWeaponTrans, TriggerBullet, TriggerCreateGadgetToEquipPart, TriggerDropEquipParts,
TriggerFaceAnimation, TriggerGadgetInteractive, TriggerHideWeapon, TriggerSetCastShadow,
TriggerSetPassThrough, TriggerSetRenderersEnable, TriggerSetShadowRamp, TriggerSetVisible,
TriggerTaunt, TriggerThrowEquipPart, TriggerUGCGadgetMove, TryFindBlinkPoint,
TryFindBlinkPointByBorn, TryTriggerPlatformStartMove, TurnDirection, TurnDirectionToPos,
UpdateReactionDamage, UseSkillEliteSet, WidgetSkillStart;
ActCameraRadialBlur,
ActCameraShake,
AddAvatarSkillInfo,
AddChargeBarValue,
AddClimateMeter,
AddElementDurability,
AddGlobalValue,
AddGlobalValueToTarget,
AddRegionalPlayVarValue,
ApplyModifier,
AttachAbilityStateResistance,
AttachBulletAimPoint,
AttachEffect,
AttachEffectFirework,
AttachElementTypeResistance,
AttachModifier,
AttachUIEffect,
AvatarCameraParam,
AvatarEnterCameraShot,
AvatarEnterFocus,
AvatarEnterViewBias,
AvatarExitCameraShot,
AvatarExitClimb,
AvatarExitFocus,
AvatarExitViewBias,
AvatarShareCDSkillStart,
AvatarSkillStart,
BroadcastNeuronStimulate,
CalcDvalinS04RebornPoint,
CallLuaTask,
ChangeEnviroWeather,
ChangeFollowDampTime,
ChangeGadgetUIInteractHint,
ChangePlayMode,
ChangeTag,
ChangeUGCRayTag,
ClearEndura,
ClearGlobalPos,
ClearGlobalValue,
ClearLocalGadgets,
ClearLockTarget,
ClearPos,
ConfigAbilityAction,
ControlEmotion,
CopyGlobalValue,
CreateGadget,
CreateMovingPlatform,
CreateTile,
DamageByAttackValue,
DebugLog,
DestroyTile,
DoBlink,
DoTileAction,
DoWatcherSystemAction,
DoWidgetSystemAction,
DropSubfield,
DummyAction,
DungeonFogEffects,
ElementAttachForActivityGacha,
EnableAIStealthy,
EnableAfterImage,
EnableAvatarFlyStateTrail,
EnableAvatarMoveOnWater,
EnableBulletCollisionPluginTrigger,
EnableGadgetIntee,
EnableHeadControl,
EnableHitBoxByName,
EnableMainInterface,
EnablePartControl,
EnablePositionSynchronization,
EnablePushColliderName,
EnableRocketJump,
EnableSceneTransformByName,
EnterCameraLock,
EntityDoSkill,
EquipAffixStart,
ExecuteGadgetLua,
FireAISoundEvent,
FireChargeBarEffect,
FireEffect,
FireEffectFirework,
FireEffectForStorm,
FireFishingEvent,
FireHitEffect,
FireSubEmitterEffect,
FireUIEffect,
FixedMonsterRushMove,
ForceAirStateFly,
ForceEnableShakeOffButton,
GenerateElemBall,
GetFightProperty,
GetInteractIdToGlobalValue,
GetPos,
HealHP,
HideUIBillBoard,
IgnoreMoveColToRockCol,
KillGadget,
KillPlayEntity,
KillSelf,
KillServerGadget,
LoseHP,
ModifyAvatarSkillCD,
ModifyVehicleSkillCD,
PlayEmoSync,
Predicated,
PushDvalinS01Process,
PushInterActionByConfigPath,
PushPos,
Randomed,
ReTriggerAISkillInitialCD,
RefreshUICombatBarLayout,
RegisterAIActionPoint,
ReleaseAIActionPoint,
RemoveAvatarSkillInfo,
RemoveModifier,
RemoveModifierByAbilityStateResistanceID,
RemoveServerBuff,
RemoveUniqueModifier,
RemoveVelocityForce,
Repeated,
ResetAIAttackTarget,
ResetAIResistTauntLevel,
ResetAIThreatBroadcastRange,
ResetAnimatorTrigger,
ReviveDeadAvatar,
ReviveElemEnergy,
ReviveStamina,
SectorCityManeuver,
SendEffectTrigger,
SendEffectTriggerToLineEffect,
SendEvtElectricCoreMoveEnterP1,
SendEvtElectricCoreMoveInterrupt,
ServerLuaCall,
ServerLuaTriggerEvent,
ServerMonsterLog,
SetAIHitFeeling,
SetAISkillCDAvailableNow,
SetAISkillCDMultiplier,
SetAISkillGCD,
SetAnimatorBool,
SetAnimatorFloat,
SetAnimatorInt,
SetAnimatorTrigger,
SetAvatarCanShakeOff,
SetAvatarHitBuckets,
SetCanDieImmediately,
SetChargeBarValue,
SetDvalinS01FlyState,
SetEmissionScaler,
SetEntityScale,
SetExtraAbilityEnable,
SetExtraAbilityState,
SetGlobalDir,
SetGlobalPos,
SetGlobalValue,
SetGlobalValueByTargetDistance,
SetGlobalValueToOverrideMap,
SetKeepInAirVelocityForce,
SetMaterialParamFloatByTransform,
SetNeuronEnable,
SetOverrideMapValue,
SetPartControlTarget,
SetPoseBool,
SetPoseFloat,
SetPoseInt,
SetRandomOverrideMapValue,
SetRegionalPlayVarValue,
SetSelfAttackTarget,
SetSkillAnchor,
SetSpecialCamera,
SetSurroundAnchor,
SetSystemValueToOverrideMap,
SetTargetNumToGlobalValue,
SetUICombatBarAsh,
SetUICombatBarSpark,
SetVelocityIgnoreAirGY,
SetWeaponAttachPointRealName,
SetWeaponBindState,
ShowExtraAbility,
ShowProgressBarAction,
ShowReminder,
ShowScreenEffect,
ShowTextMap,
ShowUICombatBar,
StartDither,
SumTargetWeightToSelfGlobalValue,
Summon,
SyncToStageScript,
TriggerAbility,
TriggerAttackEvent,
TriggerAttackTargetMapEvent,
TriggerAudio,
TriggerAuxWeaponTrans,
TriggerBullet,
TriggerCreateGadgetToEquipPart,
TriggerDropEquipParts,
TriggerFaceAnimation,
TriggerGadgetInteractive,
TriggerHideWeapon,
TriggerSetCastShadow,
TriggerSetPassThrough,
TriggerSetRenderersEnable,
TriggerSetShadowRamp,
TriggerSetVisible,
TriggerTaunt,
TriggerThrowEquipPart,
TriggerUGCGadgetMove,
TryFindBlinkPoint,
TryFindBlinkPointByBorn,
TryTriggerPlatformStartMove,
TurnDirection,
TurnDirectionToPos,
UpdateReactionDamage,
UseSkillEliteSet,
WidgetSkillStart;
}
@SerializedName("$type")
public Type type;
public String target;
@SerializedName(value = "amount", alternate = "PDLLIFICICJ")
public DynamicFloat amount = DynamicFloat.ZERO;
public DynamicFloat amountByCasterAttackRatio = DynamicFloat.ZERO;
public DynamicFloat amountByCasterCurrentHPRatio = DynamicFloat.ZERO;
public DynamicFloat amountByCasterMaxHPRatio = DynamicFloat.ZERO;
public DynamicFloat amountByGetDamage = DynamicFloat.ZERO;
public DynamicFloat amountByTargetCurrentHPRatio = DynamicFloat.ZERO;
public DynamicFloat amountByTargetMaxHPRatio = DynamicFloat.ZERO;
@SerializedName(value = "ignoreAbilityProperty", alternate = "HHFGADCJJDI")
public boolean ignoreAbilityProperty;
public String modifierName;
public int param1;
@ -113,7 +284,8 @@ public class AbilityModifier implements Serializable {
public int param3;
}
//The following should be implemented into DynamicFloat if older resource formats need to be supported
// The following should be implemented into DynamicFloat if older resource formats need to be
// supported
// public static class AbilityModifierValue {
// public boolean isFormula;
// public boolean isDynamic;

View File

@ -6,7 +6,6 @@ import emu.grasscutter.Grasscutter;
import emu.grasscutter.scripts.SceneIndexManager;
import emu.grasscutter.utils.GridPosition;
import emu.grasscutter.utils.Position;
import java.util.*;
public class Grid {
@ -15,14 +14,13 @@ public class Grid {
public Map<GridPosition, Set<Integer>> grid = new LinkedHashMap<>();
/**
* Creates an optimized cache of the grid.
*/
/** Creates an optimized cache of the grid. */
private void optimize() {
if (this.gridOptimized == null) {
var gridValues = new ArrayList<Map.Entry<GridPosition, Set<Integer>>>();
this.grid.forEach((k, v) -> gridValues.add(new AbstractMap.SimpleEntry<>(k, v)));
this.gridOptimized = SceneIndexManager.buildIndex(2, gridValues, entry -> entry.getKey().toPoint());
this.gridOptimized =
SceneIndexManager.buildIndex(2, gridValues, entry -> entry.getKey().toPoint());
}
}

View File

@ -1,12 +1,11 @@
package emu.grasscutter.game.ability;
import java.util.HashMap;
import java.util.Map;
import emu.grasscutter.data.binout.AbilityData;
import emu.grasscutter.game.entity.GameEntity;
import emu.grasscutter.server.event.entity.EntityDamageEvent;
import emu.grasscutter.utils.Utils;
import java.util.HashMap;
import java.util.Map;
import lombok.Getter;
public final class Ability {
@ -14,8 +13,7 @@ public final class Ability {
@Getter private GameEntity owner;
@Getter private AbilityManager manager;
@Getter private Map<String, AbilityModifierController> modifiers
= new HashMap<>();
@Getter private Map<String, AbilityModifierController> modifiers = new HashMap<>();
@Getter private int hash;

View File

@ -1,10 +1,9 @@
package emu.grasscutter.game.ability;
import emu.grasscutter.data.binout.AbilityModifier.AbilityModifierAction;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import emu.grasscutter.data.binout.AbilityModifier.AbilityModifierAction;
@Retention(RetentionPolicy.RUNTIME)
public @interface AbilityAction {
AbilityModifierAction.Type value();

View File

@ -2,9 +2,8 @@ package emu.grasscutter.game.ability;
import emu.grasscutter.Grasscutter;
import emu.grasscutter.data.binout.AbilityModifier.AbilityModifierAction;
import lombok.AllArgsConstructor;
import java.util.Map;
import lombok.AllArgsConstructor;
public final class AbilityLocalIdGenerator {
public ConfigAbilitySubContainerType type;
@ -13,13 +12,12 @@ public final class AbilityLocalIdGenerator {
public long mixinIndex = 0;
private long actionIndex = 0;
public AbilityLocalIdGenerator(ConfigAbilitySubContainerType type)
{
public AbilityLocalIdGenerator(ConfigAbilitySubContainerType type) {
this.type = type;
}
public void initializeActionLocalIds(AbilityModifierAction[] actions, Map<Integer, AbilityModifierAction> localIdToAction)
{
public void initializeActionLocalIds(
AbilityModifierAction[] actions, Map<Integer, AbilityModifierAction> localIdToAction) {
if (actions == null) return;
actionIndex = 0;
@ -44,7 +42,11 @@ public final class AbilityLocalIdGenerator {
return type.value + (modifierIndex << 3) + (configIndex << 9) + (actionIndex << 15);
}
case MODIFIER_MIXIN -> {
return type.value + (modifierIndex << 3) + (mixinIndex << 9) + (configIndex << 15) + (actionIndex << 21);
return type.value
+ (modifierIndex << 3)
+ (mixinIndex << 9)
+ (configIndex << 15)
+ (actionIndex << 21);
}
case NONE -> Grasscutter.getLogger().error("Ability local id generator using NONE type.");
}

View File

@ -13,29 +13,36 @@ import emu.grasscutter.game.player.BasePlayerManager;
import emu.grasscutter.game.player.Player;
import emu.grasscutter.game.quest.enums.QuestContent;
import emu.grasscutter.net.proto.AbilityInvokeEntryOuterClass.AbilityInvokeEntry;
import emu.grasscutter.net.proto.AbilityMetaAddAbilityOuterClass.AbilityMetaAddAbility;
import emu.grasscutter.net.proto.AbilityMetaModifierChangeOuterClass.AbilityMetaModifierChange;
import emu.grasscutter.net.proto.AbilityMetaModifierDurabilityChangeOuterClass.AbilityMetaModifierDurabilityChange;
import emu.grasscutter.net.proto.AbilityMetaReInitOverrideMapOuterClass.AbilityMetaReInitOverrideMap;
import emu.grasscutter.net.proto.AbilityMixinCostStaminaOuterClass.AbilityMixinCostStamina;
import emu.grasscutter.net.proto.AbilityScalarValueEntryOuterClass.AbilityScalarValueEntry;
import emu.grasscutter.net.proto.ModifierActionOuterClass.ModifierAction;
import io.netty.util.concurrent.FastThreadLocalThread;
import lombok.Getter;
import org.reflections.Reflections;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import lombok.Getter;
import org.reflections.Reflections;
public final class AbilityManager extends BasePlayerManager {
public static final ExecutorService eventExecutor;
static {
eventExecutor = new ThreadPoolExecutor(4, 4,
60, TimeUnit.SECONDS, new LinkedBlockingDeque<>(1000),
FastThreadLocalThread::new, new ThreadPoolExecutor.AbortPolicy());
eventExecutor =
new ThreadPoolExecutor(
4,
4,
60,
TimeUnit.SECONDS,
new LinkedBlockingDeque<>(1000),
FastThreadLocalThread::new,
new ThreadPoolExecutor.AbortPolicy());
}
private final HealAbilityManager healAbilityManager;
@ -52,9 +59,7 @@ public final class AbilityManager extends BasePlayerManager {
this.registerHandlers();
}
/**
* Registers all present ability handlers.
*/
/** Registers all present ability handlers. */
private void registerHandlers() {
var reflections = new Reflections("emu.grasscutter.game.ability.actions");
var handlerClasses = reflections.getSubTypesOf(AbilityActionHandler.class);
@ -77,13 +82,16 @@ public final class AbilityManager extends BasePlayerManager {
var handler = actionHandlers.get(action.type);
if (handler == null || ability == null) {
Grasscutter.getLogger().debug("Could not execute ability action {} at {}", action.type, ability);
Grasscutter.getLogger()
.debug("Could not execute ability action {} at {}", action.type, ability);
return;
}
eventExecutor.submit(() -> {
eventExecutor.submit(
() -> {
if (!handler.execute(ability, action)) {
Grasscutter.getLogger().debug("exec ability action failed {} at {}", action.type, ability);
Grasscutter.getLogger()
.debug("exec ability action failed {} at {}", action.type, ability);
}
});
}
@ -92,7 +100,13 @@ public final class AbilityManager extends BasePlayerManager {
this.healAbilityManager.healHandler(invoke);
if (invoke.getEntityId() == 67109298) {
Grasscutter.getLogger().info(invoke.getArgumentType() + " (" + invoke.getArgumentTypeValue() + "): " + invoke.getEntityId());
Grasscutter.getLogger()
.info(
invoke.getArgumentType()
+ " ("
+ invoke.getArgumentTypeValue()
+ "): "
+ invoke.getEntityId());
}
switch (invoke.getArgumentType()) {
@ -102,7 +116,8 @@ public final class AbilityManager extends BasePlayerManager {
case ABILITY_INVOKE_ARGUMENT_MIXIN_COST_STAMINA -> this.handleMixinCostStamina(invoke);
case ABILITY_INVOKE_ARGUMENT_ACTION_GENERATE_ELEM_BALL -> this.handleGenerateElemBall(invoke);
case ABILITY_INVOKE_ARGUMENT_META_GLOBAL_FLOAT_VALUE -> this.handleGlobalFloatValue(invoke);
case ABILITY_INVOKE_ARGUMENT_META_MODIFIER_DURABILITY_CHANGE -> this.handleModifierDurabilityChange(invoke);
case ABILITY_INVOKE_ARGUMENT_META_MODIFIER_DURABILITY_CHANGE -> this
.handleModifierDurabilityChange(invoke);
case ABILITY_INVOKE_ARGUMENT_META_ADD_NEW_ABILITY -> this.handleAddNewAbility(invoke);
case ABILITY_INVOKE_ARGUMENT_NONE -> this.handleInvoke(invoke);
default -> {}
@ -173,28 +188,38 @@ public final class AbilityManager extends BasePlayerManager {
}
var head = invoke.getHead();
Grasscutter.getLogger().debug("{} {} {}", head.getInstancedAbilityId(), entity.getInstanceToHash(), head.getLocalId());
Grasscutter.getLogger()
.debug(
"{} {} {}",
head.getInstancedAbilityId(),
entity.getInstanceToHash(),
head.getLocalId());
var hash = entity.getInstanceToHash().get(head.getInstancedAbilityId());
if (hash == null) {
var abilities = entity.getAbilities().values().toArray(new Ability[0]);
if(head.getInstancedAbilityId() <= abilities.length) {
if (head.getInstancedAbilityId() <= abilities.length) {
var ability = abilities[head.getInstancedAbilityId() - 1];
Grasscutter.getLogger().warn("-> {}", ability.getData().localIdToAction);
var action = ability.getData().localIdToAction.get(head.getLocalId());
if(action != null) ability.getManager().executeAction(ability, action);
if (action != null) ability.getManager().executeAction(ability, action);
}
return;
}
var stream = entity.getAbilities().values().stream()
.filter(a -> a.getHash() == hash ||
a.getData().abilityName == entity.getInstanceToName().get(head.getInstancedAbilityId()));
stream.forEach(ability -> {
var stream =
entity.getAbilities().values().stream()
.filter(
a ->
a.getHash() == hash
|| a.getData().abilityName
== entity.getInstanceToName().get(head.getInstancedAbilityId()));
stream.forEach(
ability -> {
var action = ability.getData().localIdToAction.get(head.getLocalId());
if(action != null) ability.getManager().executeAction(ability, action);
if (action != null) ability.getManager().executeAction(ability, action);
});
}
@ -248,7 +273,7 @@ public final class AbilityManager extends BasePlayerManager {
if (data.getAction() == ModifierAction.MODIFIER_ACTION_REMOVED) {
var ability = target.getAbilities().get(data.getParentAbilityName().getStr());
if(ability != null) {
if (ability != null) {
var modifier = ability.getModifiers().get(head.getInstancedModifierId());
if (modifier != null) {
modifier.onRemoved();
@ -257,13 +282,23 @@ public final class AbilityManager extends BasePlayerManager {
}
}
if(data.getAction() == ModifierAction.MODIFIER_ACTION_ADDED) {
if (data.getAction() == ModifierAction.MODIFIER_ACTION_ADDED) {
var modifierString = data.getParentAbilityName().getStr();
var hash = target.getInstanceToHash().get(head.getInstancedAbilityId());
if(hash == null) return;
if (hash == null) return;
target.getAbilities().values().stream().filter(a -> a.getHash() == hash || a.getData().abilityName == target.getInstanceToName().get(head.getInstancedAbilityId())).forEach(a -> {
a.getModifiers().keySet().stream().filter(key -> key.compareTo(modifierString) == 0).forEach(key -> {
target.getAbilities().values().stream()
.filter(
a ->
a.getHash() == hash
|| a.getData().abilityName
== target.getInstanceToName().get(head.getInstancedAbilityId()))
.forEach(
a -> {
a.getModifiers().keySet().stream()
.filter(key -> key.compareTo(modifierString) == 0)
.forEach(
key -> {
a.getModifiers().get(key).setLocalId(head.getInstancedModifierId());
});
});
@ -362,7 +397,8 @@ public final class AbilityManager extends BasePlayerManager {
}
}
private void handleModifierDurabilityChange(AbilityInvokeEntry invoke) throws InvalidProtocolBufferException {
private void handleModifierDurabilityChange(AbilityInvokeEntry invoke)
throws InvalidProtocolBufferException {
var target = this.player.getScene().getEntityById(invoke.getEntityId());
if (target == null) {
return;
@ -374,41 +410,53 @@ public final class AbilityManager extends BasePlayerManager {
}
var head = invoke.getHead();
if (head == null) {
return;
}
var hash = target.getInstanceToHash().get(head.getInstancedAbilityId());
if(hash == null) return;
target.getAbilities().values().stream().filter(a -> a.getHash() == hash || a.getData().abilityName == target.getInstanceToName().get(head.getInstancedAbilityId())).forEach(a -> {
a.getModifiers().values().stream().filter(m -> m.getLocalId() == head.getInstancedModifierId()).forEach(modifier -> {
if (hash == null) return;
target.getAbilities().values().stream()
.filter(
a ->
a.getHash() == hash
|| a.getData().abilityName
== target.getInstanceToName().get(head.getInstancedAbilityId()))
.forEach(
a -> {
a.getModifiers().values().stream()
.filter(m -> m.getLocalId() == head.getInstancedModifierId())
.forEach(
modifier -> {
modifier.setElementDurability(data.getRemainDurability());
});
});
}
private void handleAddNewAbility(AbilityInvokeEntry invoke) throws InvalidProtocolBufferException {
private void handleAddNewAbility(AbilityInvokeEntry invoke)
throws InvalidProtocolBufferException {
var data = AbilityMetaAddAbility.parseFrom(invoke.getAbilityData());
if (data == null) {
return;
}
}
if(data.getAbility().getAbilityName().getHash() != 0) Grasscutter.getLogger().warn("Instancing {} in to {}", data.getAbility().getAbilityName().getHash(), data.getAbility().getInstancedAbilityId());
else Grasscutter.getLogger().warn("Instancing {} in to {}", data.getAbility().getAbilityName().getStr(), data.getAbility().getInstancedAbilityId());
var ability = data.getAbility();
var abilityName = ability.getAbilityName();
if (abilityName.getHash() != 0)
Grasscutter.getLogger()
.warn("Instancing {} in to {}", abilityName.getHash(), ability.getInstancedAbilityId());
else
Grasscutter.getLogger()
.warn("Instancing {} in to {}", abilityName.getStr(), ability.getInstancedAbilityId());
GameEntity target = this.player.getScene().getEntityById(invoke.getEntityId());
var target = this.player.getScene().getEntityById(invoke.getEntityId());
if (target == null) {
return;
}
target.getInstanceToHash().put(data.getAbility().getInstancedAbilityId(), data.getAbility().getAbilityName().getHash());
target.getInstanceToName().put(data.getAbility().getInstancedAbilityId(), data.getAbility().getAbilityName().getStr());
target.getInstanceToHash().put(ability.getInstancedAbilityId(), abilityName.getHash());
target.getInstanceToName().put(ability.getInstancedAbilityId(), abilityName.getStr());
}
public void addAbilityToEntity(GameEntity entity, String name) {
var data = GameData.getAbilityData(name);
if(data != null)
addAbilityToEntity(entity, data, name);
if (data != null) addAbilityToEntity(entity, data, name);
}
public void addAbilityToEntity(GameEntity entity, AbilityData abilityData, String id) {

View File

@ -9,7 +9,7 @@ import lombok.Setter;
public final class AbilityModifierController {
@Getter private AbilityModifier data;
@Getter private Ability ability; //Owner ability instance
@Getter private Ability ability; // Owner ability instance
@Getter private float elementDurability;
@ -54,7 +54,7 @@ public final class AbilityModifierController {
if (event.getAttackElementType().equals(data.elementType)) {
elementDurability -= event.getDamage();
if(elementDurability <= 0) {
if (elementDurability <= 0) {
onRemoved();
ability.getModifiers().values().removeIf(a -> a == this);
}

View File

@ -18,8 +18,9 @@ public final class ActionApplyModifier extends AbilityActionHandler {
return false;
}
if (modifierData.stacking != null && modifierData.stacking.compareTo("Unique") == 0 &&
ability.getModifiers().values().stream()
if (modifierData.stacking != null
&& modifierData.stacking.compareTo("Unique") == 0
&& ability.getModifiers().values().stream()
.anyMatch(m -> m.getData().equals(modifierData))) {
return true;
}
@ -28,10 +29,13 @@ public final class ActionApplyModifier extends AbilityActionHandler {
ability.getModifiers().put(action.modifierName, modifier);
modifier.onAdded();
if(modifierData.duration != DynamicFloat.ZERO) {
Grasscutter.getGameServer().getScheduler().scheduleAsyncTask(() -> {
if (modifierData.duration != DynamicFloat.ZERO) {
Grasscutter.getGameServer()
.getScheduler()
.scheduleAsyncTask(
() -> {
try {
Thread.sleep((int)(modifierData.duration.get() * 1000));
Thread.sleep((int) (modifierData.duration.get() * 1000));
modifier.onRemoved();
} catch (InterruptedException ignored) {
Grasscutter.getLogger().error("Failed to schedule ability modifier async task.");

View File

@ -4,7 +4,6 @@ import emu.grasscutter.data.binout.AbilityModifier.AbilityModifierAction;
import emu.grasscutter.game.ability.Ability;
import emu.grasscutter.game.ability.AbilityAction;
import emu.grasscutter.game.ability.AbilityActionHandler;
import emu.grasscutter.game.entity.GameEntity;
@AbilityAction(AbilityModifierAction.Type.ExecuteGadgetLua)
public final class ActionExecuteGadgetLua extends AbilityActionHandler {
@ -12,8 +11,10 @@ public final class ActionExecuteGadgetLua extends AbilityActionHandler {
public boolean execute(Ability ability, AbilityModifierAction action) {
var owner = ability.getOwner();
if( owner.getEntityController() != null) {
owner.getEntityController().onClientExecuteRequest(owner, action.param1, action.param2, action.param3);
if (owner.getEntityController() != null) {
owner
.getEntityController()
.onClientExecuteRequest(owner, action.param1, action.param2, action.param3);
return true;
}

View File

@ -4,7 +4,6 @@ import emu.grasscutter.data.binout.AbilityModifier.AbilityModifierAction;
import emu.grasscutter.game.ability.Ability;
import emu.grasscutter.game.ability.AbilityAction;
import emu.grasscutter.game.ability.AbilityActionHandler;
import emu.grasscutter.game.entity.GameEntity;
@AbilityAction(AbilityModifierAction.Type.KillSelf)
public final class ActionKillSelf extends AbilityActionHandler {

View File

@ -71,7 +71,8 @@ public abstract class ActivityHandler {
.forEach(
condGroupId -> {
var condGroup = GameData.getActivityCondGroupMap().get((int) condGroupId);
if (condGroup != null) condGroup
if (condGroup != null)
condGroup
.getCondIds()
.forEach(
condition ->

View File

@ -105,22 +105,24 @@ public class EntityGadget extends EntityBaseGadget {
this.addConfigAbilities();
}
private void addConfigAbilities(){
if(this.configGadget != null && this.configGadget.getAbilities() != null) {
private void addConfigAbilities() {
if (this.configGadget != null && this.configGadget.getAbilities() != null) {
for (var ability : this.configGadget.getAbilities()) {
this.addConfigAbility(ability);
}
}
}
private void addConfigAbility(ConfigAbilityData abilityData){
private void addConfigAbility(ConfigAbilityData abilityData) {
var data = GameData.getAbilityData(abilityData.getAbilityName());
if(data != null)
getScene().getWorld().getHost().getAbilityManager().addAbilityToEntity(
this, data, abilityData.getAbilityID());
if (data != null)
getScene()
.getWorld()
.getHost()
.getAbilityManager()
.addAbilityToEntity(this, data, abilityData.getAbilityID());
}
public void setState(int state) {
this.state = state;
// Cache the gadget state

View File

@ -24,11 +24,10 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import it.unimi.dsi.fastutil.objects.Object2FloatMap;
import it.unimi.dsi.fastutil.objects.Object2FloatOpenHashMap;
import lombok.Getter;
import lombok.Setter;
import java.util.HashMap;
import java.util.Map;
import lombok.Getter;
import lombok.Setter;
public abstract class GameEntity {
@Getter private final Scene scene;

View File

@ -487,7 +487,8 @@ public final class TeamManager extends BasePlayerDataManager {
return this.getTrialAvatars().values().stream()
.filter(avatar -> avatar.getTrialAvatarId() == trialAvatarId)
.map(Avatar::getGuid)
.findFirst().orElse(0L);
.findFirst()
.orElse(0L);
}
/** Rollback changes from using a trial avatar team. */
@ -1074,7 +1075,8 @@ public final class TeamManager extends BasePlayerDataManager {
this.getPlayer()
.sendPacket(
new PacketAvatarDelNotify(trialAvatarIds.stream().map(this::getTrialAvatarGuid).toList()));
new PacketAvatarDelNotify(
trialAvatarIds.stream().map(this::getTrialAvatarGuid).toList()));
this.removeTrialAvatarTeam(trialAvatarIds);
// Update the team.

View File

@ -293,7 +293,8 @@ public class GameQuest {
return this.getQuestData().getFinishCond().stream()
.filter(cond -> cond.getType() == QuestContent.QUEST_CONTENT_ENTER_DUNGEON)
.map(condition -> {
.map(
condition -> {
var params = condition.getParam();
// The first parameter is the ID of the dungeon.
// The second parameter is the dungeon entry's scene point.

View File

@ -334,9 +334,7 @@ public final class Scene {
List<List<T>> parts = new ArrayList<List<T>>();
final int N = list.size();
for (int i = 0; i < N; i += L) {
parts.add(new ArrayList<T>(
list.subList(i, Math.min(N, i + L)))
);
parts.add(new ArrayList<T>(list.subList(i, Math.min(N, i + L))));
}
return parts;
}
@ -351,7 +349,7 @@ public final class Scene {
this.addEntityDirectly(entity);
}
for(var l : chopped(new ArrayList<>(entities), 100)) {
for (var l : chopped(new ArrayList<>(entities), 100)) {
this.broadcastPacket(new PacketSceneEntityAppearNotify(l, visionType));
}
}

View File

@ -26,6 +26,8 @@ import emu.grasscutter.utils.GridPosition;
import emu.grasscutter.utils.JsonUtils;
import emu.grasscutter.utils.Position;
import io.netty.util.concurrent.FastThreadLocalThread;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import java.io.FileWriter;
import java.io.IOException;
import java.nio.file.Files;
@ -35,9 +37,6 @@ import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import kotlin.Pair;
import lombok.val;
import org.luaj.vm2.LuaError;
@ -64,8 +63,8 @@ public class SceneScriptManager {
private ScriptMonsterSpawnService scriptMonsterSpawnService;
/** blockid - loaded groupSet */
private final Map<Integer, Set<SceneGroup>> loadedGroupSetPerBlock;
private static final Int2ObjectMap<List<Grid>> groupGridsCache
= new Int2ObjectOpenHashMap<>();
private static final Int2ObjectMap<List<Grid>> groupGridsCache = new Int2ObjectOpenHashMap<>();
public static final ExecutorService eventExecutor;
static {
@ -118,8 +117,7 @@ public class SceneScriptManager {
}
@Nullable public Map<String, Integer> getVariables(int group_id) {
if (this.getCachedGroupInstanceById(group_id) == null)
return Collections.emptyMap();
if (this.getCachedGroupInstanceById(group_id) == null) return Collections.emptyMap();
return getCachedGroupInstanceById(group_id).getCachedVariables();
}
@ -200,11 +198,16 @@ public class SceneScriptManager {
// }
}
public int refreshGroup(SceneGroupInstance groupInstance, int suiteIndex, boolean excludePrevSuite) {
public int refreshGroup(
SceneGroupInstance groupInstance, int suiteIndex, boolean excludePrevSuite) {
return this.refreshGroup(groupInstance, suiteIndex, excludePrevSuite, null);
}
public int refreshGroup(SceneGroupInstance groupInstance, int suiteIndex, boolean excludePrevSuite, List<GameEntity> entitiesAdded) {
public int refreshGroup(
SceneGroupInstance groupInstance,
int suiteIndex,
boolean excludePrevSuite,
List<GameEntity> entitiesAdded) {
SceneGroup group = groupInstance.getLuaGroup();
if (suiteIndex == 0) {
if (excludePrevSuite) {
@ -434,7 +437,7 @@ public class SceneScriptManager {
public List<Grid> getGroupGrids() {
int sceneId = scene.getId();
if (groupGridsCache.containsKey(sceneId) && groupGridsCache.get(sceneId) != null) {
Grasscutter.getLogger().debug("Hit cache for scene {}",sceneId);
Grasscutter.getLogger().debug("Hit cache for scene {}", sceneId);
return groupGridsCache.get(sceneId);
} else {
var path = FileUtils.getCachePath("scene" + sceneId + "_grid.json");
@ -442,68 +445,122 @@ public class SceneScriptManager {
try {
var groupGrids = JsonUtils.loadToList(path, Grid.class);
groupGridsCache.put(sceneId, groupGrids);
if(groupGrids != null) return groupGrids;
if (groupGrids != null) return groupGrids;
} catch (IOException e) {
e.printStackTrace();
}
}
//otherwise generate the grids
// otherwise generate the grids
List<Map<GridPosition, Set<Integer>>> groupPositions = new ArrayList<>();
for (int i = 0; i < 6; i++) groupPositions.add(new HashMap<>());
var visionOptions = Grasscutter.config.server.game.visionOptions;
meta.blocks.values().forEach(block -> {
meta.blocks
.values()
.forEach(
block -> {
block.load(sceneId, meta.context);
block.groups.values().stream().filter(g -> !g.dynamic_load).forEach(group -> {
block.groups.values().stream()
.filter(g -> !g.dynamic_load)
.forEach(
group -> {
group.load(this.scene.getId());
//Add all entities here
// Add all entities here
Set<Integer> vision_levels = new HashSet<>();
if (group.monsters != null) {
group.monsters.values().forEach(m -> {
addGridPositionToMap(groupPositions.get(m.vision_level), group.id, m.vision_level, m.pos);
group
.monsters
.values()
.forEach(
m -> {
addGridPositionToMap(
groupPositions.get(m.vision_level),
group.id,
m.vision_level,
m.pos);
vision_levels.add(m.vision_level);
});
} else {
Grasscutter.getLogger().error("group.monsters null for group {}", group.id);
Grasscutter.getLogger()
.error("group.monsters null for group {}", group.id);
}
if (group.gadgets != null) {
group.gadgets.values().forEach(g -> {
int vision_level = Math.max(getGadgetVisionLevel(g.gadget_id), g.vision_level);
addGridPositionToMap(groupPositions.get(vision_level), group.id, vision_level, g.pos);
group
.gadgets
.values()
.forEach(
g -> {
int vision_level =
Math.max(
getGadgetVisionLevel(g.gadget_id), g.vision_level);
addGridPositionToMap(
groupPositions.get(vision_level),
group.id,
vision_level,
g.pos);
vision_levels.add(vision_level);
});
} else {
Grasscutter.getLogger().error("group.gadgets null for group {}", group.id);
Grasscutter.getLogger()
.error("group.gadgets null for group {}", group.id);
}
if (group.npcs != null) {
group.npcs.values().forEach(n -> addGridPositionToMap(groupPositions.get(n.vision_level), group.id, n.vision_level, n.pos));
group
.npcs
.values()
.forEach(
n ->
addGridPositionToMap(
groupPositions.get(n.vision_level),
group.id,
n.vision_level,
n.pos));
} else {
Grasscutter.getLogger().error("group.npcs null for group {}", group.id);
}
if (group.regions != null) {
group.regions.values().forEach(r -> addGridPositionToMap(groupPositions.get(0), group.id, 0, r.pos));
group
.regions
.values()
.forEach(
r ->
addGridPositionToMap(
groupPositions.get(0), group.id, 0, r.pos));
} else {
Grasscutter.getLogger().error("group.regions null for group {}", group.id);
Grasscutter.getLogger()
.error("group.regions null for group {}", group.id);
}
if (group.garbages != null && group.garbages.gadgets != null)
group.garbages.gadgets.forEach(g -> addGridPositionToMap(groupPositions.get(g.vision_level), group.id, g.vision_level, g.pos));
group.garbages.gadgets.forEach(
g ->
addGridPositionToMap(
groupPositions.get(g.vision_level),
group.id,
g.vision_level,
g.pos));
int max_vision_level = -1;
if (!vision_levels.isEmpty()) {
for (int vision_level : vision_levels) {
if (max_vision_level == -1 || visionOptions[max_vision_level].visionRange < visionOptions[vision_level].visionRange)
if (max_vision_level == -1
|| visionOptions[max_vision_level].visionRange
< visionOptions[vision_level].visionRange)
max_vision_level = vision_level;
}
}
if (max_vision_level == -1) max_vision_level = 0;
addGridPositionToMap(groupPositions.get(max_vision_level), group.id, max_vision_level, group.pos);
addGridPositionToMap(
groupPositions.get(max_vision_level),
group.id,
max_vision_level,
group.pos);
});
});
@ -516,7 +573,8 @@ public class SceneScriptManager {
try {
Files.createDirectories(path.getParent());
} catch (IOException ignored) {}
} catch (IOException ignored) {
}
try (var file = new FileWriter(path.toFile())) {
file.write(JsonUtils.encode(groupGrids));
Grasscutter.getLogger().info("Scene {} saved grid file.", getScene().getId());
@ -658,7 +716,8 @@ public class SceneScriptManager {
this.addGroupSuite(groupInstance, suite, null);
}
public void addGroupSuite(SceneGroupInstance groupInstance, SceneSuite suite, List<GameEntity> entities) {
public void addGroupSuite(
SceneGroupInstance groupInstance, SceneSuite suite, List<GameEntity> entities) {
// we added trigger first
registerTrigger(suite.sceneTriggers);
@ -666,8 +725,7 @@ public class SceneScriptManager {
var toCreate = new ArrayList<GameEntity>();
toCreate.addAll(getGadgetsInGroupSuite(groupInstance, suite));
toCreate.addAll(getMonstersInGroupSuite(groupInstance, suite));
if (entities != null)
entities.addAll(toCreate);
if (entities != null) entities.addAll(toCreate);
else this.addEntities(toCreate);
registerRegionInGroupSuite(group, suite);

View File

@ -7,7 +7,6 @@ import java.io.Serializable;
import java.util.List;
import lombok.Getter;
import lombok.Setter;
import lombok.SneakyThrows;
@Entity
public final class GridPosition implements Serializable {
@ -92,7 +91,7 @@ public final class GridPosition implements Serializable {
}
public double[] toDoubleArray() {
return new double[]{ x, z };
return new double[] {x, z};
}
public int[] toXZIntArray() {
@ -100,7 +99,7 @@ public final class GridPosition implements Serializable {
}
public Point toPoint() {
return Point.create(x,z);
return Point.create(x, z);
}
@Override