Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

code analyzer fixes #623

Merged
merged 1 commit into from
Feb 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion BossMod/Components/BaitAway.cs
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ public override void AddHints(int slot, Actor actor, TextHints hints)
if (ActiveBaits.Count == 0)
return;
base.AddHints(slot, actor, hints);
if (ActiveBaitsOn(actor).Any(b => PlayersClippedBy(b).Any()))
if (ActiveBaitsOn(actor).Any(b => PlayersClippedBy(b).Count != 0))
hints.Add(BaitAwayHint);
}
}
2 changes: 1 addition & 1 deletion BossMod/Modules/Dawntrail/Savage/M03SBruteBomber/Lariat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public override void AddHints(int slot, Actor actor, TextHints hints)
}
else
{
hints.Add("Spread!", clipped.Any());
hints.Add("Spread!", clipped.Count != 0);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion BossMod/Modules/Dawntrail/Ultimate/FRU/P2DiamondDust.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public override void AddHints(int slot, Actor actor, TextHints hints)
{
if (baitIndex < 0)
hints.Add("Stay closer to bait!");
else if (PlayersClippedBy(CurrentBaits[baitIndex]).Any())
else if (PlayersClippedBy(CurrentBaits[baitIndex]).Count != 0)
hints.Add("Bait cone away from raid!");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public override void AddHints(int slot, Actor actor, TextHints hints)
{
if (baitIndex < 0)
hints.Add("Stay closer to bait!");
else if (PlayersClippedBy(CurrentBaits[baitIndex]).Any())
else if (PlayersClippedBy(CurrentBaits[baitIndex]).Count != 0)
hints.Add("Bait cone away from raid!");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public override void AddHints(int slot, Actor actor, TextHints hints)
if (t.target == actor)
{
++numBaits;
clipping |= Raid.WithoutSlot(false, true, true).Exclude(actor).InShape(_shape, b.Source.Position, t.dir).Any();
clipping |= Raid.WithoutSlot(false, true, true).Exclude(actor).InShape(_shape, b.Source.Position, t.dir).Count != 0;
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public override void AddHints(int slot, Actor actor, TextHints hints)
{
if (_playerStacks[slot] >= 2)
hints.Add("Pass aggro!");
if (Raid.WithoutSlot(false, true, true).Exclude(actor).InShape(_shape, Module.PrimaryActor.Position, Angle.FromDirection(actor.Position - Module.PrimaryActor.Position)).Any())
if (Raid.WithoutSlot(false, true, true).Exclude(actor).InShape(_shape, Module.PrimaryActor.Position, Angle.FromDirection(actor.Position - Module.PrimaryActor.Position)).Count != 0)
hints.Add("GTFO from raid!");
}
else if (CurrentBaits.Count > 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ public override void AddHints(int slot, Actor actor, TextHints hints)
var isSpread = _spreadTargets.Contains(actor);
if (_spreadTargets.Any(t => t != actor && _shapeSpread.Check(actor.Position, Module.PrimaryActor.Position, Angle.FromDirection(t.Position - Module.PrimaryActor.Position))))
hints.Add("GTFO from other spreads!");
if (isSpread && Raid.WithoutSlot(false, true, true).Exclude(actor).InShape(_shapeSpread, Module.PrimaryActor.Position, Angle.FromDirection(actor.Position - Module.PrimaryActor.Position)).Any())
if (isSpread && Raid.WithoutSlot(false, true, true).Exclude(actor).InShape(_shapeSpread, Module.PrimaryActor.Position, Angle.FromDirection(actor.Position - Module.PrimaryActor.Position)).Count != 0)
hints.Add("Aim spread away from raid!");

if (_stackTarget == actor)
{
if (_spreadTargets.InShape(_shapeStack, Module.PrimaryActor.Position, Angle.FromDirection(actor.Position - Module.PrimaryActor.Position)).Any())
if (_spreadTargets.InShape(_shapeStack, Module.PrimaryActor.Position, Angle.FromDirection(actor.Position - Module.PrimaryActor.Position)).Count != 0)
hints.Add("Aim stack away from spreads!");
}
else if (_stackTarget != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public override void AddHints(int slot, Actor actor, TextHints hints)
hints.Add("GTFO from aoe!");
break;
case Shape.Spread:
hints.Add("Spread!", Raid.WithoutSlot(false, true, true).Exclude(actor).InShape(_shapeSpread, c.Origin.Position, Angle.FromDirection(actor.Position - c.Origin.Position)).Any());
hints.Add("Spread!", Raid.WithoutSlot(false, true, true).Exclude(actor).InShape(_shapeSpread, c.Origin.Position, Angle.FromDirection(actor.Position - c.Origin.Position)).Count != 0);
break;
case Shape.Pairs:
var actorIsSupport = actor.Class.IsSupport();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public override void AddHints(int slot, Actor actor, TextHints hints)
if (_vulnerable[slot])
{
var source = _tethers.Find(t => t.target == actor).source;
var numHit = source != null ? Raid.WithoutSlot(false, true, true).Exclude(actor).InShape(_shape, source.Position, Angle.FromDirection(actor.Position - source.Position)).Count() : 0;
var numHit = source != null ? Raid.WithoutSlot(false, true, true).Exclude(actor).InShape(_shape, source.Position, Angle.FromDirection(actor.Position - source.Position)).Count : 0;
if (numHit == 0)
hints.Add("Hide behind partner!");
else if (numHit > 1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public override void AddHints(int slot, Actor actor, TextHints hints)
{
if (actor.InstanceID == target.InstanceID)
{
if (Raid.WithoutSlot(false, true, true).Exclude(actor).InShape(_shape, Origin(target), default).Any())
if (Raid.WithoutSlot(false, true, true).Exclude(actor).InShape(_shape, Origin(target), default).Count != 0)
hints.Add("Bait away from raid!");
}
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,6 @@ public override void DrawArenaForeground(int pcSlot, Actor pc)
}
}

private IEnumerable<(int, Actor)> FindPlayersInWinds(Actor origin, Actor target)
{
return Raid.WithSlot(false, true, true).InShape(_windsAOE, origin.Position, Angle.FromDirection(target.Position - origin.Position));
}
private List<(int, Actor)> FindPlayersInWinds(Actor origin, Actor target)
=> Raid.WithSlot(false, true, true).InShape(_windsAOE, origin.Position, Angle.FromDirection(target.Position - origin.Position));
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public override void AddHints(int slot, Actor actor, TextHints hints)
if (tetheredCaster == null)
return; // non-tethered players shouldn't need to worry about this mechanic

if (Raid.WithoutSlot(false, true, true).Exclude(actor).InShape(_shape, tetheredCaster).Any())
if (Raid.WithoutSlot(false, true, true).Exclude(actor).InShape(_shape, tetheredCaster).Count != 0)
hints.Add("Bait away from raid!");
if (_tethers.Any(t => t.target != actor && _shape.Check(actor.Position, t.source)))
hints.Add("Move away from other baits!");
Expand Down
2 changes: 1 addition & 1 deletion BossMod/Modules/Endwalker/Ultimate/DSW2/P6HallowedWings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public override void AddHints(int slot, Actor actor, TextHints hints)
{
if (shouldBait)
{
if (ActiveBaitsOn(actor).Any(b => PlayersClippedBy(b).Any()))
if (ActiveBaitsOn(actor).Any(b => PlayersClippedBy(b).Count != 0))
hints.Add("Bait away from raid!");
}
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,13 @@ public override IEnumerable<AOEInstance> ActiveAOEs(int slot, Actor actor)

public override void OnStatusGain(Actor actor, ActorStatus status)
{
if ((SID)status.ID == SID.Transporting)
if (status.ID == (uint)SID.Transporting)
transporting.Set(Raid.FindSlot(actor.InstanceID));
}

public override void OnStatusLose(Actor actor, ActorStatus status)
{
if ((SID)status.ID == SID.Transporting)
if (status.ID == (uint)SID.Transporting)
transporting[Raid.FindSlot(actor.InstanceID)] = default;
}

Expand All @@ -98,17 +98,17 @@ private static Square[] GenerateRotatedTiles(float angle)

public override void OnCastStarted(Actor caster, ActorCastInfo spell)
{
if ((AID)spell.Action.ID == AID.DirectSeeding)
if (spell.Action.ID == (uint)AID.DirectSeeding)
++NumCasts;
else if ((AID)spell.Action.ID == AID.IrefulWind)
else if (spell.Action.ID == (uint)AID.IrefulWind)
{
var knockbackDirection = new Angle(MathF.Round(spell.Rotation.Deg / 90) * 90) * Angle.DegToRad;
var knockbackDirection = new Angle(MathF.Round(spell.Rotation.Deg / 90f) * 90f) * Angle.DegToRad;
var offset = 10 * knockbackDirection.ToDirection();
var tileList = tiles.ToList();
var newTiles = new List<Square>(10);
for (var i = 0; i < tileList.Count; ++i)
tileList[i] = new(tileList[i].Center - offset, tileList[i].HalfSize);
foreach (var t in tileList.Where(x => (caster.Position - x.Center).LengthSq() > 625))
foreach (var t in tileList.Where(x => (caster.Position - x.Center).LengthSq() > 625f))
newTiles.Add(new(t.Center + offset, t.HalfSize));
tileList.AddRange(newTiles);
tiles = [.. tileList];
Expand All @@ -133,18 +133,18 @@ public override void AddAIHints(int slot, Actor actor, PartyRolesConfig.Assignme
transportingCheckStartTimes.Remove(actor);
}

private IEnumerable<Actor> GetClippedSeeds(AOEInstance shape)
private List<Actor> GetClippedSeeds(AOEInstance shape)
=> Module.Enemies(D092LeananSith.Seeds).Where(x => x.IsTargetable).InShape(shape.Shape, shape.Origin, default);

private void HandleNonTransportingActor(Actor actor, AIHints hints, IEnumerable<Actor> clippedSeeds, Actor closestSeed)
{
var forbidden = new List<Func<WPos, float>>(4);
foreach (var seed in clippedSeeds)
forbidden.Add(ShapeDistance.InvertedCircle(seed.Position, 3));
forbidden.Add(ShapeDistance.InvertedCircle(seed.Position, 3f));
var distance = (actor.Position - closestSeed.Position).LengthSq();
if (forbidden.Count > 0 && distance > 9)
if (forbidden.Count > 0 && distance > 9f)
hints.AddForbiddenZone(ShapeDistance.Intersection(forbidden));
else if (distance < 9)
else if (distance < 9f)
hints.InteractWithTarget = closestSeed;
}

Expand Down Expand Up @@ -172,7 +172,7 @@ public override void AddHints(int slot, Actor actor, TextHints hints)
else if (!trans)
{
var aoes = ActiveAOEs(slot, actor).FirstOrDefault();
if (aoes.Shape != null && GetClippedSeeds(aoes).Any())
if (aoes.Shape != null && GetClippedSeeds(aoes).Count != 0)
hints.Add("Pick up seeds in vulnerable squares!");
}
}
Expand Down