-
Notifications
You must be signed in to change notification settings - Fork 36
2.2.4 ICLSPart
ICLSPart
public interface ICLSPart
{
ICLSSpace Space { get; }
bool Docked { get; }
List<ICLSKerbal> Crew { get; }
Part Part { get; }
void Highlight(bool val, bool force);
bool Habitable { get; }
bool Navigable { get; }
}
The ICLSPart object is essentially a wrapper for the Part object. It adds several properties and 1 method to allow CLS to provide a wealth of information.
Properties
- Space This property returns the parent ICLSpace object.
- Docked This property returns the Docked state of an ICLSPart
- Crew This property returns a list of ICLSKerbal Objects contained within the ICLSPart object.
- Part This property returns the Part object that this object wraps.
- Habitable This property returns the Habitalble state of the ICLSPart. True = habitable.
- Navigable This property returns the Navigable (passable) state of the ICLSPart. True = Navigable/passable.
Methods
- Highlight This method provides a means to enable or disable highlighting of the ICLSPart object. This does not allow changing the highlight color, as the color is determined by other factors, such as passibility, part type, etc. Passing a Boolean value of true enables highlighting. Passing a bool false disable highlighting. This method need only be fire once, as it will set a flag on the associated parts to ensure the part stays highlighted until commanded to turn off.
This Highlight method differs from the same method on the other objects. This is because of the way that CLS manages highlighting. Since multiple mods may use the highlighting scheme, highlighting cascades down from the top level. When then the vessel or space is highlighted, all parts for the vessel or space get highlighted. However, since highlighting control at the part level is desirable, an additional flag, Force is available. To better understand the use of Force, let's look at the internal CLSPart Highlight method in detail:
public void Highlight(bool val, bool force = false)
{
// Set the variable to mark if this part is SUPPOSED to be hightlighted or not.
if (val && (!this.highlighted || force))
{
this.SetHighlighting();
this.highlighted = val;
this.part.highlightType = Part.HighlightType.AlwaysOn;
}
else
{
if(!val && (this.highlighted || force))
{
this.highlighted = val;
this.part.SetHighlight(false, false);
part.SetHighlightDefault();
this.part.highlightType = Part.HighlightType.OnMouseOver;
}
}
}
By default, when a part is highlighted it sets an internal flag "Highlighted" to true. This flag ensures the we only set the part's highlighting state once and we don't continuously set it (every frame for example) Now when we then set the part to false, it will also change the Highlighted flag to false.
Once this flag is set, it will then only allow changes to occur and not repeat the same action over and over. By adding the Force Flag, we can force the action to occur, overriding the highlighted flag. This is useful when we externally wish to make changes to the highlight color of a given part via another Mod and then want CLS to refresh the original at a later time. This provides flexibility at the part level, and allows the use of the Vessel or Space level highlighting, without altering part level settings.