public override void Update(float frameTime)
        {
            foreach (var(component, transform) in EntityManager.EntityQuery <RoguePointingArrowComponent, TransformComponent>())
            {
                var uid = component.Owner;
                component.Chasing ??= RandomNearbyPlayer(uid, component, transform);

                if (component.Chasing is not {
                    Valid: true
                } chasing)
                {
                    EntityManager.QueueDeleteEntity(uid);
                    return;
                }

                component.TurningDelay -= frameTime;

                if (component.TurningDelay > 0)
                {
                    var difference = EntityManager.GetComponent <TransformComponent>(chasing).WorldPosition - transform.WorldPosition;
                    var angle      = difference.ToAngle();
                    var adjusted   = angle.Degrees + 90;
                    var newAngle   = Angle.FromDegrees(adjusted);

                    transform.LocalRotation = newAngle;

                    UpdateAppearance(uid, component, transform);
                    return;
                }

                transform.WorldRotation += Angle.FromDegrees(20);

                UpdateAppearance(uid, component, transform);

                var toChased = EntityManager.GetComponent <TransformComponent>(chasing).WorldPosition - transform.WorldPosition;

                transform.WorldPosition += toChased * frameTime * component.ChasingSpeed;

                component.ChasingTime -= frameTime;

                if (component.ChasingTime > 0)
                {
                    return;
                }

                _explosions.SpawnExplosion(uid, 0, 2, 1, 1);
                SoundSystem.Play(Filter.Pvs(uid, entityManager: EntityManager), component.ExplosionSound.GetSound(), uid);

                EntityManager.QueueDeleteEntity(uid);
            }
        }
Exemplo n.º 2
0
    private void Explode(EntityUid uid, BatteryComponent?battery = null)
    {
        _logSystem.Add(LogType.Explosion, LogImpact.High, $"Sabotaged power cell {ToPrettyString(uid)} is exploding");

        if (!Resolve(uid, ref battery))
        {
            return;
        }

        var heavy = (int)Math.Ceiling(Math.Sqrt(battery.CurrentCharge) / 60);
        var light = (int)Math.Ceiling(Math.Sqrt(battery.CurrentCharge) / 30);

        _explosionSystem.SpawnExplosion(uid, 0, heavy, light, light * 2);
        QueueDel(uid);
    }