Example #1
0
        void INotifyDamage.Damaged(Actor self, AttackInfo e)
        {
            // Don't track self-damage
            if (e.Attacker != null && e.Attacker.Owner == self.Owner)
            {
                return;
            }

            // Only track last hit against our harvesters
            if (!self.Info.HasTraitInfo <AcolytePreyInfo>())
            {
                return;
            }

            if (self.World.WorldTick - lastAttackTime > info.NotifyInterval * 25)
            {
                Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", info.Notification, self.Owner.Faction.InternalName);

                if (radarPings != null)
                {
                    radarPings.Add(() => self.Owner.IsAlliedWith(self.World.RenderPlayer), self.CenterPosition, info.RadarPingColor, info.RadarPingDuration);
                }
            }

            lastAttackTime = self.World.WorldTick;
        }
Example #2
0
        bool AttackTargets(Actor self, IEnumerable <Actor> targets)
        {
            var targetLocation = target.Actor.Location;

            foreach (var t in targets)
            {
                var targetClose = t;                 // loop variable in closure hazard

                self.World.AddFrameEndTask(_ =>
                {
                    // Don't use Kill() because we don't want any of its side-effects (husks, etc)
                    targetClose.Dispose();

                    // Harvester insurance
                    if (targetClose.Info.HasTraitInfo <HarvesterInfo>())
                    {
                        var insurance = targetClose.Owner.PlayerActor.TraitOrDefault <HarvesterInsurance>();
                        if (insurance != null)
                        {
                            self.World.AddFrameEndTask(__ => insurance.TryActivate());
                        }
                    }
                });
            }

            positionable.SetPosition(self, targetLocation);

            var attackPosition  = self.CenterPosition;
            var affectedPlayers = targets.Select(x => x.Owner).Distinct().ToList();

            Game.Sound.Play(swallow.Info.WormAttackSound, self.CenterPosition);

            Game.RunAfterDelay(1000, () =>
            {
                if (!Game.IsCurrentWorld(self.World))
                {
                    return;
                }

                foreach (var player in affectedPlayers)
                {
                    Game.Sound.PlayNotification(player.World.Map.Rules, player, "Speech", swallow.Info.WormAttackNotification, player.Faction.InternalName);

                    if (player == player.World.RenderPlayer)
                    {
                        radarPings.Add(() => true, attackPosition, Color.Red, 50);
                    }
                }
            });

            foreach (var notify in self.TraitsImplementing <INotifyAttack>())
            {
                notify.PreparingAttack(self, target, null, null);
                notify.Attacking(self, target, null, null);
            }

            return(true);
        }
Example #3
0
        void NotifyPlayer(Player player, WPos location)
        {
            Sound.PlayNotification(player.World.Map.Rules, player, "Speech", swallow.Info.WormAttackNotification, player.Country.Race);

            if (player == player.World.RenderPlayer)
            {
                radarPings.Add(() => true, location, Color.Red, 50);
            }
        }
Example #4
0
 public void Ping(Player player, WPos position, Color color, int duration = 30 * 25)
 {
     if (radarPings != null)
     {
         radarPings.Add(
             () => player.World.RenderPlayer == player,
             position,
             color,
             duration);
     }
 }
Example #5
0
        void INotifyDamage.Damaged(Actor self, AttackInfo e)
        {
            if (e.Attacker == null)
            {
                return;
            }

            if (e.Attacker.Owner == self.Owner)
            {
                return;
            }

            if (e.Attacker == self.World.WorldActor)
            {
                return;
            }

            if (e.Damage.Value == 0)
            {
                return;
            }

            var ani = self.Info.TraitInfoOrDefault <AttackNotificationInfo>();

            if (ani == null)
            {
                return;
            }

            var veterancy    = self.TraitOrDefault <Veterancy.Veterancy>();
            var notification = ani.Notifications[(veterancy == null ? 0 : veterancy.Level) % ani.Notifications.Length];

            if (!lastAttackTimes.ContainsKey(notification))
            {
                lastAttackTimes.Add(notification, self.World.WorldTick - info.NotifyInterval * 25);
            }

            if (self.World.WorldTick - lastAttackTimes[notification] >= info.NotifyInterval * 25)
            {
                Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", notification, self.Owner.Faction.InternalName);

                if (ani.RadarPings)
                {
                    radarPings.Add(() => self.Owner.IsAlliedWith(self.World.RenderPlayer), self.CenterPosition, info.RadarPingColor, info.RadarPingDuration);
                }
            }

            lastAttackTimes[notification] = self.World.WorldTick;
        }
Example #6
0
        public void Tick(World world)
        {
            if (remainingDelay-- > 0)
            {
                return;
            }

            Game.Sound.PlayNotification(player.World.Map.Rules, player, category, notification, player.Faction.InternalName);

            if (visible && radarPings != null && player == player.World.RenderPlayer)
            {
                radarPings.Add(() => true, pos, color, duration);
            }

            world.AddFrameEndTask(w => w.Remove(this));
        }
Example #7
0
        public Beacon New(Player owner, WPos position, int duration = 30 * 25, bool showRadarPings = true, string palettePrefix = "player")
        {
            var playerBeacon = new Beacon(owner, position, duration, palettePrefix);

            owner.PlayerActor.World.AddFrameEndTask(w => w.Add(playerBeacon));

            if (showRadarPings && radarPings != null)
            {
                radarPings.Add(
                    () => owner.IsAlliedWith(owner.World.RenderPlayer),
                    position,
                    owner.Color.RGB,
                    duration);
            }

            return(playerBeacon);
        }
Example #8
0
        public Beacon New(Player owner, WPos position, int duration = 30 * 25, bool showRadarPings = true)
        {
            var beacon       = owner.PlayerActor.Info.TraitInfo <PlaceBeaconInfo>();
            var playerBeacon = new Beacon(owner, position, duration, beacon.Palette, beacon.IsPlayerPalette, beacon.BeaconImage, beacon.ArrowSequence, beacon.CircleSequence);

            owner.PlayerActor.World.AddFrameEndTask(w => w.Add(playerBeacon));

            if (showRadarPings && radarPings != null)
            {
                radarPings.Add(
                    () => owner.IsAlliedWith(owner.World.RenderPlayer),
                    position,
                    owner.Color.RGB,
                    duration);
            }

            return(playerBeacon);
        }
Example #9
0
        public void ResolveOrder(Actor self, Order order)
        {
            if (order.OrderString != "PlaceBeacon")
            {
                return;
            }

            var pos = self.World.Map.CenterOfCell(order.TargetLocation);

            self.World.AddFrameEndTask(w =>
            {
                if (playerBeacon != null)
                {
                    self.World.Remove(playerBeacon);
                }

                playerBeacon = new AnimatedBeacon(self.Owner, pos, info.Duration, info.Palette, info.IsPlayerPalette, info.BeaconImage, info.BeaconSequence);
                self.World.Add(playerBeacon);

                if (self.Owner.IsAlliedWith(self.World.RenderPlayer))
                {
                    Game.Sound.PlayNotification(self.World.Map.Rules, null, info.NotificationType, info.Notification,
                                                self.World.RenderPlayer != null ? self.World.RenderPlayer.Faction.InternalName : null);
                }

                if (radarPings != null)
                {
                    if (playerRadarPing != null)
                    {
                        radarPings.Remove(playerRadarPing);
                    }

                    playerRadarPing = radarPings.Add(
                        () => self.Owner.IsAlliedWith(self.World.RenderPlayer),
                        pos,
                        self.Owner.Color.RGB,
                        info.Duration);
                }
            });
        }
Example #10
0
        public void New(Player owner, WPos position, int duration = 30 * 25, bool showRadarPings = true)
        {
            var beacon = owner.PlayerActor.Info.TraitInfoOrDefault <PlaceBeaconInfo>();

            if (beacon == null)
            {
                throw new LuaException("The player actor has no 'PlaceBeacon' trait.");
            }

            var playerBeacon = new Beacon(owner, position, duration, beacon.Palette, beacon.IsPlayerPalette,
                                          beacon.BeaconImage, beacon.BeaconSequence, beacon.ArrowSequence, beacon.CircleSequence);

            owner.PlayerActor.World.AddFrameEndTask(w => w.Add(playerBeacon));

            if (showRadarPings && radarPings != null)
            {
                radarPings.Add(
                    () => owner.IsAlliedWith(owner.World.RenderPlayer),
                    position,
                    owner.Color,
                    duration);
            }
        }
Example #11
0
 public void Ping(Player player, WPos position, Color color, int duration = 750)
 {
     radarPings?.Add(() => player.World.RenderPlayer == player, position, color, duration);
 }