Skip to content

Commit

Permalink
Merge pull request #143 from FFXIV-CombatReborn/mergeWIP
Browse files Browse the repository at this point in the history
pragma warning disable
  • Loading branch information
CarnifexOptimus authored Jun 26, 2024
2 parents 7f4fe7b + 137e5f3 commit 9e0c5c5
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions BossMod/Autorotation/Strategy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,22 +52,16 @@ public record struct StrategyValue()
public string Comment = ""; // user-editable comment string
}

public readonly record struct StrategyValues
#pragma warning disable CA2227
public record struct StrategyValues(List<StrategyConfig> Configs)
{
public List<StrategyConfig> Configs { get; }
public StrategyValue[] Values { get; }

public StrategyValues(List<StrategyConfig> configs)
{
Configs = configs;
Values = Utils.MakeArray(Configs.Count, new StrategyValue());
}
public StrategyValue[] Values = Utils.MakeArray(Configs.Count, new StrategyValue());

// unfortunately, c# doesn't support partial type inference, and forcing user to spell out track enum twice is obnoxious, so here's the hopefully cheap solution
public readonly struct OptionRef(StrategyConfig config, StrategyValue value)
public readonly ref struct OptionRef(ref StrategyConfig config, ref StrategyValue value)
{
public readonly StrategyConfig Config = config;
public readonly StrategyValue Value = value;
public readonly ref readonly StrategyConfig Config = ref config;
public readonly ref readonly StrategyValue Value = ref value;

public OptionType As<OptionType>() where OptionType : Enum
{
Expand All @@ -82,6 +76,7 @@ public OptionType As<OptionType>() where OptionType : Enum
public readonly OptionRef Option<TrackIndex>(TrackIndex index) where TrackIndex : Enum
{
var idx = (int)(object)index;
return new OptionRef(Configs[idx], Values[idx]);
return new(ref Configs.Ref(idx), ref Values[idx]);
}
}
#pragma warning restore CA2227

0 comments on commit 9e0c5c5

Please sign in to comment.