Skip to content

Commit

Permalink
Fix KSP-KOS#2669: asteroids:
Browse files Browse the repository at this point in the history
add STOPTRACKING and SIZECLASS suffixes to Vessel
  • Loading branch information
JonnyOThan authored and PiezPiedPy committed Nov 22, 2020
1 parent f4e95f5 commit 9171246
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/kOS/Suffixed/VesselTarget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,8 @@ private void InitializeSuffixes()
AddSuffix("MESSAGES", new NoArgsSuffix<MessageQueueStructure>(() => GetMessages()));

AddSuffix("STARTTRACKING", new NoArgsVoidSuffix(StartTracking));
AddSuffix("STOPTRACKING", new NoArgsVoidSuffix(StopTracking));
AddSuffix("SIZECLASS", new Suffix<StringValue>(GetSizeClass));

AddSuffix("SOICHANGEWATCHERS", new NoArgsSuffix<UniqueSetValue<UserDelegate>>(() => Shared.DispatchManager.CurrentDispatcher.GetSOIChangeNotifyees(Vessel)));
}
Expand Down Expand Up @@ -449,6 +451,36 @@ private void StartTracking()
}
}

private void StopTracking()
{
if (Vessel != null)
{
if (Vessel.DiscoveryInfo.HaveKnowledgeAbout(DiscoveryLevels.Appearance))
{
KSP.UI.Screens.SpaceTracking.StopTrackingObject(Vessel);
}
}
}

private StringValue GetSizeClass()
{
if (Vessel.vesselType == VesselType.SpaceObject)
{
if (Vessel.DiscoveryInfo.HaveKnowledgeAbout(DiscoveryLevels.Presence))
{
return Vessel.DiscoveryInfo.objectSize.ToString();
}
else
{
return "UNKNOWN";
}
}
else
{
return Vessel.vesselType.ToString();
}
}

public override ISuffixResult GetSuffix(string suffixName, bool failOkay = false)
{
// Most suffixes are handled by the newer AddSuffix system, except for the
Expand Down

0 comments on commit 9171246

Please sign in to comment.