Skip to content

Commit

Permalink
Add functionality to delete stock CommNetVessel instances from CommNe…
Browse files Browse the repository at this point in the history
…t network
  • Loading branch information
KSP-TaxiService committed Mar 17, 2020
1 parent b729376 commit 253a54a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/CommNetConstellation/CommNetLayer/CNCCommNetVessel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public enum FrequencyListOperation
public bool IsCommandable = true;

/// <summary>
/// Retrieve the CNC data from the vessel
/// Retrieve the CNC data from the vessel, in addition of stock network joining
/// </summary>
protected override void OnNetworkInitialized()
{
Expand Down Expand Up @@ -140,6 +140,26 @@ protected override void OnNetworkInitialized()
}
}

protected override void OnAwake()
{
base.OnAwake();
}

protected override void OnStart()
{
if (this.vessel != null)
{
//if this connection is stock, replace it with this custom connection
if (this.vessel.connection != null && this.vessel.connection is CommNetVessel && CommNetNetwork.Initialized)
{
CommNetNetwork.Remove(this.vessel.connection.Comm); //delete stock node from commnet network
//UnityEngine.Object.DestroyObject(this.vessel.connection); // don't do this. there are still action-call leftovers of stock CommNetVessel
this.vessel.connection = this;
}
}
base.OnStart();
}

protected override void OnDestroy()
{
base.OnDestroy();
Expand Down
5 changes: 5 additions & 0 deletions src/CommNetConstellation/CommNetLayer/CNCCommNetwork.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ protected override bool SetNodeConnection(CommNode a, CommNode b)
{
this.Disconnect(a, b, true);
}
// disconnect connection between "itself"
else if (AreSame(a, b))
{
this.Disconnect(a, b, true);
}
else
{
//each CommNode has at least some frequencies?
Expand Down

0 comments on commit 253a54a

Please sign in to comment.