sackInventory

GC2 Inventory Network Integration

Server-authoritative inventory networking for Game Creator 2 Inventory module. Designed for competitive multiplayer with cheat prevention.

Features

Server Authority

  • Content Operations: Add, Remove, Move, Use, Drop items validated server-side

  • Equipment System: Equip/Unequip with server validation

  • Socket Operations: Attach/Detach items from sockets

  • Wealth Management: Currency Add/Subtract/Set with server authority

  • Merchant Transactions: Buy/Sell validated server-side

  • Crafting Operations: Craft/Dismantle with ingredient verification

  • Transfer System: Bag-to-bag transfers with validation

Anti-Cheat Protection

  • Item duplication prevention

  • Gold/currency exploit prevention

  • Illegal crafting blocked

  • Equipment slot validation

  • Socket compatibility checks

  • Rate limiting per client

Architecture

Component Placement

  • Add exactly one NetworkInventoryManager to a persistent scene object (network bootstrap/root).

  • Add one NetworkInventoryController on each networked player/NPC GameObject that owns a GC2 Bag.

  • The controller should live on the same GameObject as Bag and NetworkCharacter.

  • Register controllers with the manager using NetworkCharacter.NetworkId when the entity is spawned/ready.

Quick Start

1. Setup Manager

Add NetworkInventoryManager to a persistent scene object:

2. Setup Per-Bag Controller

Add NetworkInventoryController alongside each Bag component:

3. Client Operations

Instead of calling Bag methods directly, use controller requests:

Operations Reference

Content Operations

Operation
Client Request
Server Validates

Add

RequestAddItem(hash, count)

Space, stacking rules

Remove

RequestRemoveItem(runtimeId, count)

Item exists, count valid

Move

RequestMoveItem(from, to)

Valid indices, space

Use

RequestUseItem(runtimeId)

Item exists, usable

Drop

RequestDropItem(runtimeId, count, pos)

Item exists, count valid

Equipment Operations

Operation
Client Request
Server Validates

Equip

RequestEquip(runtimeId)

Item exists, compatible

Unequip

RequestUnequip(runtimeId)

Item equipped

UnequipFromIndex

RequestUnequipFromIndex(index)

Index valid, item equipped

Socket Operations

Operation
Client Request
Server Validates

Attach

RequestAttachToSocket(parentId, childId, slot)

Items exist, compatible

Detach

RequestDetachFromSocket(parentId, childId, slot)

Items attached

Wealth Operations

Operation
Client Request
Server Validates

Add Currency

RequestWealthModify(Add, currency, amount)

Server-only typically

Subtract

RequestWealthModify(Subtract, currency, amount)

Sufficient funds

Set

RequestWealthModify(Set, currency, amount)

Server-only typically

Network Types

Core Structures

Request/Response Pattern

All operations follow request-response pattern:

Custom Validation

Extend validation with custom logic:

Transport Integration Examples

Netcode for GameObjects (optional example)

This sample follows NGO 2.10 unified RPC API ([Rpc], RpcParams, RpcTarget).

FishNet

Best Practices

DO:

  • ✅ Always use request methods for player inventory changes

  • ✅ Handle rejection callbacks gracefully

  • ✅ Implement custom validators for game-specific rules

  • ✅ Use snapshots for late-joining players

  • ✅ Log rejections for debugging potential exploits

DON'T:

  • ❌ Call Bag methods directly on client for authoritative data

  • ❌ Trust client-reported item counts

  • ❌ Skip server validation for "trusted" operations

  • ❌ Broadcast sensitive inventory data to non-owners

Events

The controller fires events for UI updates:

Rejection Reasons

Reason
Description

None

No rejection

BagNotFound

Target bag doesn't exist

ItemNotFound

Referenced item not found

BagFull

No space in inventory

InsufficientFunds

Not enough currency

InsufficientAmount

Not enough items

ConditionFailed

Custom condition failed

InvalidOperation

Operation not supported

NotOwner

Client doesn't own this bag

OutOfRange

Target too far away

Cooldown

Operation on cooldown

EquipmentSlotFull

Equipment slot occupied

IncompatibleSocket

Socket doesn't accept item

Files

File
Purpose

NetworkInventoryTypes.cs

All network data structures

NetworkInventoryController.cs

Per-bag inventory network management

NetworkInventoryManager.cs

Global singleton, transport routing

Dependencies

  • Game Creator 2 Core

  • Game Creator 2 Inventory Module

  • Unity 2021.3+

Define Symbol

This module requires GC2_INVENTORY define symbol, which is automatically set via Version Defines when com.gamecreator.inventory package is present.

Last updated