Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
fix: fixed the reflection issue.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Sep 12, 2023
1 parent 84f60d6 commit 7a05738
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 43 deletions.
20 changes: 15 additions & 5 deletions RotationSolver/ActionSequencer/ConditionHelper.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
using ECommons.GameHelpers;
using Dalamud.Logging;
using ECommons.GameHelpers;
using RotationSolver.Localization;
using RotationSolver.UI;
using RotationSolver.Updaters;

namespace RotationSolver.ActionSequencer;

internal class ConditionHelper
internal static class ConditionHelper
{
public static bool CheckBaseAction(ICustomRotation rotation, ActionID id, ref IBaseAction action)
{
Expand All @@ -17,21 +18,30 @@ public static bool CheckBaseAction(ICustomRotation rotation, ActionID id, ref IB
return true;
}

public static void CheckMemberInfo<T>(ICustomRotation rotation, string name, ref T value) where T : MemberInfo
public static void CheckMemberInfo<T>(ICustomRotation rotation, ref string name, ref T value) where T : MemberInfo
{
if (!string.IsNullOrEmpty(name) && (value == null || value.Name != name))
{
var memberName = name;
if (typeof(T).IsAssignableFrom(typeof(PropertyInfo)))
{
value = (T)(MemberInfo)rotation.GetType().GetPropertyInfo(name);
value = (T)rotation.GetType().GetAllMethods(RuntimeReflectionExtensions.GetRuntimeProperties).FirstOrDefault(m => m.Name == memberName);
}
else if (typeof(T).IsAssignableFrom(typeof(MethodInfo)))
{
value = (T)(MemberInfo)rotation.GetType().GetMethodInfo(name);
value = (T)rotation.GetType().GetAllMethods(RuntimeReflectionExtensions.GetRuntimeMethods).FirstOrDefault(m => m.Name == memberName);
}
}
}

private static IEnumerable<MemberInfo> GetAllMethods(this Type type, Func<Type, IEnumerable<MemberInfo>> getFunc)
{
if (type == null || getFunc == null) return Array.Empty<MemberInfo>();

var methods = getFunc(type);
return methods.Union(GetAllMethods(type.BaseType, getFunc));
}

public static void DrawByteEnum<T>(string name, ref T value, Func<T, string> function) where T : struct, Enum
{
var values = Enum.GetValues<T>();
Expand Down
14 changes: 7 additions & 7 deletions RotationSolver/ActionSequencer/RotationCondition.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using ECommons.GameHelpers;
using Dalamud.Logging;
using ECommons.GameHelpers;
using RotationSolver.Localization;
using RotationSolver.UI;

Expand All @@ -8,13 +9,12 @@ internal class RotationCondition : BaseCondition
{
public ComboConditionType ComboConditionType = ComboConditionType.Float;
PropertyInfo _prop;
public string PropertyName { get; set; } = nameof(CustomRotation.CombatTime);
public string PropertyName = nameof(CustomRotation.CombatTime);

MethodInfo _method;
public string MethodName { get; set; } = string.Empty;
public string MethodName = string.Empty;

IBaseAction _action;

public ActionID ID { get; set; } = ActionID.None;

public int Condition;
Expand All @@ -25,8 +25,8 @@ internal class RotationCondition : BaseCondition
private void UpdateInfo(ICustomRotation rotation)
{
ConditionHelper.CheckBaseAction(rotation, ID, ref _action);
ConditionHelper.CheckMemberInfo(rotation, PropertyName, ref _prop);
ConditionHelper.CheckMemberInfo(rotation, MethodName, ref _method);
ConditionHelper.CheckMemberInfo(rotation, ref PropertyName, ref _prop);
ConditionHelper.CheckMemberInfo(rotation, ref MethodName, ref _method);
}

public override bool IsTrueInside(ICustomRotation rotation)
Expand Down Expand Up @@ -95,7 +95,7 @@ public override bool IsTrueInside(ICustomRotation rotation)
{
if (_method?.Invoke(rotation, new object[] { Param1 > 0, new IAction[] { _action } }) is bool boo)
{
return Condition > 0 ? boo : !boo;
return Condition > 0 ? !boo : boo;
}
return false;
}
Expand Down
62 changes: 31 additions & 31 deletions RotationSolver/Localization/Localization.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@
"ConfigWindow_Param_UseOverlayWindow": "Display UI Overlay",
"ConfigWindow_Param_UseOverlayWindowDesc": "This top window is used to display some extra information on your game window, such as target's positional, target and sub-target, etc.",
"ConfigWindow_Param_ActionAhead": "Set the time advance of using actions",
"ConfigWindow_Param_MinLastAbilityAdvanced": "Set min the time advance of using the last 0gcd.",
"ConfigWindow_Param_MinLastAbilityAdvanced": "Set minimum the time in advance before using the last 0gcd.",
"ConfigWindow_Param_CountDownAhead": "Set the number of seconds combat abilities will be used before finishing the countdown",
"ConfigWindow_Param_SpecialDuration": "Set the duration of special windows set by commands",
"ConfigWindow_Param_AddDotGCDCount": "Set GCD advance of DOT refresh",
"ConfigWindow_Param_AddDotGCDCount": "Set the number of GCDs in advance for DOT refreshing",
"ConfigWindow_Param_MaxPing": "Set the max ping that RS can get to before skipping to the next action.",
"ConfigWindow_Param_AutoOffBetweenArea": "Auto turn off when player is moving between areas.",
"ConfigWindow_Param_AutoOffAfterCombat": "Auto turn off RS when combat is over more for more then...",
Expand All @@ -54,7 +54,7 @@
"ConfigWindow_Param_ToggleAuto": "Make /rotation Auto as a toggle command.",
"ConfigWindow_Param_WeaponDelay": "Set the range of random delay for GCD usage in seconds.",
"ConfigWindow_Param_DeathDelay": "Set the range of random delay for using revival abilities in seconds.",
"ConfigWindow_Param_HostileDelay": "Set the range of random delay for targeting hostile targets in seconds.",
"ConfigWindow_Param_HostileDelay": "Set the range of random delay for targeting in seconds.",
"ConfigWindow_Param_InterruptDelay": "Set the range of random delay for interrupting hostile targets in seconds.",
"ConfigWindow_Param_WeakenDelay": "Set the range of random delay for cleansing dispellable debuffs in seconds.",
"ConfigWindow_Param_HealDelay": "Set the range of random delay for healing people in seconds.",
Expand Down Expand Up @@ -89,14 +89,14 @@
"ConfigWindow_Param_ShowInfoOnDtr": "Display plugin status on server info",
"ConfigWindow_Param_ShowInfoOnToast": "Display plugin status on toast",
"ConfigWindow_Param_ShowToastsAboutDoAction": "Display do action feedback on toast",
"ConfigWindow_Param_UseAOEAction": "Use AOE actions",
"ConfigWindow_Param_UseAOEWhenManual": "Use AOE actions in manual mode",
"ConfigWindow_Param_UseAOEAction": "Use AoE actions",
"ConfigWindow_Param_UseAOEWhenManual": "Use AoE actions in manual mode",
"ConfigWindow_Param_AutoBurst": "Automatically trigger dps burst phase",
"ConfigWindow_Param_AutoHeal": "Automatic Heal",
"ConfigWindow_Param_UseAbility": "Auto-use abilities",
"ConfigWindow_Param_NoNewHostiles": "Don't attack new mobs by aoe",
"ConfigWindow_Params_NoNewHostilesDesc": "Never use any AOE action when this action may attack the mobs that are not hostile targets.",
"ConfigWindow_Param_UseDefenseAbility": "Use defense abilities",
"ConfigWindow_Param_NoNewHostiles": "Don't attack new mobs by AoE",
"ConfigWindow_Params_NoNewHostilesDesc": "Never use any AoE action when this action may attack the mobs that are not hostile targets.",
"ConfigWindow_Param_UseDefenseAbility": "Use defensive abilities",
"ConfigWindow_Param_UseDefenseAbilityDesc": "It is recommended to check this option if you are playing Raids or you can plan the heal and defense ability usage by yourself.",
"ConfigWindow_Param_AutoShield": "Automatically activate tank stance",
"ConfigWindow_Param_AutoProvokeForTank": "Auto provoke non-tank attacking targets",
Expand All @@ -105,7 +105,7 @@
"ConfigWindow_Param_RaisePlayerBySwift": "Raise player by using swiftcast if avaliable",
"ConfigWindow_Param_UseGroundBeneficialAbility": "Use beneficial ground-targeted actions",
"ConfigWindow_Param_AutoSpeedOutOfCombat": "Use movement speed increase abilities when out of combat.",
"ConfigWindow_Param_RaisePlayerByCasting": "Raise player while swiftcast is in cooldown",
"ConfigWindow_Param_RaisePlayerByCasting": "Raise player while swiftcast is on cooldown",
"ConfigWindow_Param_UseHealWhenNotAHealer": "Use healing abilities when playing a non-healer role",
"ConfigWindow_Param_LessMPNoRaise": "Never raise player if MP is less than the set value",
"ConfigWindow_Param_UseTinctures": "Use Tinctures",
Expand All @@ -120,28 +120,28 @@
"ConfigWindow_Param_BeneficialAreaOnlyOnLocations": "Only on predefined location",
"ConfigWindow_Param_BeneficialAreaOnTarget": "On target",
"ConfigWindow_Param_BeneficialAreaOnCalculated": "On the calculated location",
"ConfigWindow_Param_HealthDifference": "HP%% for standard deviation for using AOE heal.",
"ConfigWindow_Param_HealthAreaAbility": "HP%% for AOE healing OGCDs",
"ConfigWindow_Param_HealthAreaSpell": "HP%% for AOE healing GCDs",
"ConfigWindow_Param_HealthDifference": "HP%% for standard deviation for using AoE heal.",
"ConfigWindow_Param_HealthAreaAbility": "HP%% for AoE healing oGCDs",
"ConfigWindow_Param_HealthAreaSpell": "HP%% for AoE healing GCDs",
"ConfigWindow_Param_Normal": "Normal Targets",
"ConfigWindow_Param_HOT": "Targets with HOT",
"ConfigWindow_Param_HealthSingleAbility": "HP%% for ST healing OGCDs",
"ConfigWindow_Param_HealthSingleAbility": "HP%% for ST healing oGCDs",
"ConfigWindow_Param_HealthSingleSpell": "HP%% for ST healing GCDs",
"ConfigWindow_Param_HealthHealerRatio": "Heal healer first if its HP%% is lower than this.",
"ConfigWindow_Param_HealthTankRatio": "Heal tank first if its HP%% is lower than this.",
"ConfigWindow_Param_DistanceForMoving": "Use gapcloser as a damage ability if the distance to your target is less then this.",
"ConfigWindow_Param_HealWhenNothingTodo": "Healing the members with GCD if there is nothing to do in combat.",
"ConfigWindow_Param_HealWhenNothingTodoBelow": "When their min HP%% is lower than this.",
"ConfigWindow_Param_HealWhenNothingTodoBelow": "When their minimum HP%% is lower than this.",
"ConfigWindow_Param_HealWhenNothingTodoDelay": "The delay of this type of healing.",
"ConfigWindow_Param_HealthForDyingTank": "Set the HP%% for tank to use invulnerability",
"ConfigWindow_Param_MeleeRangeOffset": "Melee Range action using offset",
"ConfigWindow_Param_RightNowTargetToHostileType": "Engage settings",
"ConfigWindow_Param_TargetToHostileType1": "All targets that you can attack and are in range for any abilities",
"ConfigWindow_Param_TargetToHostileType2": "Targets have a target or all targets can attack",
"ConfigWindow_Param_TargetToHostileType3": "Targets that already have a target or are hostile towards the player/player party",
"ConfigWindow_Param_AddEnemyListToHostile": "Add Enemies list to the hostile targets.",
"ConfigWindow_Param_AddEnemyListToHostile": "Add enemies list to the hostile targets.",
"ConfigWindow_Param_ChooseAttackMark": "Priority attack targets with attack markers",
"ConfigWindow_Param_CanAttackMarkAOE": "Allowed use of AOE to attack more mobs.",
"ConfigWindow_Param_CanAttackMarkAOE": "Allowed use of AoE to attack more mobs.",
"ConfigWindow_Param_AttackMarkAOEDesc": "Attention: Checking this option , AA will attack as many hostile targets as possible, while ignoring whether the attack will cover the marked target.",
"ConfigWindow_Param_FilterStopMark": "Never attack targets with stop markers",
"ConfigWindow_Param_MoveTargetAngle": "The size of the sector angle that can be selected as the moveable target",
Expand Down Expand Up @@ -185,18 +185,18 @@
"ConfigWindow_Rotation_InvalidRotation": "Invalid Rotation! \nPlease update to the latest version or contact to the {0}!",
"ConfigWindow_List_Description": "In this window, you can set the parameters about some list things.",
"ConfigWindow_List_Hostile": "Hostile",
"ConfigWindow_List_Invincibility": "Invincibility",
"ConfigWindow_List_InvincibilityDesc": "If target get one of this statuses, never attack it.",
"ConfigWindow_List_DangerousStatus": "Dangerous Status",
"ConfigWindow_List_DangerousStatusDesc": "Esuna immediately if one of your party members get these statuses",
"ConfigWindow_List_Invincibility": "Invulnerability",
"ConfigWindow_List_InvincibilityDesc": "Ignores target if it has one of this statuses",
"ConfigWindow_List_DangerousStatus": "Dispellable debuffs",
"ConfigWindow_List_DangerousStatusDesc": "Esuna dispellable debuffs list",
"ConfigWindow_List_HostileCastingTank": "Tank Buster",
"ConfigWindow_List_HostileCastingTankDesc": "Use tank personal damage mitigation abilities if the target is casting any of these actions",
"ConfigWindow_List_HostileCastingArea": "AOE",
"ConfigWindow_List_HostileCastingAreaDesc": "Use AOE damage mitigation abilities if the target is casting any of these actions",
"ConfigWindow_List_NoHostile": "No Hostile",
"ConfigWindow_List_NoProvoke": "No Provoke",
"ConfigWindow_List_NoHostileDesc": "Add names of targets that will never be attacked.",
"ConfigWindow_List_NoProvokeDesc": "Add names of targets that will never be provoked.",
"ConfigWindow_List_HostileCastingArea": "AoE",
"ConfigWindow_List_HostileCastingAreaDesc": "Use AoE damage mitigation abilities if the target is casting any of these actions",
"ConfigWindow_List_NoHostile": "Don't target",
"ConfigWindow_List_NoProvoke": "Don't provoke",
"ConfigWindow_List_NoHostileDesc": "Enemies that will never be targeted.",
"ConfigWindow_List_NoProvokeDesc": "Enemies that will never be provoked.",
"ActionSequencer_Load": "Load From folder.",
"ActionSequencer_Can": "Can",
"ActionSequencer_Cannot": "Can Not",
Expand Down Expand Up @@ -450,16 +450,16 @@
"ConfigWindow_Rotations_Library": "The folder contains rotation libs or the download url about rotation lib.",
"ConfigWindow_List_Statuses": "Statuses",
"ConfigWindow_List_Actions": "Actions",
"ConfigWindow_List_Territories": "Map settings",
"ConfigWindow_List_Territories": "Map specific settings",
"ConfigWindow_List_StatusNameOrId": "Status name or id",
"ConfigWindow_Actions_MemberName": "Member Name",
"ConfigWindow_List_AddStatus": "Add Status",
"ConfigWindow_List_Remove": "Remove",
"ConfigWindow_List_ActionNameOrId": "Action name or id",
"ConfigWindow_List_AddAction": "Add Action",
"ConfigWindow_List_BeneficialPositions": "Beneficial AoE locations",
"ConfigWindow_List_NoHostilesName": "The name of object that you don't want to attack",
"ConfigWindow_List_NoProvokeName": "The name of object that you don't want to provoke",
"ConfigWindow_List_NoHostilesName": "The name of the enemy that you don't want to be targeted",
"ConfigWindow_List_NoProvokeName": "The name of the enemy that you don't want to be provoked",
"ConfigWindow_Basic_AutoSwitch": "Auto Switch",
"ConfigWindow_Basic_Timer": "Timer",
"ConfigWindow_UI_Windows": "Windows",
Expand Down Expand Up @@ -503,7 +503,7 @@
"ConfigWindow_About_ClickingCount": "Rotation Solver helped you by clicking actions {0:N0} times.",
"ConfigWindow_About_ClickingTooMuch": "Well, you must be a lazy player!",
"ConfigWindow_Auto_AutoHealTimeToKill": "Auto heal before combat end several seconds.",
"ConfigWindow_UI_ShowHostiles": "Show the hostile targets",
"ConfigWindow_UI_ShowHostiles": "Show the hostile target icon",
"ConfigWindow_UI_HostileIconHeight": "Hostile Icon height from position",
"ConfigWindow_UI_HostileIconSize": "Hostile Icon size",
"ConfigWindow_UI_StateIconHeight": "State icon height",
Expand All @@ -515,7 +515,7 @@
"ConfigWindow_Target_VisionCone": "The angle of your vision cone",
"ConfigWindow_Auto_ProvokeDelay": "The delay of provoke in seconds.",
"ConfigWindow_UI_TTKTextColor": "The text color of TTK.",
"ConfigWindow_Basic_MinUpdatingTime": "The min time between updating information in second.",
"ConfigWindow_Basic_MinUpdatingTime": "The minimum time between updating RS informations in seconds.",
"ConfigWindow_Actions_AOECount": "How many targets are needed to use this action.",
"ConfigWindow_Actions_TTK": "TTK that this action needs the target be.",
"ConfigWindow_Actions_HealRatio": "The HP ratio to auto heal"
Expand Down

0 comments on commit 7a05738

Please sign in to comment.