Skip to content

Commit

Permalink
Merge pull request #146 from FFXIV-CombatReborn/mergeWIP2
Browse files Browse the repository at this point in the history
pragma warning disable
  • Loading branch information
CarnifexOptimus authored Jun 30, 2024
2 parents 5ffd546 + c866226 commit a1f10fa
Showing 1 changed file with 5 additions and 23 deletions.
28 changes: 5 additions & 23 deletions BossMod/Autorotation/Strategy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,29 +51,10 @@ public record struct StrategyValue()
public int TargetParam; // strategy-specific parameter
public string Comment = ""; // user-editable comment string
}

public readonly record struct StrategyValues
#pragma warning disable CA2227
public record struct StrategyValues(List<StrategyConfig> Configs)
{
private readonly List<StrategyConfig> _configs;

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

public readonly IReadOnlyList<StrategyConfig> Configs => _configs.AsReadOnly();
public StrategyValue[] Values { get; }

public readonly void AddConfig(StrategyConfig config)
{
_configs.Add(config);
}

public readonly void RemoveConfig(StrategyConfig config)
{
_configs.Remove(config);
}
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 ref struct OptionRef(ref StrategyConfig config, ref StrategyValue value)
Expand All @@ -94,6 +75,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(ref _configs.Ref(idx), ref Values[idx]);
return new(ref Configs.Ref(idx), ref Values[idx]);
}
}
#pragma warning restore CA2227

0 comments on commit a1f10fa

Please sign in to comment.