private void OnInsertEvent(EntityUid uid, FoldableComponent component, ContainerGettingInsertedAttemptEvent args) { if (!component.IsFolded) { args.Cancel(); } }
private void OnInsertAttempt(EntityUid uid, BlockingUserComponent component, ContainerGettingInsertedAttemptEvent args) { if (TryComp <BlockingComponent>(component.BlockingItem, out var blockComp) && blockComp.IsBlocking) { _blockingSystem.StopBlocking(component.BlockingItem.Value, blockComp, uid); } }
private void OnInsertAttempt(EntityUid uid, StrapComponent component, ContainerGettingInsertedAttemptEvent args) { // If someone is attempting to put this item inside of a backpack, ensure that it has no entities strapped to it. if (HasComp <SharedStorageComponent>(args.Container.Owner) && component.BuckledEntities.Count != 0) { args.Cancel(); } }
/// <inheritdoc /> public virtual bool CanInsert(EntityUid toinsert, IEntityManager?entMan = null) { DebugTools.Assert(!Deleted); // cannot insert into itself. if (Owner == toinsert) { return(false); } IoCManager.Resolve(ref entMan); // no, you can't put maps or grids into containers if (entMan.HasComponent <IMapComponent>(toinsert) || entMan.HasComponent <IMapGridComponent>(toinsert)) { return(false); } // Crucial, prevent circular insertion. if (entMan.GetComponent <TransformComponent>(toinsert) .ContainsEntity(entMan.GetComponent <TransformComponent>(Owner))) { return(false); } //Improvement: Traverse the entire tree to make sure we are not creating a loop. //raise events var insertAttemptEvent = new ContainerIsInsertingAttemptEvent(this, toinsert); entMan.EventBus.RaiseLocalEvent(Owner, insertAttemptEvent); if (insertAttemptEvent.Cancelled) { return(false); } var gettingInsertedAttemptEvent = new ContainerGettingInsertedAttemptEvent(this, toinsert); entMan.EventBus.RaiseLocalEvent(toinsert, gettingInsertedAttemptEvent); if (gettingInsertedAttemptEvent.Cancelled) { return(false); } return(true); }