Skip to content

Commit

Permalink
Rewrite NetworkNode
Browse files Browse the repository at this point in the history
Introducing a composition pattern to NetworkNodes. This makes creating new network nodes significantly easier, as well as improving code readability and maintainability.
  • Loading branch information
warent committed Dec 29, 2024
1 parent 5056b21 commit 2f077d1
Show file tree
Hide file tree
Showing 15 changed files with 715 additions and 690 deletions.
2 changes: 1 addition & 1 deletion addons/HLNC/Addons/NetworkTransform/NetworkTransform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public override void _PhysicsProcess(double delta)
{
return;
}
if (!IsWorldReady) return;
if (!Network.IsWorldReady) return;
TargetNode.Position = NetPosition;
TargetNode.Rotation = NetRotation;
}
Expand Down
4 changes: 2 additions & 2 deletions addons/HLNC/Addons/NetworkVisibility/NetworkVisibility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ public partial class NetworkVisibility : Node3D
/// <inheritdoc/>
public override void _EnterTree()
{
var netParent = GetParentOrNull<NetworkNode3D>();
if (netParent.IsCurrentOwner && NetworkRunner.Instance.IsClient)
var netParent = GetParentOrNull<INetworkNode>();
if (netParent.Network.IsCurrentOwner && NetworkRunner.Instance.IsClient)
{
return;
}
Expand Down
9 changes: 9 additions & 0 deletions addons/HLNC/Core/INetworkNode.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using HLNC.Serialization.Serializers;

namespace HLNC {
public interface INetworkNode {
public NetworkController Network { get; }
public IStateSerializer[] Serializers { get; }
public void SetupSerializers();
}
}
Loading

0 comments on commit 2f077d1

Please sign in to comment.