Skip to content

Commit

Permalink
Refactor to "World" system. Implement "Interest"
Browse files Browse the repository at this point in the history
  • Loading branch information
warent committed Jul 28, 2024
1 parent 56df559 commit 241aaa4
Show file tree
Hide file tree
Showing 18 changed files with 1,235 additions and 911 deletions.
1 change: 1 addition & 0 deletions addons/HLNC/HLNC.props
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<Project>
<ItemGroup>
<PackageReference Include="MongoDB.Bson" Version="2.28.0" />
<PackageReference Include="Fody" Version="6.8.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
9 changes: 1 addition & 8 deletions addons/HLNC/IBlastoffDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@ public interface IBlastoffServerDriver {
/// <summary>
/// Validate whether the user is allowed to join the desired zone (i.e. server instance) or not.
/// </summary>
/// <param name="zoneId">The zoneId being requested by the client. This is generated either statically when the Blastoff server is initially spun up, or dynamically when the Blastoff server generates new instances.</param>
/// <param name="token">The token sent from the client. This may be a JWT, HMAC, or anything else desired for authentication.</param>
/// <param name="redirect">An optional output parameter to ask Blastoff connect the client to. Only used if the user is not valid and false is returned.</param>
/// <returns>Return true to allow the user to join. Return false to reject.</returns>
public bool BlastoffValidatePeer(Guid zoneId, string token, out Guid redirect);
public bool BlastoffValidatePeer(string token, out Guid redirect);

}

Expand All @@ -32,11 +31,5 @@ public interface IBlastoffClientDriver {
/// </summary>
/// <returns>The user's authentication token which is validated in <see cref="IBlastoffServerDriver.BlastoffValidatePeer(Guid, string, out Guid)"/></returns>
public string BlastoffGetToken();

/// <summary>
/// NetworkRunner uses this to tell the server which zone the client is trying to connect to.
/// </summary>
/// <returns>The Zone ID, utilized in the validation process of <see cref="IBlastoffServerDriver.BlastoffValidatePeer(Guid, string, out Guid)"/></returns>
public Guid BlastoffGetZoneId();
}
}
10 changes: 0 additions & 10 deletions addons/HLNC/INetworkInputHandler.cs

This file was deleted.

264 changes: 179 additions & 85 deletions addons/HLNC/NetworkNode3D.cs

Large diffs are not rendered by default.

43 changes: 40 additions & 3 deletions addons/HLNC/NetworkNodeWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ public NetworkNodeWrapper(Node node) {
"NetworkId",
"NetworkParentId",
"DynamicSpawn",
"CurrentWorld",
"InputBuffer",
"InterestLayers"
};
foreach (var prop in node.GetPropertyList()) {
var pascalName = ToPascalCase(prop["name"].AsString());
Expand Down Expand Up @@ -165,7 +168,17 @@ internal set {
}
}

public NetworkNodeWrapper NetworkParent => NetworkRunner.Instance.GetFromNetworkId(NetworkParentId);
public WorldRunner CurrentWorld {
get {
return Get("CurrentWorld").As<WorldRunner>();
}

internal set {
Set("CurrentWorld", value);
}
}

public NetworkNodeWrapper NetworkParent => CurrentWorld.GetNodeFromNetworkId(NetworkParentId);

// TODO: Handle null?
internal byte NetworkSceneId => NetworkScenesRegister.SCENES_PACK[Node.SceneFilePath];
Expand All @@ -190,6 +203,26 @@ internal set {
}
}

public Godot.Collections.Dictionary<byte, Variant> InputBuffer {
get {
return Get("InputBuffer").As<Godot.Collections.Dictionary<byte, Variant>>();
}

internal set {
Set("InputBuffer", value);
}
}

public Godot.Collections.Dictionary<string, long> InterestLayers {
get {
return Get("InterestLayers").As<Godot.Collections.Dictionary<string, long>>();
}

internal set {
Set("InterestLayers", value);
}
}

public IStateSerailizer[] Serializers {
get {
// TODO: Support serializers across other languages / node types
Expand All @@ -200,14 +233,18 @@ public IStateSerailizer[] Serializers {
}
}

internal void _NetworkPrepare() {
Call("_NetworkPrepare");
internal void _NetworkPrepare(WorldRunner worldRunner) {
Call("_NetworkPrepare", [worldRunner]);
}

public void _NetworkProcess(Tick tick) {
Call("_NetworkProcess", tick);
}

public void SetPeerInterest(string peerId, long interestLayers, bool recurse = true) {
Call("SetPeerInterest", peerId, interestLayers, recurse);
}

public List<NetworkNodeWrapper> StaticNetworkChildren {
get {
return NetworkScenesRegister.STATIC_NETWORK_NODE_PATHS[Node.SceneFilePath].Aggregate(new List<NetworkNodeWrapper>(), (acc, path) => {
Expand Down
80 changes: 0 additions & 80 deletions addons/HLNC/NetworkPeerManager/IPeerController.cs

This file was deleted.

Loading

0 comments on commit 241aaa4

Please sign in to comment.