Example #1
0
        public virtual bool CanInsert(SharedDisposalUnitComponent component, EntityUid entity)
        {
            if (!EntityManager.GetComponent <TransformComponent>(component.Owner).Anchored)
            {
                return(false);
            }

            // TODO: Probably just need a disposable tag.
            if (!EntityManager.TryGetComponent(entity, out SharedItemComponent? storable) &&
                !EntityManager.HasComponent <SharedBodyComponent>(entity))
            {
                return(false);
            }


            if (!EntityManager.TryGetComponent(entity, out IPhysBody? physics) ||
                !physics.CanCollide && storable == null)
            {
                if (!(EntityManager.TryGetComponent(entity, out MobStateComponent? damageState) && damageState.IsDead()))
                {
                    return(false);
                }
            }

            return(true);
        }
Example #2
0
        private void OnCanDragDropOn(EntityUid uid, SharedDisposalUnitComponent component, CanDragDropOnEvent args)
        {
            if (args.Handled)
            {
                return;
            }

            args.CanDrop = CanInsert(component, args.Dragged);
            args.Handled = true;
        }
Example #3
0
        private void OnPreventCollide(EntityUid uid, SharedDisposalUnitComponent component, PreventCollideEvent args)
        {
            var otherBody = args.BodyB.Owner;

            // Items dropped shouldn't collide but items thrown should
            if (EntityManager.HasComponent <SharedItemComponent>(otherBody) &&
                !EntityManager.HasComponent <ThrownItemComponent>(otherBody))
            {
                args.Cancel();
                return;
            }

            if (component.RecentlyEjected.Contains(otherBody))
            {
                args.Cancel();
            }
        }
Example #4
0
        public bool CanInsert(SharedDisposalUnitComponent component, EntityUid entityId)
        {
            var entity = EntityManager.GetEntity(entityId);

            return(CanInsert(component, entity));
        }