Table of Contents

Class TradeSystem

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

The broadcast handlers: invitation, offers, currency, acceptance, cancellation.

[CreateAssetMenu(fileName = "TradeSystem", menuName = "FishMMO/Server/SceneServer/Trade System", order = 1)]
[RequiresDataContainer(typeof(TradeSystemMainThreadQueueData))]
[RequiresDataContainer(typeof(TradeSystemRuntimeData))]
[RequiresDataContainer(typeof(AsyncWorkerData))]
public class TradeSystem : ServerBehaviour, IServerBehaviour<INetworkManagerWrapper, ServerManager, NetworkConnection, IServerBehaviour>, IServerComponent<INetworkManagerWrapper, ServerManager, NetworkConnection, IServerBehaviour>, ITradeSystem, IServerBehaviour, IServerComponent
Inheritance
Object
ScriptableObject
TradeSystem
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

Remarks

Every handler follows the same shape: ingress guard, resolve and validate the sender through CanAct(IPlayerCharacter), find the session they are a party to, ask TradeSession whether the change is allowed, apply the side effect (a slot lock, an unlock), then send both parties the new table. A refused change answers the sender alone with a TradeRefusedBroadcast AND the current table, so a client that acted on a stale view is corrected and told why rather than left waiting.

Properties

MaxTradeDistance

The range, in metres, beyond which an open trade is closed by the server.

public float MaxTradeDistance { get; }

Property Value

float

OpenSessionCount

Number of open sessions, for diagnostics.

public int OpenSessionCount { get; }

Property Value

int

Methods

CloseTradeFor(IPlayerCharacter, TradeCloseReason)

Closes whatever trade the character is in, telling both parties why.

public bool CloseTradeFor(IPlayerCharacter character, TradeCloseReason reason)

Parameters

character IPlayerCharacter
reason TradeCloseReason

Returns

bool

True when a session was closed.

InitializeOnce()

Called once to initialize the behaviour. Must be implemented by derived classes.

public override ServerComponentInitializationStatus InitializeOnce()

Returns

ServerComponentInitializationStatus

Remarks

Behaviours that need to await I/O (database registration, for example) must override InitializeOnceAsync(CancellationToken) instead of blocking in here. The Unity main thread must never block on I/O: it is the thread that drains async continuations, so blocking it can deadlock startup before the transport ever binds.

IsTrading(long)

True while the character has a trade window open with someone.

public bool IsTrading(long characterID)

Parameters

characterID long

Returns

bool

OnDeinitialize()

Called when the behaviour is being deinitialized. Must be implemented by derived classes.

public override void OnDeinitialize()

OnUpdate(float)

Override this method in derived classes that need per-frame updates. Guaranteed to run only when the behaviour is initialized and Server is non-null.

protected override void OnUpdate(float deltaTime)

Parameters

deltaTime float

Time elapsed since last frame.