Skip to content

Commit

Permalink
onenable add container
Browse files Browse the repository at this point in the history
  • Loading branch information
stilnat committed Jul 22, 2023
1 parent 30ba68d commit 11ad28a
Showing 1 changed file with 19 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,10 @@ public class AttachedContainer : NetworkActor

public event AttachedContainerHandler OnAttachedContainerDisabled;

/// <summary>
/// The items stored in this container, including information on how they are stored
/// </summary>
[SyncObject]
/// <summary>
/// The items stored in this container, including information on how they are stored
/// </summary>
[SyncObject]
private readonly SyncList<StoredItem> _storedItems = new();

/// <summary>
Expand Down Expand Up @@ -184,6 +184,7 @@ protected override void OnAwake()

protected override void OnDisabled()
{
// Mostly used to allow inventory to update accessible containers.
base.OnDisabled();
if (!IsServer)
{
Expand All @@ -192,6 +193,20 @@ protected override void OnDisabled()
OnAttachedContainerDisabled?.Invoke(this);
}

protected override void OnEnabled()
{
// Mostly used to allow inventory to update accessible containers.
base.OnEnabled();
if (!IsServer)
{
return;
}
var inventory = GetComponentInParent<HumanInventory>();
if (inventory != null)
{
inventory.TryAddContainer(this);
}
}

protected override void OnDestroyed()
{
Expand Down

0 comments on commit 11ad28a

Please sign in to comment.