Example #1
0
        private void HandleCollisionWakeState(EntityUid uid, CollisionWakeComponent component, CollisionWakeStateMessage args)
        {
            if (!ComponentManager.TryGetComponent <PhysicsComponent>(uid, out var body))
            {
                return;
            }

            body.CanCollide = !component.Enabled || body.Awake || body.Joints.Any();
        }
 private void HandleCollisionWakeState(EntityUid uid, CollisionWakeComponent component, CollisionWakeStateMessage args)
 {
     if (ComponentManager.TryGetComponent <IPhysBody>(uid, out var body))
     {
         body.CanCollide = !component.Enabled || body.Awake;
     }
 }
Example #3
0
        private void HandleCollisionWakeState(EntityUid uid, CollisionWakeComponent component, CollisionWakeStateMessage args)
        {
            // If you really wanted you could optimise for each use case above and save some calls but
            // these are called pretty infrequently so I'm fine with this for now.

            // If we just got put into a container don't want to mess with our collision state.
            if (!EntityManager.TryGetComponent <PhysicsComponent>(uid, out var body))
            {
                return;
            }

            // If we're attached to the map we'll also just never disable collision due to how grid movement works.
            body.CanCollide = !component.Enabled ||
                              body.Awake ||
                              (EntityManager.TryGetComponent(uid, out JointComponent? jointComponent) && jointComponent.JointCount > 0) ||
                              EntityManager.GetComponent <TransformComponent>(uid).GridID == GridId.Invalid;
        }