mirror of
https://github.com/Melledy/Grasscutter.git
synced 2024-11-23 11:26:07 +00:00
Run spotlessApply
on previous commit
This commit is contained in:
parent
c9d6225194
commit
e85d269518
@ -1,13 +1,12 @@
|
|||||||
package emu.grasscutter.data.binout;
|
package emu.grasscutter.data.binout;
|
||||||
|
|
||||||
|
import static emu.grasscutter.game.ability.AbilityLocalIdGenerator.*;
|
||||||
|
|
||||||
import emu.grasscutter.data.binout.AbilityModifier.AbilityModifierAction;
|
import emu.grasscutter.data.binout.AbilityModifier.AbilityModifierAction;
|
||||||
import emu.grasscutter.game.ability.AbilityLocalIdGenerator;
|
import emu.grasscutter.game.ability.AbilityLocalIdGenerator;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import static emu.grasscutter.game.ability.AbilityLocalIdGenerator.*;
|
|
||||||
|
|
||||||
public class AbilityData {
|
public class AbilityData {
|
||||||
public String abilityName;
|
public String abilityName;
|
||||||
public Map<String, AbilityModifier> modifiers;
|
public Map<String, AbilityModifier> modifiers;
|
||||||
@ -19,44 +18,67 @@ public class AbilityData {
|
|||||||
// onAbilityStart
|
// onAbilityStart
|
||||||
// onKill
|
// onKill
|
||||||
|
|
||||||
public final Map<Integer, AbilityModifierAction> localIdToAction
|
public final Map<Integer, AbilityModifierAction> localIdToAction = new HashMap<>();
|
||||||
= new HashMap<>();
|
|
||||||
|
|
||||||
private boolean _initialized = false;
|
private boolean _initialized = false;
|
||||||
|
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
if(_initialized) return;
|
if (_initialized) return;
|
||||||
_initialized = true;
|
_initialized = true;
|
||||||
|
|
||||||
if(modifiers == null) return;
|
if (modifiers == null) return;
|
||||||
|
|
||||||
var _modifiers = modifiers.values().toArray(new AbilityModifier[0]);
|
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;
|
long configIndex = 0L;
|
||||||
this.initializeActionSubCategory(modifierIndex, configIndex++, modifier.onAdded, localIdToAction);
|
this.initializeActionSubCategory(
|
||||||
this.initializeActionSubCategory(modifierIndex, configIndex++, modifier.onRemoved, localIdToAction);
|
modifierIndex, configIndex++, modifier.onAdded, localIdToAction);
|
||||||
this.initializeActionSubCategory(modifierIndex, configIndex++, modifier.onBeingHit, localIdToAction);
|
this.initializeActionSubCategory(
|
||||||
this.initializeActionSubCategory(modifierIndex, configIndex++, modifier.onAttackLanded, localIdToAction);
|
modifierIndex, configIndex++, modifier.onRemoved, localIdToAction);
|
||||||
this.initializeActionSubCategory(modifierIndex, configIndex++, modifier.onHittingOther, localIdToAction);
|
this.initializeActionSubCategory(
|
||||||
this.initializeActionSubCategory(modifierIndex, configIndex++, modifier.onThinkInterval, localIdToAction);
|
modifierIndex, configIndex++, modifier.onBeingHit, localIdToAction);
|
||||||
this.initializeActionSubCategory(modifierIndex, configIndex++, modifier.onKill, localIdToAction);
|
this.initializeActionSubCategory(
|
||||||
this.initializeActionSubCategory(modifierIndex, configIndex++, modifier.onCrash, localIdToAction);
|
modifierIndex, configIndex++, modifier.onAttackLanded, localIdToAction);
|
||||||
this.initializeActionSubCategory(modifierIndex, configIndex++, modifier.onAvatarIn, localIdToAction);
|
this.initializeActionSubCategory(
|
||||||
this.initializeActionSubCategory(modifierIndex, configIndex++, modifier.onAvatarOut, localIdToAction);
|
modifierIndex, configIndex++, modifier.onHittingOther, localIdToAction);
|
||||||
this.initializeActionSubCategory(modifierIndex, configIndex++, modifier.onReconnect, localIdToAction);
|
this.initializeActionSubCategory(
|
||||||
this.initializeActionSubCategory(modifierIndex, configIndex++, modifier.onChangeAuthority, localIdToAction);
|
modifierIndex, configIndex++, modifier.onThinkInterval, localIdToAction);
|
||||||
this.initializeActionSubCategory(modifierIndex, configIndex++, modifier.onVehicleIn, localIdToAction);
|
this.initializeActionSubCategory(
|
||||||
this.initializeActionSubCategory(modifierIndex, configIndex++, modifier.onVehicleOut, localIdToAction);
|
modifierIndex, configIndex++, modifier.onKill, localIdToAction);
|
||||||
this.initializeActionSubCategory(modifierIndex, configIndex++, modifier.onZoneEnter, localIdToAction);
|
this.initializeActionSubCategory(
|
||||||
this.initializeActionSubCategory(modifierIndex, configIndex++, modifier.onZoneExit, localIdToAction);
|
modifierIndex, configIndex++, modifier.onCrash, localIdToAction);
|
||||||
this.initializeActionSubCategory(modifierIndex, configIndex++, modifier.onHeal, localIdToAction);
|
this.initializeActionSubCategory(
|
||||||
this.initializeActionSubCategory(modifierIndex, configIndex++, modifier.onBeingHealed, localIdToAction);
|
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++;
|
modifierIndex++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initializeActionSubCategory(long modifierIndex, long configIndex, AbilityModifierAction[] actions, Map<Integer, AbilityModifierAction> localIdToAction) {
|
private void initializeActionSubCategory(
|
||||||
if(actions == null) return;
|
long modifierIndex,
|
||||||
|
long configIndex,
|
||||||
|
AbilityModifierAction[] actions,
|
||||||
|
Map<Integer, AbilityModifierAction> localIdToAction) {
|
||||||
|
if (actions == null) return;
|
||||||
|
|
||||||
var generator = new AbilityLocalIdGenerator(ConfigAbilitySubContainerType.MODIFIER_ACTION);
|
var generator = new AbilityLocalIdGenerator(ConfigAbilitySubContainerType.MODIFIER_ACTION);
|
||||||
generator.modifierIndex = modifierIndex;
|
generator.modifierIndex = modifierIndex;
|
||||||
|
@ -1,19 +1,23 @@
|
|||||||
package emu.grasscutter.data.binout;
|
package emu.grasscutter.data.binout;
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
import com.google.gson.annotations.SerializedName;
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
|
||||||
import emu.grasscutter.data.common.DynamicFloat;
|
import emu.grasscutter.data.common.DynamicFloat;
|
||||||
import emu.grasscutter.game.props.ElementType;
|
import emu.grasscutter.game.props.ElementType;
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
public class AbilityModifier implements Serializable {
|
public class AbilityModifier implements Serializable {
|
||||||
private static final long serialVersionUID = -2001232313615923575L;
|
private static final long serialVersionUID = -2001232313615923575L;
|
||||||
|
|
||||||
@SerializedName(value="onAdded", alternate={"KCICDEJLIJD"})
|
@SerializedName(
|
||||||
|
value = "onAdded",
|
||||||
|
alternate = {"KCICDEJLIJD"})
|
||||||
public AbilityModifierAction[] onAdded;
|
public AbilityModifierAction[] onAdded;
|
||||||
@SerializedName(value="onThinkInterval", alternate={"PBDDACFFPOE"})
|
|
||||||
|
@SerializedName(
|
||||||
|
value = "onThinkInterval",
|
||||||
|
alternate = {"PBDDACFFPOE"})
|
||||||
public AbilityModifierAction[] onThinkInterval;
|
public AbilityModifierAction[] onThinkInterval;
|
||||||
|
|
||||||
public AbilityModifierAction[] onRemoved;
|
public AbilityModifierAction[] onRemoved;
|
||||||
public AbilityModifierAction[] onBeingHit;
|
public AbilityModifierAction[] onBeingHit;
|
||||||
public AbilityModifierAction[] onAttackLanded;
|
public AbilityModifierAction[] onAttackLanded;
|
||||||
@ -38,74 +42,241 @@ public class AbilityModifier implements Serializable {
|
|||||||
|
|
||||||
public static class AbilityModifierAction implements Serializable {
|
public static class AbilityModifierAction implements Serializable {
|
||||||
public enum Type {
|
public enum Type {
|
||||||
ActCameraRadialBlur, ActCameraShake, AddAvatarSkillInfo, AddChargeBarValue,
|
ActCameraRadialBlur,
|
||||||
AddClimateMeter, AddElementDurability, AddGlobalValue, AddGlobalValueToTarget,
|
ActCameraShake,
|
||||||
AddRegionalPlayVarValue, ApplyModifier, AttachAbilityStateResistance, AttachBulletAimPoint,
|
AddAvatarSkillInfo,
|
||||||
AttachEffect, AttachEffectFirework, AttachElementTypeResistance, AttachModifier,
|
AddChargeBarValue,
|
||||||
AttachUIEffect, AvatarCameraParam, AvatarEnterCameraShot, AvatarEnterFocus,
|
AddClimateMeter,
|
||||||
AvatarEnterViewBias, AvatarExitCameraShot, AvatarExitClimb, AvatarExitFocus,
|
AddElementDurability,
|
||||||
AvatarExitViewBias, AvatarShareCDSkillStart, AvatarSkillStart, BroadcastNeuronStimulate,
|
AddGlobalValue,
|
||||||
CalcDvalinS04RebornPoint, CallLuaTask, ChangeEnviroWeather, ChangeFollowDampTime,
|
AddGlobalValueToTarget,
|
||||||
ChangeGadgetUIInteractHint, ChangePlayMode, ChangeTag, ChangeUGCRayTag,
|
AddRegionalPlayVarValue,
|
||||||
ClearEndura, ClearGlobalPos, ClearGlobalValue, ClearLocalGadgets,
|
ApplyModifier,
|
||||||
ClearLockTarget, ClearPos, ConfigAbilityAction, ControlEmotion,
|
AttachAbilityStateResistance,
|
||||||
CopyGlobalValue, CreateGadget, CreateMovingPlatform, CreateTile,
|
AttachBulletAimPoint,
|
||||||
DamageByAttackValue, DebugLog, DestroyTile, DoBlink,
|
AttachEffect,
|
||||||
DoTileAction, DoWatcherSystemAction, DoWidgetSystemAction, DropSubfield,
|
AttachEffectFirework,
|
||||||
DummyAction, DungeonFogEffects, ElementAttachForActivityGacha, EnableAIStealthy,
|
AttachElementTypeResistance,
|
||||||
EnableAfterImage, EnableAvatarFlyStateTrail, EnableAvatarMoveOnWater, EnableBulletCollisionPluginTrigger,
|
AttachModifier,
|
||||||
EnableGadgetIntee, EnableHeadControl, EnableHitBoxByName, EnableMainInterface,
|
AttachUIEffect,
|
||||||
EnablePartControl, EnablePositionSynchronization, EnablePushColliderName, EnableRocketJump,
|
AvatarCameraParam,
|
||||||
EnableSceneTransformByName, EnterCameraLock, EntityDoSkill, EquipAffixStart,
|
AvatarEnterCameraShot,
|
||||||
ExecuteGadgetLua, FireAISoundEvent, FireChargeBarEffect, FireEffect,
|
AvatarEnterFocus,
|
||||||
FireEffectFirework, FireEffectForStorm, FireFishingEvent, FireHitEffect,
|
AvatarEnterViewBias,
|
||||||
FireSubEmitterEffect, FireUIEffect, FixedMonsterRushMove, ForceAirStateFly,
|
AvatarExitCameraShot,
|
||||||
ForceEnableShakeOffButton, GenerateElemBall, GetFightProperty, GetInteractIdToGlobalValue,
|
AvatarExitClimb,
|
||||||
GetPos, HealHP, HideUIBillBoard, IgnoreMoveColToRockCol,
|
AvatarExitFocus,
|
||||||
KillGadget, KillPlayEntity, KillSelf, KillServerGadget,
|
AvatarExitViewBias,
|
||||||
LoseHP, ModifyAvatarSkillCD, ModifyVehicleSkillCD, PlayEmoSync,
|
AvatarShareCDSkillStart,
|
||||||
Predicated, PushDvalinS01Process, PushInterActionByConfigPath, PushPos,
|
AvatarSkillStart,
|
||||||
Randomed, ReTriggerAISkillInitialCD, RefreshUICombatBarLayout, RegisterAIActionPoint,
|
BroadcastNeuronStimulate,
|
||||||
ReleaseAIActionPoint, RemoveAvatarSkillInfo, RemoveModifier, RemoveModifierByAbilityStateResistanceID,
|
CalcDvalinS04RebornPoint,
|
||||||
RemoveServerBuff, RemoveUniqueModifier, RemoveVelocityForce, Repeated,
|
CallLuaTask,
|
||||||
ResetAIAttackTarget, ResetAIResistTauntLevel, ResetAIThreatBroadcastRange, ResetAnimatorTrigger,
|
ChangeEnviroWeather,
|
||||||
ReviveDeadAvatar, ReviveElemEnergy, ReviveStamina, SectorCityManeuver,
|
ChangeFollowDampTime,
|
||||||
SendEffectTrigger, SendEffectTriggerToLineEffect, SendEvtElectricCoreMoveEnterP1, SendEvtElectricCoreMoveInterrupt,
|
ChangeGadgetUIInteractHint,
|
||||||
ServerLuaCall, ServerLuaTriggerEvent, ServerMonsterLog, SetAIHitFeeling,
|
ChangePlayMode,
|
||||||
SetAISkillCDAvailableNow, SetAISkillCDMultiplier, SetAISkillGCD, SetAnimatorBool,
|
ChangeTag,
|
||||||
SetAnimatorFloat, SetAnimatorInt, SetAnimatorTrigger, SetAvatarCanShakeOff,
|
ChangeUGCRayTag,
|
||||||
SetAvatarHitBuckets, SetCanDieImmediately, SetChargeBarValue, SetDvalinS01FlyState,
|
ClearEndura,
|
||||||
SetEmissionScaler, SetEntityScale, SetExtraAbilityEnable, SetExtraAbilityState,
|
ClearGlobalPos,
|
||||||
SetGlobalDir, SetGlobalPos, SetGlobalValue, SetGlobalValueByTargetDistance,
|
ClearGlobalValue,
|
||||||
SetGlobalValueToOverrideMap, SetKeepInAirVelocityForce, SetMaterialParamFloatByTransform, SetNeuronEnable,
|
ClearLocalGadgets,
|
||||||
SetOverrideMapValue, SetPartControlTarget, SetPoseBool, SetPoseFloat,
|
ClearLockTarget,
|
||||||
SetPoseInt, SetRandomOverrideMapValue, SetRegionalPlayVarValue, SetSelfAttackTarget,
|
ClearPos,
|
||||||
SetSkillAnchor, SetSpecialCamera, SetSurroundAnchor, SetSystemValueToOverrideMap,
|
ConfigAbilityAction,
|
||||||
SetTargetNumToGlobalValue, SetUICombatBarAsh, SetUICombatBarSpark, SetVelocityIgnoreAirGY,
|
ControlEmotion,
|
||||||
SetWeaponAttachPointRealName, SetWeaponBindState, ShowExtraAbility, ShowProgressBarAction,
|
CopyGlobalValue,
|
||||||
ShowReminder, ShowScreenEffect, ShowTextMap, ShowUICombatBar,
|
CreateGadget,
|
||||||
StartDither, SumTargetWeightToSelfGlobalValue, Summon, SyncToStageScript,
|
CreateMovingPlatform,
|
||||||
TriggerAbility, TriggerAttackEvent, TriggerAttackTargetMapEvent, TriggerAudio,
|
CreateTile,
|
||||||
TriggerAuxWeaponTrans, TriggerBullet, TriggerCreateGadgetToEquipPart, TriggerDropEquipParts,
|
DamageByAttackValue,
|
||||||
TriggerFaceAnimation, TriggerGadgetInteractive, TriggerHideWeapon, TriggerSetCastShadow,
|
DebugLog,
|
||||||
TriggerSetPassThrough, TriggerSetRenderersEnable, TriggerSetShadowRamp, TriggerSetVisible,
|
DestroyTile,
|
||||||
TriggerTaunt, TriggerThrowEquipPart, TriggerUGCGadgetMove, TryFindBlinkPoint,
|
DoBlink,
|
||||||
TryFindBlinkPointByBorn, TryTriggerPlatformStartMove, TurnDirection, TurnDirectionToPos,
|
DoTileAction,
|
||||||
UpdateReactionDamage, UseSkillEliteSet, WidgetSkillStart;
|
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")
|
@SerializedName("$type")
|
||||||
public Type type;
|
public Type type;
|
||||||
|
|
||||||
public String target;
|
public String target;
|
||||||
|
|
||||||
@SerializedName(value = "amount", alternate = "PDLLIFICICJ")
|
@SerializedName(value = "amount", alternate = "PDLLIFICICJ")
|
||||||
public DynamicFloat amount = DynamicFloat.ZERO;
|
public DynamicFloat amount = DynamicFloat.ZERO;
|
||||||
|
|
||||||
public DynamicFloat amountByCasterAttackRatio = DynamicFloat.ZERO;
|
public DynamicFloat amountByCasterAttackRatio = DynamicFloat.ZERO;
|
||||||
public DynamicFloat amountByCasterCurrentHPRatio = DynamicFloat.ZERO;
|
public DynamicFloat amountByCasterCurrentHPRatio = DynamicFloat.ZERO;
|
||||||
public DynamicFloat amountByCasterMaxHPRatio = DynamicFloat.ZERO;
|
public DynamicFloat amountByCasterMaxHPRatio = DynamicFloat.ZERO;
|
||||||
public DynamicFloat amountByGetDamage = DynamicFloat.ZERO;
|
public DynamicFloat amountByGetDamage = DynamicFloat.ZERO;
|
||||||
public DynamicFloat amountByTargetCurrentHPRatio = DynamicFloat.ZERO;
|
public DynamicFloat amountByTargetCurrentHPRatio = DynamicFloat.ZERO;
|
||||||
public DynamicFloat amountByTargetMaxHPRatio = DynamicFloat.ZERO;
|
public DynamicFloat amountByTargetMaxHPRatio = DynamicFloat.ZERO;
|
||||||
|
|
||||||
@SerializedName(value = "ignoreAbilityProperty", alternate = "HHFGADCJJDI")
|
@SerializedName(value = "ignoreAbilityProperty", alternate = "HHFGADCJJDI")
|
||||||
public boolean ignoreAbilityProperty;
|
public boolean ignoreAbilityProperty;
|
||||||
|
|
||||||
public String modifierName;
|
public String modifierName;
|
||||||
|
|
||||||
public int param1;
|
public int param1;
|
||||||
@ -113,7 +284,8 @@ public class AbilityModifier implements Serializable {
|
|||||||
public int param3;
|
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 static class AbilityModifierValue {
|
||||||
// public boolean isFormula;
|
// public boolean isFormula;
|
||||||
// public boolean isDynamic;
|
// public boolean isDynamic;
|
||||||
|
@ -6,7 +6,6 @@ import emu.grasscutter.Grasscutter;
|
|||||||
import emu.grasscutter.scripts.SceneIndexManager;
|
import emu.grasscutter.scripts.SceneIndexManager;
|
||||||
import emu.grasscutter.utils.GridPosition;
|
import emu.grasscutter.utils.GridPosition;
|
||||||
import emu.grasscutter.utils.Position;
|
import emu.grasscutter.utils.Position;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
public class Grid {
|
public class Grid {
|
||||||
@ -15,14 +14,13 @@ public class Grid {
|
|||||||
|
|
||||||
public Map<GridPosition, Set<Integer>> grid = new LinkedHashMap<>();
|
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() {
|
private void optimize() {
|
||||||
if (this.gridOptimized == null) {
|
if (this.gridOptimized == null) {
|
||||||
var gridValues = new ArrayList<Map.Entry<GridPosition, Set<Integer>>>();
|
var gridValues = new ArrayList<Map.Entry<GridPosition, Set<Integer>>>();
|
||||||
this.grid.forEach((k, v) -> gridValues.add(new AbstractMap.SimpleEntry<>(k, v)));
|
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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,7 +55,7 @@ public class Grid {
|
|||||||
|
|
||||||
// Construct a list of nearby groups.
|
// Construct a list of nearby groups.
|
||||||
SceneIndexManager.queryNeighbors(gridOptimized, pos.toDoubleArray(), vision_range_grid + 1)
|
SceneIndexManager.queryNeighbors(gridOptimized, pos.toDoubleArray(), vision_range_grid + 1)
|
||||||
.forEach(e -> nearbyGroups.addAll(e.getValue()));
|
.forEach(e -> nearbyGroups.addAll(e.getValue()));
|
||||||
return this.nearbyGroups;
|
return this.nearbyGroups;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,11 @@
|
|||||||
package emu.grasscutter.game.ability;
|
package emu.grasscutter.game.ability;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import emu.grasscutter.data.binout.AbilityData;
|
import emu.grasscutter.data.binout.AbilityData;
|
||||||
import emu.grasscutter.game.entity.GameEntity;
|
import emu.grasscutter.game.entity.GameEntity;
|
||||||
import emu.grasscutter.server.event.entity.EntityDamageEvent;
|
import emu.grasscutter.server.event.entity.EntityDamageEvent;
|
||||||
import emu.grasscutter.utils.Utils;
|
import emu.grasscutter.utils.Utils;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
public final class Ability {
|
public final class Ability {
|
||||||
@ -14,8 +13,7 @@ public final class Ability {
|
|||||||
@Getter private GameEntity owner;
|
@Getter private GameEntity owner;
|
||||||
|
|
||||||
@Getter private AbilityManager manager;
|
@Getter private AbilityManager manager;
|
||||||
@Getter private Map<String, AbilityModifierController> modifiers
|
@Getter private Map<String, AbilityModifierController> modifiers = new HashMap<>();
|
||||||
= new HashMap<>();
|
|
||||||
|
|
||||||
@Getter private int hash;
|
@Getter private int hash;
|
||||||
|
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
package emu.grasscutter.game.ability;
|
package emu.grasscutter.game.ability;
|
||||||
|
|
||||||
|
import emu.grasscutter.data.binout.AbilityModifier.AbilityModifierAction;
|
||||||
import java.lang.annotation.Retention;
|
import java.lang.annotation.Retention;
|
||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
|
||||||
import emu.grasscutter.data.binout.AbilityModifier.AbilityModifierAction;
|
|
||||||
|
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
public @interface AbilityAction {
|
public @interface AbilityAction {
|
||||||
AbilityModifierAction.Type value();
|
AbilityModifierAction.Type value();
|
||||||
|
@ -2,9 +2,8 @@ package emu.grasscutter.game.ability;
|
|||||||
|
|
||||||
import emu.grasscutter.Grasscutter;
|
import emu.grasscutter.Grasscutter;
|
||||||
import emu.grasscutter.data.binout.AbilityModifier.AbilityModifierAction;
|
import emu.grasscutter.data.binout.AbilityModifier.AbilityModifierAction;
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
|
||||||
public final class AbilityLocalIdGenerator {
|
public final class AbilityLocalIdGenerator {
|
||||||
public ConfigAbilitySubContainerType type;
|
public ConfigAbilitySubContainerType type;
|
||||||
@ -13,13 +12,12 @@ public final class AbilityLocalIdGenerator {
|
|||||||
public long mixinIndex = 0;
|
public long mixinIndex = 0;
|
||||||
private long actionIndex = 0;
|
private long actionIndex = 0;
|
||||||
|
|
||||||
public AbilityLocalIdGenerator(ConfigAbilitySubContainerType type)
|
public AbilityLocalIdGenerator(ConfigAbilitySubContainerType type) {
|
||||||
{
|
|
||||||
this.type = 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;
|
if (actions == null) return;
|
||||||
|
|
||||||
actionIndex = 0;
|
actionIndex = 0;
|
||||||
@ -44,7 +42,11 @@ public final class AbilityLocalIdGenerator {
|
|||||||
return type.value + (modifierIndex << 3) + (configIndex << 9) + (actionIndex << 15);
|
return type.value + (modifierIndex << 3) + (configIndex << 9) + (actionIndex << 15);
|
||||||
}
|
}
|
||||||
case MODIFIER_MIXIN -> {
|
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.");
|
case NONE -> Grasscutter.getLogger().error("Ability local id generator using NONE type.");
|
||||||
}
|
}
|
||||||
|
@ -13,29 +13,36 @@ import emu.grasscutter.game.player.BasePlayerManager;
|
|||||||
import emu.grasscutter.game.player.Player;
|
import emu.grasscutter.game.player.Player;
|
||||||
import emu.grasscutter.game.quest.enums.QuestContent;
|
import emu.grasscutter.game.quest.enums.QuestContent;
|
||||||
import emu.grasscutter.net.proto.AbilityInvokeEntryOuterClass.AbilityInvokeEntry;
|
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.AbilityMetaModifierChangeOuterClass.AbilityMetaModifierChange;
|
||||||
|
import emu.grasscutter.net.proto.AbilityMetaModifierDurabilityChangeOuterClass.AbilityMetaModifierDurabilityChange;
|
||||||
import emu.grasscutter.net.proto.AbilityMetaReInitOverrideMapOuterClass.AbilityMetaReInitOverrideMap;
|
import emu.grasscutter.net.proto.AbilityMetaReInitOverrideMapOuterClass.AbilityMetaReInitOverrideMap;
|
||||||
import emu.grasscutter.net.proto.AbilityMixinCostStaminaOuterClass.AbilityMixinCostStamina;
|
import emu.grasscutter.net.proto.AbilityMixinCostStaminaOuterClass.AbilityMixinCostStamina;
|
||||||
import emu.grasscutter.net.proto.AbilityScalarValueEntryOuterClass.AbilityScalarValueEntry;
|
import emu.grasscutter.net.proto.AbilityScalarValueEntryOuterClass.AbilityScalarValueEntry;
|
||||||
import emu.grasscutter.net.proto.ModifierActionOuterClass.ModifierAction;
|
import emu.grasscutter.net.proto.ModifierActionOuterClass.ModifierAction;
|
||||||
import io.netty.util.concurrent.FastThreadLocalThread;
|
import io.netty.util.concurrent.FastThreadLocalThread;
|
||||||
import lombok.Getter;
|
|
||||||
import org.reflections.Reflections;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.LinkedBlockingDeque;
|
import java.util.concurrent.LinkedBlockingDeque;
|
||||||
import java.util.concurrent.ThreadPoolExecutor;
|
import java.util.concurrent.ThreadPoolExecutor;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import lombok.Getter;
|
||||||
|
import org.reflections.Reflections;
|
||||||
|
|
||||||
public final class AbilityManager extends BasePlayerManager {
|
public final class AbilityManager extends BasePlayerManager {
|
||||||
public static final ExecutorService eventExecutor;
|
public static final ExecutorService eventExecutor;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
eventExecutor = new ThreadPoolExecutor(4, 4,
|
eventExecutor =
|
||||||
60, TimeUnit.SECONDS, new LinkedBlockingDeque<>(1000),
|
new ThreadPoolExecutor(
|
||||||
FastThreadLocalThread::new, new ThreadPoolExecutor.AbortPolicy());
|
4,
|
||||||
|
4,
|
||||||
|
60,
|
||||||
|
TimeUnit.SECONDS,
|
||||||
|
new LinkedBlockingDeque<>(1000),
|
||||||
|
FastThreadLocalThread::new,
|
||||||
|
new ThreadPoolExecutor.AbortPolicy());
|
||||||
}
|
}
|
||||||
|
|
||||||
private final HealAbilityManager healAbilityManager;
|
private final HealAbilityManager healAbilityManager;
|
||||||
@ -52,9 +59,7 @@ public final class AbilityManager extends BasePlayerManager {
|
|||||||
this.registerHandlers();
|
this.registerHandlers();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** Registers all present ability handlers. */
|
||||||
* Registers all present ability handlers.
|
|
||||||
*/
|
|
||||||
private void registerHandlers() {
|
private void registerHandlers() {
|
||||||
var reflections = new Reflections("emu.grasscutter.game.ability.actions");
|
var reflections = new Reflections("emu.grasscutter.game.ability.actions");
|
||||||
var handlerClasses = reflections.getSubTypesOf(AbilityActionHandler.class);
|
var handlerClasses = reflections.getSubTypesOf(AbilityActionHandler.class);
|
||||||
@ -77,22 +82,31 @@ public final class AbilityManager extends BasePlayerManager {
|
|||||||
var handler = actionHandlers.get(action.type);
|
var handler = actionHandlers.get(action.type);
|
||||||
|
|
||||||
if (handler == null || ability == null) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
eventExecutor.submit(() -> {
|
eventExecutor.submit(
|
||||||
if (!handler.execute(ability, action)) {
|
() -> {
|
||||||
Grasscutter.getLogger().debug("exec ability action failed {} at {}", action.type, ability);
|
if (!handler.execute(ability, action)) {
|
||||||
}
|
Grasscutter.getLogger()
|
||||||
});
|
.debug("exec ability action failed {} at {}", action.type, ability);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onAbilityInvoke(AbilityInvokeEntry invoke) throws Exception {
|
public void onAbilityInvoke(AbilityInvokeEntry invoke) throws Exception {
|
||||||
this.healAbilityManager.healHandler(invoke);
|
this.healAbilityManager.healHandler(invoke);
|
||||||
|
|
||||||
if (invoke.getEntityId() == 67109298) {
|
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()) {
|
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_MIXIN_COST_STAMINA -> this.handleMixinCostStamina(invoke);
|
||||||
case ABILITY_INVOKE_ARGUMENT_ACTION_GENERATE_ELEM_BALL -> this.handleGenerateElemBall(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_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_META_ADD_NEW_ABILITY -> this.handleAddNewAbility(invoke);
|
||||||
case ABILITY_INVOKE_ARGUMENT_NONE -> this.handleInvoke(invoke);
|
case ABILITY_INVOKE_ARGUMENT_NONE -> this.handleInvoke(invoke);
|
||||||
default -> {}
|
default -> {}
|
||||||
@ -173,29 +188,39 @@ public final class AbilityManager extends BasePlayerManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var head = invoke.getHead();
|
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());
|
var hash = entity.getInstanceToHash().get(head.getInstancedAbilityId());
|
||||||
if (hash == null) {
|
if (hash == null) {
|
||||||
var abilities = entity.getAbilities().values().toArray(new Ability[0]);
|
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];
|
var ability = abilities[head.getInstancedAbilityId() - 1];
|
||||||
Grasscutter.getLogger().warn("-> {}", ability.getData().localIdToAction);
|
Grasscutter.getLogger().warn("-> {}", ability.getData().localIdToAction);
|
||||||
var action = ability.getData().localIdToAction.get(head.getLocalId());
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var stream = entity.getAbilities().values().stream()
|
var stream =
|
||||||
.filter(a -> a.getHash() == hash ||
|
entity.getAbilities().values().stream()
|
||||||
a.getData().abilityName == entity.getInstanceToName().get(head.getInstancedAbilityId()));
|
.filter(
|
||||||
stream.forEach(ability -> {
|
a ->
|
||||||
var action = ability.getData().localIdToAction.get(head.getLocalId());
|
a.getHash() == hash
|
||||||
if(action != null) ability.getManager().executeAction(ability, action);
|
|| 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);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleOverrideParam(AbilityInvokeEntry invoke) throws Exception {
|
private void handleOverrideParam(AbilityInvokeEntry invoke) throws Exception {
|
||||||
@ -248,7 +273,7 @@ public final class AbilityManager extends BasePlayerManager {
|
|||||||
|
|
||||||
if (data.getAction() == ModifierAction.MODIFIER_ACTION_REMOVED) {
|
if (data.getAction() == ModifierAction.MODIFIER_ACTION_REMOVED) {
|
||||||
var ability = target.getAbilities().get(data.getParentAbilityName().getStr());
|
var ability = target.getAbilities().get(data.getParentAbilityName().getStr());
|
||||||
if(ability != null) {
|
if (ability != null) {
|
||||||
var modifier = ability.getModifiers().get(head.getInstancedModifierId());
|
var modifier = ability.getModifiers().get(head.getInstancedModifierId());
|
||||||
if (modifier != null) {
|
if (modifier != null) {
|
||||||
modifier.onRemoved();
|
modifier.onRemoved();
|
||||||
@ -257,16 +282,26 @@ 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 modifierString = data.getParentAbilityName().getStr();
|
||||||
var hash = target.getInstanceToHash().get(head.getInstancedAbilityId());
|
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 -> {
|
target.getAbilities().values().stream()
|
||||||
a.getModifiers().keySet().stream().filter(key -> key.compareTo(modifierString) == 0).forEach(key -> {
|
.filter(
|
||||||
a.getModifiers().get(key).setLocalId(head.getInstancedModifierId());
|
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());
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
var sourceEntity = this.player.getScene().getEntityById(data.getApplyEntityId());
|
var sourceEntity = this.player.getScene().getEntityById(data.getApplyEntityId());
|
||||||
@ -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());
|
var target = this.player.getScene().getEntityById(invoke.getEntityId());
|
||||||
if (target == null) {
|
if (target == null) {
|
||||||
return;
|
return;
|
||||||
@ -374,41 +410,53 @@ public final class AbilityManager extends BasePlayerManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var head = invoke.getHead();
|
var head = invoke.getHead();
|
||||||
if (head == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var hash = target.getInstanceToHash().get(head.getInstancedAbilityId());
|
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 -> {
|
target.getAbilities().values().stream()
|
||||||
a.getModifiers().values().stream().filter(m -> m.getLocalId() == head.getInstancedModifierId()).forEach(modifier -> {
|
.filter(
|
||||||
modifier.setElementDurability(data.getRemainDurability());
|
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());
|
var data = AbilityMetaAddAbility.parseFrom(invoke.getAbilityData());
|
||||||
if (data == null) {
|
if (data == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(data.getAbility().getAbilityName().getHash() != 0) Grasscutter.getLogger().warn("Instancing {} in to {}", data.getAbility().getAbilityName().getHash(), data.getAbility().getInstancedAbilityId());
|
var ability = data.getAbility();
|
||||||
else Grasscutter.getLogger().warn("Instancing {} in to {}", data.getAbility().getAbilityName().getStr(), data.getAbility().getInstancedAbilityId());
|
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) {
|
if (target == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
target.getInstanceToHash().put(data.getAbility().getInstancedAbilityId(), data.getAbility().getAbilityName().getHash());
|
target.getInstanceToHash().put(ability.getInstancedAbilityId(), abilityName.getHash());
|
||||||
target.getInstanceToName().put(data.getAbility().getInstancedAbilityId(), data.getAbility().getAbilityName().getStr());
|
target.getInstanceToName().put(ability.getInstancedAbilityId(), abilityName.getStr());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addAbilityToEntity(GameEntity entity, String name) {
|
public void addAbilityToEntity(GameEntity entity, String name) {
|
||||||
var data = GameData.getAbilityData(name);
|
var data = GameData.getAbilityData(name);
|
||||||
if(data != null)
|
if (data != null) addAbilityToEntity(entity, data, name);
|
||||||
addAbilityToEntity(entity, data, name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addAbilityToEntity(GameEntity entity, AbilityData abilityData, String id) {
|
public void addAbilityToEntity(GameEntity entity, AbilityData abilityData, String id) {
|
||||||
|
@ -9,7 +9,7 @@ import lombok.Setter;
|
|||||||
public final class AbilityModifierController {
|
public final class AbilityModifierController {
|
||||||
@Getter private AbilityModifier data;
|
@Getter private AbilityModifier data;
|
||||||
|
|
||||||
@Getter private Ability ability; //Owner ability instance
|
@Getter private Ability ability; // Owner ability instance
|
||||||
|
|
||||||
@Getter private float elementDurability;
|
@Getter private float elementDurability;
|
||||||
|
|
||||||
@ -54,7 +54,7 @@ public final class AbilityModifierController {
|
|||||||
|
|
||||||
if (event.getAttackElementType().equals(data.elementType)) {
|
if (event.getAttackElementType().equals(data.elementType)) {
|
||||||
elementDurability -= event.getDamage();
|
elementDurability -= event.getDamage();
|
||||||
if(elementDurability <= 0) {
|
if (elementDurability <= 0) {
|
||||||
onRemoved();
|
onRemoved();
|
||||||
ability.getModifiers().values().removeIf(a -> a == this);
|
ability.getModifiers().values().removeIf(a -> a == this);
|
||||||
}
|
}
|
||||||
|
@ -18,9 +18,10 @@ public final class ActionApplyModifier extends AbilityActionHandler {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (modifierData.stacking != null && modifierData.stacking.compareTo("Unique") == 0 &&
|
if (modifierData.stacking != null
|
||||||
ability.getModifiers().values().stream()
|
&& modifierData.stacking.compareTo("Unique") == 0
|
||||||
.anyMatch(m -> m.getData().equals(modifierData))) {
|
&& ability.getModifiers().values().stream()
|
||||||
|
.anyMatch(m -> m.getData().equals(modifierData))) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -28,15 +29,18 @@ public final class ActionApplyModifier extends AbilityActionHandler {
|
|||||||
ability.getModifiers().put(action.modifierName, modifier);
|
ability.getModifiers().put(action.modifierName, modifier);
|
||||||
modifier.onAdded();
|
modifier.onAdded();
|
||||||
|
|
||||||
if(modifierData.duration != DynamicFloat.ZERO) {
|
if (modifierData.duration != DynamicFloat.ZERO) {
|
||||||
Grasscutter.getGameServer().getScheduler().scheduleAsyncTask(() -> {
|
Grasscutter.getGameServer()
|
||||||
try {
|
.getScheduler()
|
||||||
Thread.sleep((int)(modifierData.duration.get() * 1000));
|
.scheduleAsyncTask(
|
||||||
modifier.onRemoved();
|
() -> {
|
||||||
} catch (InterruptedException ignored) {
|
try {
|
||||||
Grasscutter.getLogger().error("Failed to schedule ability modifier async task.");
|
Thread.sleep((int) (modifierData.duration.get() * 1000));
|
||||||
}
|
modifier.onRemoved();
|
||||||
});
|
} catch (InterruptedException ignored) {
|
||||||
|
Grasscutter.getLogger().error("Failed to schedule ability modifier async task.");
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -4,7 +4,6 @@ import emu.grasscutter.data.binout.AbilityModifier.AbilityModifierAction;
|
|||||||
import emu.grasscutter.game.ability.Ability;
|
import emu.grasscutter.game.ability.Ability;
|
||||||
import emu.grasscutter.game.ability.AbilityAction;
|
import emu.grasscutter.game.ability.AbilityAction;
|
||||||
import emu.grasscutter.game.ability.AbilityActionHandler;
|
import emu.grasscutter.game.ability.AbilityActionHandler;
|
||||||
import emu.grasscutter.game.entity.GameEntity;
|
|
||||||
|
|
||||||
@AbilityAction(AbilityModifierAction.Type.ExecuteGadgetLua)
|
@AbilityAction(AbilityModifierAction.Type.ExecuteGadgetLua)
|
||||||
public final class ActionExecuteGadgetLua extends AbilityActionHandler {
|
public final class ActionExecuteGadgetLua extends AbilityActionHandler {
|
||||||
@ -12,8 +11,10 @@ public final class ActionExecuteGadgetLua extends AbilityActionHandler {
|
|||||||
public boolean execute(Ability ability, AbilityModifierAction action) {
|
public boolean execute(Ability ability, AbilityModifierAction action) {
|
||||||
var owner = ability.getOwner();
|
var owner = ability.getOwner();
|
||||||
|
|
||||||
if( owner.getEntityController() != null) {
|
if (owner.getEntityController() != null) {
|
||||||
owner.getEntityController().onClientExecuteRequest(owner, action.param1, action.param2, action.param3);
|
owner
|
||||||
|
.getEntityController()
|
||||||
|
.onClientExecuteRequest(owner, action.param1, action.param2, action.param3);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,6 @@ import emu.grasscutter.data.binout.AbilityModifier.AbilityModifierAction;
|
|||||||
import emu.grasscutter.game.ability.Ability;
|
import emu.grasscutter.game.ability.Ability;
|
||||||
import emu.grasscutter.game.ability.AbilityAction;
|
import emu.grasscutter.game.ability.AbilityAction;
|
||||||
import emu.grasscutter.game.ability.AbilityActionHandler;
|
import emu.grasscutter.game.ability.AbilityActionHandler;
|
||||||
import emu.grasscutter.game.entity.GameEntity;
|
|
||||||
|
|
||||||
@AbilityAction(AbilityModifierAction.Type.KillSelf)
|
@AbilityAction(AbilityModifierAction.Type.KillSelf)
|
||||||
public final class ActionKillSelf extends AbilityActionHandler {
|
public final class ActionKillSelf extends AbilityActionHandler {
|
||||||
|
@ -71,11 +71,12 @@ public abstract class ActivityHandler {
|
|||||||
.forEach(
|
.forEach(
|
||||||
condGroupId -> {
|
condGroupId -> {
|
||||||
var condGroup = GameData.getActivityCondGroupMap().get((int) condGroupId);
|
var condGroup = GameData.getActivityCondGroupMap().get((int) condGroupId);
|
||||||
if (condGroup != null) condGroup
|
if (condGroup != null)
|
||||||
.getCondIds()
|
condGroup
|
||||||
.forEach(
|
.getCondIds()
|
||||||
condition ->
|
.forEach(
|
||||||
questManager.queueEvent(QuestCond.QUEST_COND_ACTIVITY_COND, condition));
|
condition ->
|
||||||
|
questManager.queueEvent(QuestCond.QUEST_COND_ACTIVITY_COND, condition));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,22 +105,24 @@ public class EntityGadget extends EntityBaseGadget {
|
|||||||
this.addConfigAbilities();
|
this.addConfigAbilities();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addConfigAbilities(){
|
private void addConfigAbilities() {
|
||||||
if(this.configGadget != null && this.configGadget.getAbilities() != null) {
|
if (this.configGadget != null && this.configGadget.getAbilities() != null) {
|
||||||
for (var ability : this.configGadget.getAbilities()) {
|
for (var ability : this.configGadget.getAbilities()) {
|
||||||
this.addConfigAbility(ability);
|
this.addConfigAbility(ability);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addConfigAbility(ConfigAbilityData abilityData){
|
private void addConfigAbility(ConfigAbilityData abilityData) {
|
||||||
var data = GameData.getAbilityData(abilityData.getAbilityName());
|
var data = GameData.getAbilityData(abilityData.getAbilityName());
|
||||||
if(data != null)
|
if (data != null)
|
||||||
getScene().getWorld().getHost().getAbilityManager().addAbilityToEntity(
|
getScene()
|
||||||
this, data, abilityData.getAbilityID());
|
.getWorld()
|
||||||
|
.getHost()
|
||||||
|
.getAbilityManager()
|
||||||
|
.addAbilityToEntity(this, data, abilityData.getAbilityID());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void setState(int state) {
|
public void setState(int state) {
|
||||||
this.state = state;
|
this.state = state;
|
||||||
// Cache the gadget state
|
// Cache the gadget state
|
||||||
|
@ -24,11 +24,10 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
|||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||||
import it.unimi.dsi.fastutil.objects.Object2FloatMap;
|
import it.unimi.dsi.fastutil.objects.Object2FloatMap;
|
||||||
import it.unimi.dsi.fastutil.objects.Object2FloatOpenHashMap;
|
import it.unimi.dsi.fastutil.objects.Object2FloatOpenHashMap;
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Setter;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
public abstract class GameEntity {
|
public abstract class GameEntity {
|
||||||
@Getter private final Scene scene;
|
@Getter private final Scene scene;
|
||||||
|
@ -487,7 +487,8 @@ public final class TeamManager extends BasePlayerDataManager {
|
|||||||
return this.getTrialAvatars().values().stream()
|
return this.getTrialAvatars().values().stream()
|
||||||
.filter(avatar -> avatar.getTrialAvatarId() == trialAvatarId)
|
.filter(avatar -> avatar.getTrialAvatarId() == trialAvatarId)
|
||||||
.map(Avatar::getGuid)
|
.map(Avatar::getGuid)
|
||||||
.findFirst().orElse(0L);
|
.findFirst()
|
||||||
|
.orElse(0L);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Rollback changes from using a trial avatar team. */
|
/** Rollback changes from using a trial avatar team. */
|
||||||
@ -1074,7 +1075,8 @@ public final class TeamManager extends BasePlayerDataManager {
|
|||||||
|
|
||||||
this.getPlayer()
|
this.getPlayer()
|
||||||
.sendPacket(
|
.sendPacket(
|
||||||
new PacketAvatarDelNotify(trialAvatarIds.stream().map(this::getTrialAvatarGuid).toList()));
|
new PacketAvatarDelNotify(
|
||||||
|
trialAvatarIds.stream().map(this::getTrialAvatarGuid).toList()));
|
||||||
this.removeTrialAvatarTeam(trialAvatarIds);
|
this.removeTrialAvatarTeam(trialAvatarIds);
|
||||||
|
|
||||||
// Update the team.
|
// Update the team.
|
||||||
|
@ -292,15 +292,16 @@ public class GameQuest {
|
|||||||
if (this.state != QuestState.UNFINISHED) return List.of();
|
if (this.state != QuestState.UNFINISHED) return List.of();
|
||||||
|
|
||||||
return this.getQuestData().getFinishCond().stream()
|
return this.getQuestData().getFinishCond().stream()
|
||||||
.filter(cond -> cond.getType() == QuestContent.QUEST_CONTENT_ENTER_DUNGEON)
|
.filter(cond -> cond.getType() == QuestContent.QUEST_CONTENT_ENTER_DUNGEON)
|
||||||
.map(condition -> {
|
.map(
|
||||||
var params = condition.getParam();
|
condition -> {
|
||||||
// The first parameter is the ID of the dungeon.
|
var params = condition.getParam();
|
||||||
// The second parameter is the dungeon entry's scene point.
|
// The first parameter is the ID of the dungeon.
|
||||||
// ex. [1, 1] = dungeon ID 1, scene point 1 or 'KaeyaDungeon'.
|
// The second parameter is the dungeon entry's scene point.
|
||||||
return new IntIntImmutablePair(params[0], params[1]);
|
// ex. [1, 1] = dungeon ID 1, scene point 1 or 'KaeyaDungeon'.
|
||||||
})
|
return new IntIntImmutablePair(params[0], params[1]);
|
||||||
.toList();
|
})
|
||||||
|
.toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void save() {
|
public void save() {
|
||||||
|
@ -334,9 +334,7 @@ public final class Scene {
|
|||||||
List<List<T>> parts = new ArrayList<List<T>>();
|
List<List<T>> parts = new ArrayList<List<T>>();
|
||||||
final int N = list.size();
|
final int N = list.size();
|
||||||
for (int i = 0; i < N; i += L) {
|
for (int i = 0; i < N; i += L) {
|
||||||
parts.add(new ArrayList<T>(
|
parts.add(new ArrayList<T>(list.subList(i, Math.min(N, i + L))));
|
||||||
list.subList(i, Math.min(N, i + L)))
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
return parts;
|
return parts;
|
||||||
}
|
}
|
||||||
@ -351,7 +349,7 @@ public final class Scene {
|
|||||||
this.addEntityDirectly(entity);
|
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));
|
this.broadcastPacket(new PacketSceneEntityAppearNotify(l, visionType));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,8 @@ import emu.grasscutter.utils.GridPosition;
|
|||||||
import emu.grasscutter.utils.JsonUtils;
|
import emu.grasscutter.utils.JsonUtils;
|
||||||
import emu.grasscutter.utils.Position;
|
import emu.grasscutter.utils.Position;
|
||||||
import io.netty.util.concurrent.FastThreadLocalThread;
|
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.FileWriter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
@ -35,9 +37,6 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
|
||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
|
||||||
import kotlin.Pair;
|
import kotlin.Pair;
|
||||||
import lombok.val;
|
import lombok.val;
|
||||||
import org.luaj.vm2.LuaError;
|
import org.luaj.vm2.LuaError;
|
||||||
@ -64,8 +63,8 @@ public class SceneScriptManager {
|
|||||||
private ScriptMonsterSpawnService scriptMonsterSpawnService;
|
private ScriptMonsterSpawnService scriptMonsterSpawnService;
|
||||||
/** blockid - loaded groupSet */
|
/** blockid - loaded groupSet */
|
||||||
private final Map<Integer, Set<SceneGroup>> loadedGroupSetPerBlock;
|
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;
|
public static final ExecutorService eventExecutor;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
@ -118,8 +117,7 @@ public class SceneScriptManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Nullable public Map<String, Integer> getVariables(int group_id) {
|
@Nullable public Map<String, Integer> getVariables(int group_id) {
|
||||||
if (this.getCachedGroupInstanceById(group_id) == null)
|
if (this.getCachedGroupInstanceById(group_id) == null) return Collections.emptyMap();
|
||||||
return Collections.emptyMap();
|
|
||||||
return getCachedGroupInstanceById(group_id).getCachedVariables();
|
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);
|
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();
|
SceneGroup group = groupInstance.getLuaGroup();
|
||||||
if (suiteIndex == 0) {
|
if (suiteIndex == 0) {
|
||||||
if (excludePrevSuite) {
|
if (excludePrevSuite) {
|
||||||
@ -434,7 +437,7 @@ public class SceneScriptManager {
|
|||||||
public List<Grid> getGroupGrids() {
|
public List<Grid> getGroupGrids() {
|
||||||
int sceneId = scene.getId();
|
int sceneId = scene.getId();
|
||||||
if (groupGridsCache.containsKey(sceneId) && groupGridsCache.get(sceneId) != null) {
|
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);
|
return groupGridsCache.get(sceneId);
|
||||||
} else {
|
} else {
|
||||||
var path = FileUtils.getCachePath("scene" + sceneId + "_grid.json");
|
var path = FileUtils.getCachePath("scene" + sceneId + "_grid.json");
|
||||||
@ -442,70 +445,124 @@ public class SceneScriptManager {
|
|||||||
try {
|
try {
|
||||||
var groupGrids = JsonUtils.loadToList(path, Grid.class);
|
var groupGrids = JsonUtils.loadToList(path, Grid.class);
|
||||||
groupGridsCache.put(sceneId, groupGrids);
|
groupGridsCache.put(sceneId, groupGrids);
|
||||||
if(groupGrids != null) return groupGrids;
|
if (groupGrids != null) return groupGrids;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//otherwise generate the grids
|
// otherwise generate the grids
|
||||||
List<Map<GridPosition, Set<Integer>>> groupPositions = new ArrayList<>();
|
List<Map<GridPosition, Set<Integer>>> groupPositions = new ArrayList<>();
|
||||||
for (int i = 0; i < 6; i++) groupPositions.add(new HashMap<>());
|
for (int i = 0; i < 6; i++) groupPositions.add(new HashMap<>());
|
||||||
|
|
||||||
var visionOptions = Grasscutter.config.server.game.visionOptions;
|
var visionOptions = Grasscutter.config.server.game.visionOptions;
|
||||||
meta.blocks.values().forEach(block -> {
|
meta.blocks
|
||||||
block.load(sceneId, meta.context);
|
.values()
|
||||||
block.groups.values().stream().filter(g -> !g.dynamic_load).forEach(group -> {
|
.forEach(
|
||||||
group.load(this.scene.getId());
|
block -> {
|
||||||
|
block.load(sceneId, meta.context);
|
||||||
|
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<>();
|
Set<Integer> vision_levels = new HashSet<>();
|
||||||
|
|
||||||
if (group.monsters != null) {
|
if (group.monsters != null) {
|
||||||
group.monsters.values().forEach(m -> {
|
group
|
||||||
addGridPositionToMap(groupPositions.get(m.vision_level), group.id, m.vision_level, m.pos);
|
.monsters
|
||||||
vision_levels.add(m.vision_level);
|
.values()
|
||||||
});
|
.forEach(
|
||||||
} else {
|
m -> {
|
||||||
Grasscutter.getLogger().error("group.monsters null for group {}", group.id);
|
addGridPositionToMap(
|
||||||
}
|
groupPositions.get(m.vision_level),
|
||||||
if (group.gadgets != null) {
|
group.id,
|
||||||
group.gadgets.values().forEach(g -> {
|
m.vision_level,
|
||||||
int vision_level = Math.max(getGadgetVisionLevel(g.gadget_id), g.vision_level);
|
m.pos);
|
||||||
addGridPositionToMap(groupPositions.get(vision_level), group.id, vision_level, g.pos);
|
vision_levels.add(m.vision_level);
|
||||||
vision_levels.add(vision_level);
|
});
|
||||||
});
|
} else {
|
||||||
} else {
|
Grasscutter.getLogger()
|
||||||
Grasscutter.getLogger().error("group.gadgets null for group {}", group.id);
|
.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);
|
||||||
|
vision_levels.add(vision_level);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
Grasscutter.getLogger()
|
||||||
|
.error("group.gadgets null for group {}", group.id);
|
||||||
|
}
|
||||||
|
|
||||||
if (group.npcs != null) {
|
if (group.npcs != null) {
|
||||||
group.npcs.values().forEach(n -> addGridPositionToMap(groupPositions.get(n.vision_level), group.id, n.vision_level, n.pos));
|
group
|
||||||
} else {
|
.npcs
|
||||||
Grasscutter.getLogger().error("group.npcs null for group {}", group.id);
|
.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) {
|
if (group.regions != null) {
|
||||||
group.regions.values().forEach(r -> addGridPositionToMap(groupPositions.get(0), group.id, 0, r.pos));
|
group
|
||||||
} else {
|
.regions
|
||||||
Grasscutter.getLogger().error("group.regions null for group {}", group.id);
|
.values()
|
||||||
}
|
.forEach(
|
||||||
|
r ->
|
||||||
|
addGridPositionToMap(
|
||||||
|
groupPositions.get(0), group.id, 0, r.pos));
|
||||||
|
} else {
|
||||||
|
Grasscutter.getLogger()
|
||||||
|
.error("group.regions null for group {}", group.id);
|
||||||
|
}
|
||||||
|
|
||||||
if (group.garbages != null && group.garbages.gadgets != null)
|
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;
|
int max_vision_level = -1;
|
||||||
if (!vision_levels.isEmpty()) {
|
if (!vision_levels.isEmpty()) {
|
||||||
for (int vision_level : vision_levels) {
|
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
|
||||||
max_vision_level = vision_level;
|
|| visionOptions[max_vision_level].visionRange
|
||||||
}
|
< visionOptions[vision_level].visionRange)
|
||||||
}
|
max_vision_level = vision_level;
|
||||||
if (max_vision_level == -1) max_vision_level = 0;
|
}
|
||||||
|
}
|
||||||
|
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);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
var groupGrids = new ArrayList<Grid>();
|
var groupGrids = new ArrayList<Grid>();
|
||||||
for (int i = 0; i < 6; i++) {
|
for (int i = 0; i < 6; i++) {
|
||||||
@ -516,7 +573,8 @@ public class SceneScriptManager {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
Files.createDirectories(path.getParent());
|
Files.createDirectories(path.getParent());
|
||||||
} catch (IOException ignored) {}
|
} catch (IOException ignored) {
|
||||||
|
}
|
||||||
try (var file = new FileWriter(path.toFile())) {
|
try (var file = new FileWriter(path.toFile())) {
|
||||||
file.write(JsonUtils.encode(groupGrids));
|
file.write(JsonUtils.encode(groupGrids));
|
||||||
Grasscutter.getLogger().info("Scene {} saved grid file.", getScene().getId());
|
Grasscutter.getLogger().info("Scene {} saved grid file.", getScene().getId());
|
||||||
@ -658,7 +716,8 @@ public class SceneScriptManager {
|
|||||||
this.addGroupSuite(groupInstance, suite, null);
|
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
|
// we added trigger first
|
||||||
registerTrigger(suite.sceneTriggers);
|
registerTrigger(suite.sceneTriggers);
|
||||||
|
|
||||||
@ -666,8 +725,7 @@ public class SceneScriptManager {
|
|||||||
var toCreate = new ArrayList<GameEntity>();
|
var toCreate = new ArrayList<GameEntity>();
|
||||||
toCreate.addAll(getGadgetsInGroupSuite(groupInstance, suite));
|
toCreate.addAll(getGadgetsInGroupSuite(groupInstance, suite));
|
||||||
toCreate.addAll(getMonstersInGroupSuite(groupInstance, suite));
|
toCreate.addAll(getMonstersInGroupSuite(groupInstance, suite));
|
||||||
if (entities != null)
|
if (entities != null) entities.addAll(toCreate);
|
||||||
entities.addAll(toCreate);
|
|
||||||
else this.addEntities(toCreate);
|
else this.addEntities(toCreate);
|
||||||
|
|
||||||
registerRegionInGroupSuite(group, suite);
|
registerRegionInGroupSuite(group, suite);
|
||||||
|
@ -7,7 +7,6 @@ import java.io.Serializable;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import lombok.SneakyThrows;
|
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
public final class GridPosition implements Serializable {
|
public final class GridPosition implements Serializable {
|
||||||
@ -92,7 +91,7 @@ public final class GridPosition implements Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public double[] toDoubleArray() {
|
public double[] toDoubleArray() {
|
||||||
return new double[]{ x, z };
|
return new double[] {x, z};
|
||||||
}
|
}
|
||||||
|
|
||||||
public int[] toXZIntArray() {
|
public int[] toXZIntArray() {
|
||||||
@ -100,7 +99,7 @@ public final class GridPosition implements Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Point toPoint() {
|
public Point toPoint() {
|
||||||
return Point.create(x,z);
|
return Point.create(x, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user