[Dependency] private readonly SharedHandsSystem _hands = default!;
[Dependency] private readonly EntityWhitelistSystem _whitelistSystem = default!;
- public const string BinContainerId = "bin-container";
-
/// <inheritdoc/>
public override void Initialize()
{
SubscribeLocalEvent<BinComponent, ComponentStartup>(OnStartup);
SubscribeLocalEvent<BinComponent, MapInitEvent>(OnMapInit);
+ SubscribeLocalEvent<BinComponent, EntInsertedIntoContainerMessage>(OnEntInserted);
SubscribeLocalEvent<BinComponent, EntRemovedFromContainerMessage>(OnEntRemoved);
SubscribeLocalEvent<BinComponent, InteractHandEvent>(OnInteractHand, before: new[] { typeof(SharedItemSystem) });
SubscribeLocalEvent<BinComponent, AfterInteractUsingEvent>(OnAfterInteractUsing);
private void OnStartup(EntityUid uid, BinComponent component, ComponentStartup args)
{
- component.ItemContainer = _container.EnsureContainer<Container>(uid, BinContainerId);
+ component.ItemContainer = _container.EnsureContainer<Container>(uid, component.ContainerId);
}
private void OnMapInit(EntityUid uid, BinComponent component, MapInitEvent args)
}
}
+ private void OnEntInserted(Entity<BinComponent> ent, ref EntInsertedIntoContainerMessage args)
+ {
+ ent.Comp.Items.Add(args.Entity);
+ }
+
private void OnEntRemoved(EntityUid uid, BinComponent component, EntRemovedFromContainerMessage args)
{
component.Items.Remove(args.Entity);
if (args.Using != null)
{
var canReach = args.CanAccess && args.CanInteract;
- InsertIntoBin(args.User, args.Target, (EntityUid) args.Using, component, false, canReach);
+ InsertIntoBin(args.User, args.Target, (EntityUid)args.Using, component, false, canReach);
}
}
return false;
_container.Insert(toInsert, component.ItemContainer);
- component.Items.Add(toInsert);
Dirty(uid, component);
return true;
}