private void HandleCollide(EntityUid uid, FlammableComponent component, StartCollideEvent args)
        {
            if (!args.OtherFixture.Body.Owner.TryGetComponent(out FlammableComponent? otherFlammable))
            {
                return;
            }

            if (!component.FireSpread || !otherFlammable.FireSpread)
            {
                return;
            }

            if (component.OnFire)
            {
                if (otherFlammable.OnFire)
                {
                    var fireSplit = (component.FireStacks + otherFlammable.FireStacks) / 2;
                    component.FireStacks      = fireSplit;
                    otherFlammable.FireStacks = fireSplit;
                }
                else
                {
                    component.FireStacks      /= 2;
                    otherFlammable.FireStacks += component.FireStacks;
                    Ignite(otherFlammable);
                }
            }
            else if (otherFlammable.OnFire)
            {
                otherFlammable.FireStacks /= 2;
                component.FireStacks      += otherFlammable.FireStacks;
                Ignite(component);
            }
        }
        private void HandleCollide(EntityUid uid, ProjectileComponent component, StartCollideEvent args)
        {
            // This is so entities that shouldn't get a collision are ignored.
            if (args.OurFixture.ID != ProjectileFixture || !args.OtherFixture.Hard || component.DamagedEntity)
            {
                return;
            }

            var otherEntity = args.OtherFixture.Body.Owner;

            var modifiedDamage = _damageableSystem.TryChangeDamage(otherEntity, component.Damage);

            component.DamagedEntity = true;

            if (modifiedDamage is not null && EntityManager.EntityExists(component.Shooter))
            {
                _adminLogger.Add(LogType.BulletHit,
                                 HasComp <ActorComponent>(otherEntity) ? LogImpact.Extreme : LogImpact.High,
                                 $"Projectile {ToPrettyString(component.Owner):projectile} shot by {ToPrettyString(component.Shooter):user} hit {ToPrettyString(otherEntity):target} and dealt {modifiedDamage.Total:damage} damage");
            }

            _guns.PlayImpactSound(otherEntity, modifiedDamage, component.SoundHit, component.ForceSound);

            // Damaging it can delete it
            if (HasComp <CameraRecoilComponent>(otherEntity))
            {
                var direction = args.OurFixture.Body.LinearVelocity.Normalized;
                _cameraRecoil.KickCamera(otherEntity, direction);
            }

            if (component.DeleteOnCollide)
            {
                QueueDel(uid);
            }
        }
Exemple #3
0
    private void OnCollide(EntityUid uid, ImmovableRodComponent component, StartCollideEvent args)
    {
        var ent = args.OtherFixture.Body.Owner;

        if (_random.Prob(component.HitSoundProbability))
        {
            SoundSystem.Play(component.Sound.GetSound(), Filter.Pvs(uid), uid, component.Sound.Params);
        }

        if (HasComp <ImmovableRodComponent>(ent))
        {
            // oh god.
            var coords = Transform(uid).Coordinates;
            _popup.PopupCoordinates(Loc.GetString("immovable-rod-collided-rod-not-good"), coords, Filter.Pvs(uid));

            Del(uid);
            Del(ent);
            Spawn("Singularity", coords);

            return;
        }

        // gib em
        if (TryComp <BodyComponent>(ent, out var body))
        {
            component.MobCount++;

            _popup.PopupEntity(Loc.GetString("immovable-rod-penetrated-mob", ("rod", uid), ("mob", ent)), uid, Filter.Pvs(uid));
            body.Gib();
        }

        QueueDel(ent);
    }
 private void HandleCollide(EntityUid uid, StunOnCollideComponent component, StartCollideEvent args)
 {
     if (args.OtherFixture.Body.Owner.TryGetComponent(out StunnableComponent? stunnableComponent))
     {
         stunnableComponent.Stun(component.StunAmount);
         stunnableComponent.Knockdown(component.KnockdownAmount);
         stunnableComponent.Slowdown(component.SlowdownAmount);
     }
 }
Exemple #5
0
        private void OnCollide(EntityUid uid, RecyclerComponent component, StartCollideEvent args)
        {
            if (component.Enabled && args.OurFixture.ID != "brrt")
            {
                return;
            }

            Recycle(component, args.OtherFixture.Body.Owner);
        }
        private void HandleCollide(EntityUid uid, StunOnCollideComponent component, StartCollideEvent args)
        {
            if (args.OurFixture.ID != component.FixtureID)
            {
                return;
            }

            TryDoCollideStun(uid, component, args.OtherFixture.Body.Owner);
        }
Exemple #7
0
        private void HandleCollide(EntityUid uid, FlashAreaOnCollide component, StartCollideEvent args)
        {
            if (component.Flashed)
            {
                return;
            }

            FlashableComponent.FlashAreaHelper(component.Owner, component.Range, component.Duration);
            component.Flashed = true;
        }
        private void HandleCollision(EntityUid uid, ThrownItemComponent component, StartCollideEvent args)
        {
            var thrower   = component.Thrower;
            var otherBody = args.OtherFixture.Body;

            if (otherBody.Owner == thrower)
            {
                return;
            }
            ThrowCollideInteraction(thrower, args.OurFixture.Body, otherBody);
        }
Exemple #9
0
        private void HandleCollide(EntityUid uid, ProjectileComponent component, StartCollideEvent args)
        {
            // This is so entities that shouldn't get a collision are ignored.
            if (!args.OtherFixture.Hard || component.DamagedEntity)
            {
                return;
            }

            var otherEntity = args.OtherFixture.Body.Owner;

            var coordinates  = EntityManager.GetComponent <TransformComponent>(args.OtherFixture.Body.Owner).Coordinates;
            var playerFilter = Filter.Pvs(coordinates);

            if (!EntityManager.GetComponent <MetaDataComponent>(otherEntity).EntityDeleted&& component.SoundHitSpecies != null &&
                EntityManager.HasComponent <SharedBodyComponent>(otherEntity))
            {
                SoundSystem.Play(playerFilter, component.SoundHitSpecies.GetSound(), coordinates);
            }
            else
            {
                var soundHit = component.SoundHit?.GetSound();

                if (!string.IsNullOrEmpty(soundHit))
                {
                    SoundSystem.Play(playerFilter, soundHit, coordinates);
                }
            }

            if (!EntityManager.GetComponent <MetaDataComponent>(otherEntity).EntityDeleted)
            {
                var dmg = _damageableSystem.TryChangeDamage(otherEntity, component.Damage);
                component.DamagedEntity = true;

                if (dmg is not null && EntityManager.EntityExists(component.Shooter))
                {
                    _adminLogSystem.Add(LogType.BulletHit,
                                        HasComp <ActorComponent>(otherEntity) ? LogImpact.Extreme : LogImpact.High,
                                        $"Projectile {ToPrettyString(component.Owner):projectile} shot by {ToPrettyString(component.Shooter):user} hit {ToPrettyString(otherEntity):target} and dealt {dmg.Total:damage} damage");
                }
            }

            // Damaging it can delete it
            if (!EntityManager.GetComponent <MetaDataComponent>(otherEntity).EntityDeleted&&
                EntityManager.HasComponent <CameraRecoilComponent>(otherEntity))
            {
                var direction = args.OurFixture.Body.LinearVelocity.Normalized;
                _cameraRecoil.KickCamera(otherEntity, direction);
            }

            if (component.DeleteOnCollide)
            {
                EntityManager.QueueDeleteEntity(uid);
            }
        }
        private void HandleCollide(EntityUid uid, ProjectileComponent component, StartCollideEvent args)
        {
            // This is so entities that shouldn't get a collision are ignored.
            if (!args.OtherFixture.Hard || component.DamagedEntity)
            {
                return;
            }

            var otherEntity = args.OtherFixture.Body.Owner;

            var coordinates  = args.OtherFixture.Body.Owner.Transform.Coordinates;
            var playerFilter = Filter.Pvs(coordinates);

            if (!otherEntity.Deleted && component.SoundHitSpecies != null &&
                otherEntity.HasComponent <SharedBodyComponent>())
            {
                SoundSystem.Play(playerFilter, component.SoundHitSpecies.GetSound(), coordinates);
            }
            else
            {
                var soundHit = component.SoundHit?.GetSound();

                if (!string.IsNullOrEmpty(soundHit))
                {
                    SoundSystem.Play(playerFilter, soundHit, coordinates);
                }
            }

            if (!otherEntity.Deleted && otherEntity.TryGetComponent(out IDamageableComponent? damage))
            {
                EntityManager.TryGetEntity(component.Shooter, out var shooter);

                foreach (var(damageTypeID, amount) in component.Damages)
                {
                    damage.TryChangeDamage(_prototypeManager.Index <DamageTypePrototype>(damageTypeID), amount);
                }

                component.DamagedEntity = true;
            }

            // Damaging it can delete it
            if (!otherEntity.Deleted && otherEntity.TryGetComponent(out CameraRecoilComponent? recoilComponent))
            {
                var direction = args.OurFixture.Body.LinearVelocity.Normalized;
                recoilComponent.Kick(direction);
            }

            if (component.DeleteOnCollide)
            {
                EntityManager.QueueDeleteEntity(uid);
            }
        }
    private void OnCollide(EntityUid uid, SpaceGarbageComponent component, StartCollideEvent args)
    {
        var ourXform   = Transform(args.OurFixture.Body.Owner);
        var otherXform = Transform(args.OtherFixture.Body.Owner);

        if (ourXform.GridUid == otherXform.GridUid ||
            args.OtherFixture.Body.BodyType != BodyType.Static)
        {
            return;
        }

        QueueDel(uid);
    }
Exemple #12
0
    private void HandleCollide(EntityUid uid, StepTriggerComponent component, StartCollideEvent args)
    {
        var otherUid = args.OtherFixture.Body.Owner;

        if (!CanTrigger(uid, otherUid, component))
        {
            return;
        }

        EnsureComp <StepTriggerActiveComponent>(uid);

        component.Colliding.Add(otherUid);
    }
Exemple #13
0
        private void HandleCollide(EntityUid uid, ProjectileComponent component, StartCollideEvent args)
        {
            // This is so entities that shouldn't get a collision are ignored.
            if (!args.OtherFixture.Hard || component.DamagedEntity)
            {
                return;
            }

            var coordinates  = args.OtherFixture.Body.Owner.Transform.Coordinates;
            var playerFilter = Filter.Pvs(coordinates);

            if (args.OtherFixture.Body.Owner.TryGetComponent(out IDamageableComponent? damage) && component.SoundHitSpecies != null)
            {
                SoundSystem.Play(playerFilter, component.SoundHitSpecies, coordinates);
            }
Exemple #14
0
        private void HandleCollide(EntityUid uid, VaporComponent component, StartCollideEvent args)
        {
            if (!ComponentManager.TryGetComponent(uid, out SolutionContainerComponent? contents))
            {
                return;
            }

            contents.Solution.DoEntityReaction(args.OtherFixture.Body.Owner, ReactionMethod.Touch);

            // Check for collision with a impassable object (e.g. wall) and stop
            if ((args.OtherFixture.CollisionLayer & (int)CollisionGroup.Impassable) != 0 && args.OtherFixture.Hard)
            {
                EntityManager.QueueDeleteEntity(uid);
            }
        }
        private void HandleCollide(EntityUid uid, ProjectileComponent component, StartCollideEvent args)
        {
            // This is so entities that shouldn't get a collision are ignored.
            if (!args.OtherFixture.Hard || component.DamagedEntity)
            {
                return;
            }

            var otherEntity = args.OtherFixture.Body.Owner;

            var coordinates  = args.OtherFixture.Body.Owner.Transform.Coordinates;
            var playerFilter = Filter.Pvs(coordinates);

            if (!otherEntity.Deleted && component.SoundHitSpecies != null &&
                otherEntity.HasComponent <SharedBodyComponent>())
            {
                SoundSystem.Play(playerFilter, component.SoundHitSpecies.GetSound(), coordinates);
            }
            else
            {
                var soundHit = component.SoundHit?.GetSound();

                if (!string.IsNullOrEmpty(soundHit))
                {
                    SoundSystem.Play(playerFilter, soundHit, coordinates);
                }
            }

            if (!otherEntity.Deleted)
            {
                _damageableSystem.TryChangeDamage(otherEntity.Uid, component.Damage);
                component.DamagedEntity = true;
                // "DamagedEntity" is misleading. Hit entity may be more accurate, as the damage may have been resisted
                // by resistance sets.
            }

            // Damaging it can delete it
            if (!otherEntity.Deleted && otherEntity.TryGetComponent(out CameraRecoilComponent? recoilComponent))
            {
                var direction = args.OurFixture.Body.LinearVelocity.Normalized;
                recoilComponent.Kick(direction);
            }

            if (component.DeleteOnCollide)
            {
                EntityManager.QueueDeleteEntity(uid);
            }
        }
Exemple #16
0
        private void HandleCollide(EntityUid uid, ServerDoorComponent component, StartCollideEvent args)
        {
            if (component.State != SharedDoorComponent.DoorState.Closed)
            {
                return;
            }

            if (!component.BumpOpen)
            {
                return;
            }

            // Disabled because it makes it suck hard to walk through double doors.

            component.TryOpen(args.OtherFixture.Body.Owner);
        }
        private void OnBallCollide(EntityUid uid, BallComponent component, StartCollideEvent args)
        {
            // Reflect the ball if it has collided with anything and speed it up slightly.
            var physics = ComponentManager.GetComponent <PhysicsComponent>(uid);

            var(_, y) = args.OtherFixture.Body.LinearVelocity;
            var ourVelocity = physics.LinearVelocity;

            // Can't be zero, otherwise the maths don't check out.
            // Reflect direction will depend on positions so it can be predicted accurately by the client.
            if (MathHelper.CloseTo(y, 0f))
            {
                y = component.Owner.Transform.WorldPosition.Y > args.OtherFixture.Body.Owner.Transform.WorldPosition.Y
                    ? 1f : -1f;
            }

            physics.LinearVelocity *= new Vector2(-1, MathF.Sign(y) * MathF.Sign(ourVelocity.Y)) * _ballSpeedupFactor;

            SoundSystem.Play(Filter.Broadcast(), "/Audio/bleep.wav", AudioParams.Default);
        }
Exemple #18
0
    private void OnCollide(EntityUid uid, FlyBySoundComponent component, StartCollideEvent args)
    {
        var attachedEnt = _player.LocalPlayer?.ControlledEntity;

        // If it's not our ent or we shot it.
        if (attachedEnt == null ||
            args.OtherFixture.Body.Owner != attachedEnt ||
            TryComp <ProjectileComponent>(args.OurFixture.Body.Owner, out var projectile) &&
            projectile.Shooter == attachedEnt)
        {
            return;
        }

        if (args.OurFixture.ID != FlyByFixture ||
            !_random.Prob(component.Prob))
        {
            return;
        }

        SoundSystem.Play(component.Sound.GetSound(), Filter.Local(), uid, component.Sound.Params);
    }
Exemple #19
0
        private void HandleCollide(EntityUid uid, StunOnCollideComponent component, StartCollideEvent args)
        {
            var otherUid = args.OtherFixture.Body.Owner;

            if (EntityManager.TryGetComponent <StatusEffectsComponent>(otherUid, out var status))
            {
                ServerAlertsComponent? alerts        = null;
                StandingStateComponent?standingState = null;
                AppearanceComponent?   appearance    = null;

                // Let the actual methods log errors for these.
                Resolve(otherUid, ref alerts, ref standingState, ref appearance, false);

                _stunSystem.TryStun(otherUid, TimeSpan.FromSeconds(component.StunAmount), true, status, alerts);

                _stunSystem.TryKnockdown(otherUid, TimeSpan.FromSeconds(component.KnockdownAmount), true,
                                         status, alerts);

                _stunSystem.TrySlowdown(otherUid, TimeSpan.FromSeconds(component.SlowdownAmount), true,
                                        component.WalkSpeedMultiplier, component.RunSpeedMultiplier, status, alerts);
            }
        }
Exemple #20
0
        private void OnCollide(EntityUid uid, ServerSingularityComponent component, StartCollideEvent args)
        {
            if (args.OurFixture.ID != "DeleteCircle")
            {
                return;
            }

            // This handles bouncing off of containment walls.
            // If you want the delete behavior we do it under DeleteEntities for reasons (not everything has physics).

            // If we're being deleted by another singularity, this call is probably for that singularity.
            // Even if not, just don't bother.
            if (component.BeingDeletedByAnotherSingularity)
            {
                return;
            }

            var otherUid = args.OtherFixture.Body.Owner;

            // HandleDestroy will also check CanDestroy for us
            HandleDestroy(component, otherUid);
        }
        private void OnCollideEvent(EntityUid uid, FlammableComponent flammable, StartCollideEvent args)
        {
            var otherUid = args.OtherFixture.Body.Owner.Uid;

            if (!EntityManager.TryGetComponent(otherUid, out FlammableComponent? otherFlammable))
            {
                return;
            }

            if (!flammable.FireSpread || !otherFlammable.FireSpread)
            {
                return;
            }

            if (flammable.OnFire)
            {
                if (otherFlammable.OnFire)
                {
                    var fireSplit = (flammable.FireStacks + otherFlammable.FireStacks) / 2;
                    flammable.FireStacks      = fireSplit;
                    otherFlammable.FireStacks = fireSplit;
                }
                else
                {
                    flammable.FireStacks      /= 2;
                    otherFlammable.FireStacks += flammable.FireStacks;
                    Ignite(otherUid, otherFlammable);
                }
            }
            else if (otherFlammable.OnFire)
            {
                otherFlammable.FireStacks /= 2;
                flammable.FireStacks      += otherFlammable.FireStacks;
                Ignite(uid, flammable);
            }
        }
 private void HandleCollide(EntityUid uid, TriggerOnCollideComponent component, StartCollideEvent args)
 {
     Trigger(component.Owner);
 }
        private void OnElectrifiedStartCollide(EntityUid uid, ElectrifiedComponent electrified, StartCollideEvent args)
        {
            if (!electrified.OnBump)
            {
                return;
            }

            TryDoElectrifiedAct(uid, args.OtherFixture.Body.Owner, 1, electrified);
        }
        private void HandleParticleCollide(EntityUid uid, ParticleProjectileComponent component, StartCollideEvent args)
        {
            if (EntityManager.TryGetComponent <SingularityGeneratorComponent?>(args.OtherFixture.Body.Owner, out var singularityGeneratorComponent))
            {
                singularityGeneratorComponent.Power += component.State switch
                {
                    ParticleAcceleratorPowerState.Standby => 0,
                    ParticleAcceleratorPowerState.Level0 => 1,
                    ParticleAcceleratorPowerState.Level1 => 2,
                    ParticleAcceleratorPowerState.Level2 => 4,
                    ParticleAcceleratorPowerState.Level3 => 8,
                    _ => 0
                };

                EntityManager.QueueDeleteEntity(uid);
            }
        }
 private void HandleFieldCollide(EntityUid uid, ContainmentFieldComponent component, StartCollideEvent args)
 {
     if (component.Parent == null)
     {
         EntityManager.QueueDeleteEntity(uid);
         return;
     }
 }
 private void HandleGeneratorCollide(EntityUid uid, ContainmentFieldGeneratorComponent component, StartCollideEvent args)
 {
     if (_tags.HasTag(args.OtherFixture.Body.Owner, "EmitterBolt"))
     {
         ReceivePower(6, component);
     }
 }
    private void OnTimerCollide(EntityUid uid, TriggerOnTimedCollideComponent component, StartCollideEvent args)
    {
        //Ensures the entity trigger will have an active component
        EnsureComp <ActiveTriggerOnTimedCollideComponent>(uid);
        var otherUID = args.OtherFixture.Body.Owner;

        component.Colliding.Add(otherUID, 0);
    }
Exemple #28
0
        private void HandleCollide(EntityUid uid, DamageOnHighSpeedImpactComponent component, StartCollideEvent args)
        {
            if (!ComponentManager.TryGetComponent(uid, out IDamageableComponent? damageable))
            {
                return;
            }

            var otherBody = args.OtherFixture.Body.Owner;
            var speed     = args.OurFixture.Body.LinearVelocity.Length;

            if (speed < component.MinimumSpeed)
            {
                return;
            }

            if (!string.IsNullOrEmpty(component.SoundHit))
            {
                SoundSystem.Play(Filter.Pvs(otherBody), component.SoundHit, otherBody, AudioHelpers.WithVariation(0.125f).WithVolume(-0.125f));
            }

            if ((_gameTiming.CurTime - component.LastHit).TotalSeconds < component.DamageCooldown)
            {
                return;
            }

            component.LastHit = _gameTiming.CurTime;

            var damage = (int)(component.BaseDamage * (speed / component.MinimumSpeed) * component.Factor);

            if (ComponentManager.TryGetComponent(uid, out StunnableComponent? stun) && _robustRandom.Prob(component.StunChance))
            {
                stun.Stun(component.StunSeconds);
            }

            damageable.ChangeDamage(component.Damage, damage, false, args.OtherFixture.Body.Owner);
        }
 private void HandleCollide(EntityUid uid, RecyclerComponent component, StartCollideEvent args)
 {
     Recycle(component, args.OtherFixture.Body.Owner);
 }
Exemple #30
0
        private void HandleFieldCollide(EntityUid uid, ContainmentFieldComponent component, StartCollideEvent args)
        {
            if (component.Parent == null)
            {
                EntityManager.QueueDeleteEntity(uid);
                return;
            }

            component.Parent.TryRepell(component.Owner, args.OtherFixture.Body.Owner);
        }