Skip to content

Server Authoritative Loot Functionality and Additions. - #4

Open
dragonzero39 wants to merge 3 commits into
crizzler:mainfrom
dragonzero39:main
Open

Server Authoritative Loot Functionality and Additions. #4
dragonzero39 wants to merge 3 commits into
crizzler:mainfrom
dragonzero39:main

Conversation

@dragonzero39

Copy link
Copy Markdown

Server-Authoritative contributions.
These items should facilitate Server-Authoritative functionality in GC2 Arawn Extensions. Tested and utilized in PurrNet with Edgegap.

Primary changes are

  1. NetworkWorldObject - Facilitates server control of the existence of an item that can be interacted with.
  2. NetworkLootContainer - “This object is allowed to generate loot, using this server-side loot table.”
  3. InstructionNetworkPickupRequest - Submits server request to pick up an item and move it to a GC2 Inventory Bag
  4. InstructionNetworkLootRequest - “Player interacted with this lootable object, ask the server to generate loot.”

This is my first pull request to a real repo. Feedback appreciated. Much of what I accomplish is via GPT.

These items should facilitate Server-Authoritative functionality in GC2 Arawn Extensions. Tested and utilized in PurrNet with Edgegap.

Primary changes are 

1) NetworkWorldObject - Facilitates server control of the existence of an item that can be interacted with.
2) NetworkLootContainer - “This object is allowed to generate loot, using this server-side loot table.” 
3) InstructionNetworkPickupRequest - Submits server request to pick up an item and move it to a GC2 Inventory Bag
4) InstructionNetworkLootRequest - “Player interacted with this lootable object, ask the server to generate loot.”  

This is my first pull request to a real repo. Feedback appreciated. Much of what I accomplish is via GPT.
…-Auth-Patch

Server-Authoritative contributions.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d0905cfe46

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread NetworkInventoryController.cs Outdated
using System.Threading.Tasks;
using UnityEngine;
using GameCreator.Runtime.Common;
using GameCreator.Runtime.Inventory;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Place the new sources in the Inventory assembly

When GC2_INVENTORY is enabled by Editor/DefineSymbols/GC2NetworkingDefineSymbols.cs, these root-level scripts compile into Arawn.GameCreator2.Networking.asmdef, which does not reference GameCreator.Runtime.Inventory; this using therefore fails compilation, and the files also redeclare types already present in the Inventory assembly. These changes need to be merged into the existing Inventory/ sources rather than added beside the root asmdef.

Useful? React with 👍 / 👎.

Comment thread NetworkInventoryManager.cs Outdated
Comment on lines +354 to +358
public void SendLootRequest(NetworkLootRequest request)
{
Debug.Log(
$"[NetworkInventoryLootDebug][Manager] send loot request req={request.RequestId} actor={request.ActorNetworkId} container={request.ContainerBagNetworkId}");
OnSendLootRequest?.Invoke(request);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Wire loot requests into the transport

For a non-host client, RequestLootGeneration reaches this event and stops: the inspected PurrNet bridge bind/unbind sections and packet handlers wire pickup, transfer, and the other inventory operations, but contain no OnSendLootRequest, OnSendLootResponse, or loot packet handling. Consequently the server never receives a remote client's loot request and the new instruction only works on the server/host path.

Useful? React with 👍 / 👎.

Comment thread NetworkInventoryManager.cs Outdated
return;
}

if (!ValidateTargetOwnership(senderClientId, request.ActorNetworkId, request.ActorNetworkId, nameof(NetworkLootRequest)))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Validate access to the requested loot container

For any client that owns its actor, this validates the actor bag against itself rather than validating access to ContainerBagNetworkId; ProcessLootRequest then runs the container's loot table without any actor-to-container distance or access check. A client that knows a world-container ID can therefore remotely roll a generate-once container before reaching it, so the server must validate proximity/access to the actual container before generating loot.

Useful? React with 👍 / 👎.

return true;
}

worldObject.MarkPickedUp();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Replicate world-object consumption to clients

On a dedicated server this only disables or destroys the server's local scene object. The new protocol has no consumed-object broadcast, and ReceivePickupResponse merely logs the response, so requesting and observing clients retain an enabled copy of the pickup and can continue interacting with it after the authoritative object has been consumed. Broadcast the consumed state (or use the existing pickup-state replication path) so every client removes the object.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner

Hi @dragonzero39 — first of all, thank you for taking the time to build this and for opening your first public pull request. The motivation to add server-authoritative loot is absolutely appreciated, and running the GC2 LootTable on the server is a useful direction for the integration.

Please do not be discouraged by the automated P1 labels. They describe how serious a problem would be if the current code were merged unchanged; they are not a judgment on your effort or the value of the idea. Finding integration issues is exactly what review is for.

You do not need to close this PR or create another one. Any additional commits you push to the same dragonzero39:main branch will automatically update PR #4.

The easiest path forward is to make this a smaller, focused server-authoritative loot contribution:

  1. Remove the 12 newly added .cs files from the repository root. The public repository root maps to Assets/Arawn/NetworkingLayerForGC2, and Inventory code must live under Inventory/. The root files currently compile into the wrong assembly and duplicate existing Inventory classes.
  2. Update your fork from the latest crizzler/main before reapplying the feature. Please modify the existing Authority v3 files rather than copying older versions of complete controller/manager files into the PR.
  3. Keep the genuinely new loot pieces under Inventory/:
    • Inventory/NetworkLootContainer.cs
    • Inventory/InstructionNetworkLootRequest.cs
    • their Unity .meta files
    • small, focused edits to the existing Inventory/NetworkInventoryTypes.cs, NetworkInventoryManager.cs, and controller partial files
  4. Leave out the parallel NetworkWorldObject, InstructionNetworkPickupRequest, and NetworkInventoryController.WorldObjectPickup path for now. The current project already has NetworkInventoryPickupSource, authoritative pickup registration, one-time consumption, range/line-of-sight validation, runtime PurrNet pickup identities, and replicated pickup state. If your use case needs something that system does not cover, describe the missing behavior here and we can work out how to extend the existing path without creating a second competing pickup system.
  5. Wire the new loot operation through PurrNet. A remote client currently reaches OnSendLootRequest and stops. The request/response packets need to be added to Runtime/Transport/PurrNet/Inventory/PurrNetInventoryMessages.cs, with bind/unbind, send, receive, and server-dispatch handling in PurrNetInventoryTransportBridge.cs. Inventory messages should use the existing ReliableOrdered path.
  6. Validate access on the server before running the loot table. Owning the actor is not enough: the server should verify that the actor is allowed to use the requested container, at minimum through distance/access validation (ideally with a project validator extension point). A client must not be able to generate any container merely by knowing its network ID.
  7. Test the important cases: host request, remote-client request, out-of-range rejection, generate-once behavior, duplicate requests, two clients racing for the same container, and snapshot/reconnect behavior.

A good first revision does not need to solve every possible world-object interaction. A clean, tested loot-container addition on top of the current Inventory Authority v3 code would already be a meaningful contribution.

When you have pushed the next commits, leave a short comment such as “Ready for another review” and we will take another look. If any Git/GitHub step or the folder mapping is unclear, ask here—we are happy to guide you through it. Your authorship will remain attached to the contribution when a corrected version is merged.

@crizzler crizzler self-assigned this Jul 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants