Skip to content

Instantly share code, notes, and snippets.

@MatthewBlanchard
Created July 28, 2018 22:58
Show Gist options
  • Save MatthewBlanchard/6eb837ab858edacc61fd3ad29c0364dd to your computer and use it in GitHub Desktop.
Save MatthewBlanchard/6eb837ab858edacc61fd3ad29c0364dd to your computer and use it in GitHub Desktop.
private void CheckRange()
{
InArcInfo = new Dictionary<GenericArc, bool>();
List<System.Type> WeaponArcRestrictions = (Weapon is GenericSecondaryWeapon) ? (Weapon as GenericSecondaryWeapon).ArcRestrictions : null;
WeaponTypes weaponType = (Weapon is GenericSecondaryWeapon) ? (Weapon as GenericSecondaryWeapon).WeaponType : WeaponTypes.PrimaryWeapon;
foreach (var arc in Ship1.ArcInfo.Arcs)
{
ShotInfoArc shotInfoArc = new ShotInfoArc(Ship1, Ship2, arc);
InArcInfo.Add(arc, shotInfoArc.InArc);
if (!arc.ShotPermissions.CanShootByWeaponType(weaponType))
continue;
if (WeaponArcRestrictions != null && !WeaponArcRestrictions.Contains(arc.GetType()))
continue;
if (shotInfoArc.IsShotAvailable)
{
if (IsShotAvailable == false)
{
MinDistance = shotInfoArc.MinDistance;
}
else
{
if (shotInfoArc.MinDistance.DistanceReal < MinDistance.DistanceReal) MinDistance = shotInfoArc.MinDistance;
}
IsShotAvailable = true;
}
if (NearestFailedDistance == null)
{
NearestFailedDistance = shotInfoArc.MinDistance;
}
else if (shotInfoArc.MinDistance.DistanceReal < NearestFailedDistance.DistanceReal)
{
NearestFailedDistance = shotInfoArc.MinDistance;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment