Class WorldItem
Represents an item that exists in the world and can be interacted with or picked up by players.
public class WorldItem : Interactable, ISpawnable, IWorldItem, IInteractable, ISceneObject
- Inheritance
-
ObjectComponentBehaviourMonoBehaviourNetworkBehaviourWorldItem
- Implements
- Inherited Members
-
NetworkBehaviour.IsSpawnedNetworkBehaviour.ComponentIndexNetworkBehaviour.NetworkObjectNetworkBehaviour.MAXIMUM_NETWORKBEHAVIOURSNetworkBehaviour.UNSET_NETWORKBEHAVIOUR_IDNetworkBehaviour.ToString()NetworkBehaviour.Reset()NetworkBehaviour.OnValidate()NetworkBehaviour.IsBehaviourReconcilingNetworkBehaviour.ClearReplicateCache()NetworkBehaviour.CreateReconcile()NetworkBehaviour.Reconcile_Reader<T>(PooledReader, ref T)NetworkBehaviour.OnStartServerCalledNetworkBehaviour.OnStartClientCalledNetworkBehaviour.OnStartNetwork()NetworkBehaviour.OnStopNetwork()NetworkBehaviour.OnStopServer()NetworkBehaviour.OnOwnershipServer(NetworkConnection)NetworkBehaviour.OnSpawnServer(NetworkConnection)NetworkBehaviour.OnDespawnServer(NetworkConnection)NetworkBehaviour.OnStartClient()NetworkBehaviour.OnStopClient()NetworkBehaviour.OnOwnershipClient(NetworkConnection)NetworkBehaviour.ClearBuffedRpcs()NetworkBehaviour.ExcludeOwnerFromUnbufferedObserversRpcsNetworkBehaviour.IsClientOnlyNetworkBehaviour.IsServerOnlyNetworkBehaviour.IsHostNetworkBehaviour.IsClientNetworkBehaviour.IsServerNetworkBehaviour.IsDeinitializingNetworkBehaviour.NetworkManagerNetworkBehaviour.ServerManagerNetworkBehaviour.ClientManagerNetworkBehaviour.ObserverManagerNetworkBehaviour.TransportManagerNetworkBehaviour.TimeManagerNetworkBehaviour.SceneManagerNetworkBehaviour.PredictionManagerNetworkBehaviour.RollbackManagerNetworkBehaviour.NetworkObserverNetworkBehaviour.IsClientInitializedNetworkBehaviour.IsClientStartedNetworkBehaviour.IsClientOnlyInitializedNetworkBehaviour.IsClientOnlyStartedNetworkBehaviour.IsServerInitializedNetworkBehaviour.IsServerStartedNetworkBehaviour.IsServerOnlyInitializedNetworkBehaviour.IsServerOnlyStartedNetworkBehaviour.IsHostInitializedNetworkBehaviour.IsHostStartedNetworkBehaviour.IsOfflineNetworkBehaviour.IsNetworkedNetworkBehaviour.GetIsNetworked()NetworkBehaviour.IsManagerReconcilingNetworkBehaviour.ObserversNetworkBehaviour.IsOwnerNetworkBehaviour.IsControllerNetworkBehaviour.HasAuthorityNetworkBehaviour.OwnerNetworkBehaviour.OwnerIdNetworkBehaviour.ObjectIdNetworkBehaviour.LocalConnectionNetworkBehaviour.OwnerMatches(NetworkConnection)NetworkBehaviour.Despawn(GameObject, DespawnType?)NetworkBehaviour.Despawn(NetworkObject, DespawnType?)NetworkBehaviour.Despawn(DespawnType?)NetworkBehaviour.Spawn(GameObject, NetworkConnection, Scene)NetworkBehaviour.Spawn(NetworkObject, NetworkConnection, Scene)NetworkBehaviour.RemoveOwnership()NetworkBehaviour.GiveOwnership(NetworkConnection)NetworkBehaviour.GetInstance<T>()NetworkBehaviour.TryRegisterInstance<T>(T)NetworkBehaviour.UnregisterInstance<T>()NetworkBehaviour.CanLog(LoggingType)MonoBehaviour.IsInvoking()MonoBehaviour.CancelInvoke()MonoBehaviour.StopCoroutine(Coroutine)MonoBehaviour.StopAllCoroutines()MonoBehaviour.destroyCancellationTokenMonoBehaviour.useGUILayoutMonoBehaviour.didStartMonoBehaviour.didAwakeMonoBehaviour.runInEditModeBehaviour.enabledBehaviour.isActiveAndEnabledComponent.GetComponent<T>()Component.TryGetComponent<T>(out T)Component.GetComponentInChildren<T>()Component.GetComponentsInChildren<T>()Component.GetComponentInParent<T>()Component.GetComponentsInParent<T>()Component.GetComponents<T>()Component.GetComponentIndex()Component.CompareTag(TagHandle)Component.transformComponent.transformHandleComponent.gameObjectComponent.tagObject.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.nameObject.hideFlags
Fields
AchievementTemplateID
Achievement template ID to increment when a player picks up this world item.
[TemplateReference(typeof(AchievementTemplate))]
public int AchievementTemplateID
Field Value
Amount
public uint Amount
Field Value
Seed
The attribute-generation seed the granted Item is built from.
public int Seed
Field Value
Remarks
Rolled by ItemSpawnableSettings at spawn so this drop has an identity of its own. Without one, pickup built the item through the template-only constructor, whose seed derives from a database id that is still zero — so every generated ground drop of a template rolled IDENTICAL attributes from RNG(0), and rolled a DIFFERENT set after a relog once a real row id existed to derive from. Zero means "no seed was rolled" and pickup keeps the old derive-from-id behavior.
Properties
Template
The item template defining the type of item this world object represents.
public BaseItemTemplate Template { get; set; }
Property Value
Title
The display title for this interactable, shown in the UI.
public override string Title { get; }
Property Value
Methods
ReadPayload(NetworkConnection, Reader)
Reads network payload data for this interactable, setting its ID and registering it in the scene.
public override void ReadPayload(NetworkConnection connection, Reader reader)
Parameters
connectionNetworkConnectionThe network connection.
readerReaderThe network reader.
ResetState(bool)
Clears the rolled stack and seed when this instance returns to the pool.
public override void ResetState(bool asServer)
Parameters
asServerbool
Remarks
Per-life state. A pooled world item that is not reset comes back out of the pool still carrying the amount and seed its previous life was spawned with, and ItemSpawnableSettings only overwrites them when the object is respawned through a spawner — an item dropped by script would keep the old number, and a stale seed would silently hand a new drop the previous drop's attribute roll.
The template is deliberately left alone: templateID is a serialized field a
designer may have authored on the prefab, and zeroing it here would strip that on the
first despawn. Amount is the half that is always injected at spawn.
WritePayload(NetworkConnection, Writer)
Writes the scene object ID, then the template, stack size and generation seed.
public override void WritePayload(NetworkConnection connection, Writer writer)
Parameters
connectionNetworkConnectionwriterWriter
Remarks
WritePayload(NetworkConnection, Writer) is what sends the scene object ID, and this
override used to skip it. The consequence was total: a client's copy of a world item
kept ID 0 and was never entered into Objects, so the interact
key sent InteractableID = 0 — an ID the server never issues, because scene object
IDs count down from zero and are always negative. Every ground drop in the game was
therefore impossible to pick up, and the refusal path is silent, so it looked like a
dead keypress rather than a bug.