Table of Contents

Class CharacterInventorySystem

Namespace
FishMMO.Server.Implementation.World.SceneServer
Assembly
FishMMO.Server.dll

Manages player character inventory, equipment, and bank operations with validation and database persistence.

[CreateAssetMenu(fileName = "CharacterInventorySystem", menuName = "FishMMO/Server/SceneServer/Character Inventory System", order = 1)]
[RequiresDataContainer(typeof(CharacterInventorySystemRuntimeData))]
[RequiresDataContainer(typeof(CharacterInventorySystemMainThreadQueueData))]
[RequiresDataContainer(typeof(AsyncWorkerData))]
public class CharacterInventorySystem : ServerBehaviour, IServerBehaviour<INetworkManagerWrapper, ServerManager, NetworkConnection, IServerBehaviour>, IServerComponent<INetworkManagerWrapper, ServerManager, NetworkConnection, IServerBehaviour>, ICharacterInventorySystem, IServerBehaviour, IServerComponent
Inheritance
Object
ScriptableObject
CharacterInventorySystem
Implements
IServerBehaviour<INetworkManagerWrapper, ServerManager, NetworkConnection, IServerBehaviour>
IServerComponent<INetworkManagerWrapper, ServerManager, NetworkConnection, IServerBehaviour>
Inherited Members
ScriptableObject.SetDirty()
ScriptableObject.CreateInstance<T>()
Object.GetEntityId()
Object.GetInstanceID()
Object.GetHashCode()
Object.InstantiateAsync<T>(T)
Object.InstantiateAsync<T>(T, Transform)
Object.InstantiateAsync<T>(T, Vector3, Quaternion)
Object.InstantiateAsync<T>(T, Transform, Vector3, Quaternion)
Object.Instantiate(Object, Vector3, Quaternion)
Object.Instantiate(Object, Vector3, Quaternion, Transform)
Object.Instantiate(Object)
Object.Instantiate(Object, Scene)
Object.Instantiate<T>(T, InstantiateParameters)
Object.Instantiate<T>(T, Vector3, Quaternion, InstantiateParameters)
Object.Instantiate(Object, Transform)
Object.Instantiate<T>(T)
Object.Instantiate<T>(T, Vector3, Quaternion)
Object.Instantiate<T>(T, Vector3, Quaternion, Transform)
Object.Instantiate<T>(T, Transform)
Object.Destroy(Object)
Object.DestroyImmediate(Object)
Object.DontDestroyOnLoad(Object)
Object.DestroyObject(Object)
Object.FindObjectsOfType<T>()
Object.FindObjectsByType<T>(FindObjectsSortMode)
Object.FindObjectsByType<T>(FindObjectsInactive, FindObjectsSortMode)
Object.FindObjectOfType<T>()
Object.FindFirstObjectByType<T>()
Object.FindAnyObjectByType<T>()
Object.FindFirstObjectByType<T>(FindObjectsInactive)
Object.FindAnyObjectByType<T>(FindObjectsInactive)
Object.FindObjectsByType<T>()
Object.FindObjectsByType<T>(FindObjectsInactive)
Object.ToString()
Object.name
Object.hideFlags

Methods

InitializeOnce()

Initializes the character inventory system, registering broadcast handlers for inventory, equipment, and bank actions.

public override ServerComponentInitializationStatus InitializeOnce()

Returns

ServerComponentInitializationStatus

OnDeinitialize()

Cleans up the character inventory system, unregistering broadcast handlers for inventory, equipment, and bank actions.

public override void OnDeinitialize()

OnUpdate(float)

Sweeps stale ingress guard entries and drives the periodic item snapshot.

protected override void OnUpdate(float deltaTime)

Parameters

deltaTime float

SwapContainerItems(IItemContainer, IItemContainer, int, int, out List<Item>, out List<long>, out List<Item>)

Swaps items between two containers and collects affected items and deleted slots.

public bool SwapContainerItems(IItemContainer from, IItemContainer to, int fromIndex, int toIndex, out List<Item> affectedFromItems, out List<long> deletedFromSlots, out List<Item> affectedToItems)

Parameters

from IItemContainer

Source item container.

to IItemContainer

Target item container.

fromIndex int

Source slot index.

toIndex int

Target slot index.

affectedFromItems List<Item>

Out: items placed into the source container.

deletedFromSlots List<long>

Out: slot indices vacated in the source container.

affectedToItems List<Item>

Out: items placed into the destination container.

Returns

bool

True if swap succeeded, false otherwise.

SwapContainerItems(IItemContainer, int, int, out List<Item>)

Swaps two items within the same container and collects the affected items.

public bool SwapContainerItems(IItemContainer container, int fromIndex, int toIndex, out List<Item> affectedItems)

Parameters

container IItemContainer

Item container to swap items in.

fromIndex int

Source slot index.

toIndex int

Target slot index.

affectedItems List<Item>

Out: list of items whose slots changed.

Returns

bool

True if swap succeeded, false otherwise.

SwapContainerItems(IItemContainer, int, int, out List<Item>, out int)

Swaps two items within the same container, reporting both the affected items and any slot the swap left empty.

public bool SwapContainerItems(IItemContainer container, int fromIndex, int toIndex, out List<Item> affectedItems, out int vacatedSlot)

Parameters

container IItemContainer

Item container to swap items in.

fromIndex int

Source slot index.

toIndex int

Target slot index.

affectedItems List<Item>

Out: list of items whose slots changed.

vacatedSlot int

Out: slot the swap emptied, or -1 when both slots stay filled.

Returns

bool

True if swap succeeded, false otherwise.

Remarks

The vacated slot is the whole reason this overload exists. Item rows are keyed (character_id, slot), so a move onto an EMPTY slot writes the item at its new index and leaves the row at the old index untouched — the same item persisted twice. Only the write side was emitted here before, because affectedItems collects non-null items and a move-to-empty produces exactly one of them, which reads like a complete description of the change and is not.

The 60-second snapshot prunes the stale row, so this never survived a clean shutdown — but "duplicated until the next snapshot, permanently if the scene server dies first" is not a guarantee worth relying on when the delete costs one list entry.