From 2ab127537cbaed5cf31fe2d27367f18af28d483f Mon Sep 17 00:00:00 2001 From: abcdefg30 Date: Wed, 26 Dec 2018 10:37:16 +0100 Subject: [PATCH] Remove PlaceSimpleBeacon and AnimatedBeacon --- OpenRA.Mods.Cnc/Effects/AnimatedBeacon.cs | 75 ------------------ OpenRA.Mods.Cnc/OpenRA.Mods.Cnc.csproj | 2 - OpenRA.Mods.Cnc/Player/PlaceSimpleBeacon.cs | 84 --------------------- 3 files changed, 161 deletions(-) delete mode 100644 OpenRA.Mods.Cnc/Effects/AnimatedBeacon.cs delete mode 100644 OpenRA.Mods.Cnc/Player/PlaceSimpleBeacon.cs diff --git a/OpenRA.Mods.Cnc/Effects/AnimatedBeacon.cs b/OpenRA.Mods.Cnc/Effects/AnimatedBeacon.cs deleted file mode 100644 index d8133e0049..0000000000 --- a/OpenRA.Mods.Cnc/Effects/AnimatedBeacon.cs +++ /dev/null @@ -1,75 +0,0 @@ -#region Copyright & License Information -/* - * Copyright 2007-2019 The OpenRA Developers (see AUTHORS) - * This file is part of OpenRA, which is free software. It is made - * available to you under the terms of the GNU General Public License - * as published by the Free Software Foundation, either version 3 of - * the License, or (at your option) any later version. For more - * information, see COPYING. - */ -#endregion - -using System.Collections.Generic; -using OpenRA.Effects; -using OpenRA.Graphics; - -namespace OpenRA.Mods.Cnc.Effects -{ - public class AnimatedBeacon : IEffect, IEffectAboveShroud - { - readonly Player owner; - readonly WPos position; - readonly string beaconPalette; - readonly bool isPlayerPalette; - readonly Animation beacon; - readonly int duration; - - int delay; - int tick; - - public AnimatedBeacon(Player owner, WPos position, int duration, string beaconPalette, bool isPlayerPalette, string beaconImage, string beaconSequence, int delay = 0) - { - this.owner = owner; - this.position = position; - this.beaconPalette = beaconPalette; - this.isPlayerPalette = isPlayerPalette; - this.duration = duration; - this.delay = delay; - - if (!string.IsNullOrEmpty(beaconSequence)) - { - beacon = new Animation(owner.World, beaconImage); - beacon.PlayRepeating(beaconSequence); - } - } - - void IEffect.Tick(World world) - { - if (delay-- > 0) - return; - - if (beacon != null) - beacon.Tick(); - - if (duration > 0 && duration <= tick++) - owner.World.AddFrameEndTask(w => w.Remove(this)); - } - - IEnumerable IEffect.Render(WorldRenderer r) { return SpriteRenderable.None; } - - IEnumerable IEffectAboveShroud.RenderAboveShroud(WorldRenderer r) - { - if (delay > 0) - return SpriteRenderable.None; - - if (beacon == null) - return SpriteRenderable.None; - - if (!owner.IsAlliedWith(owner.World.RenderPlayer)) - return SpriteRenderable.None; - - var palette = r.Palette(isPlayerPalette ? beaconPalette + owner.InternalName : beaconPalette); - return beacon.Render(position, palette); - } - } -} diff --git a/OpenRA.Mods.Cnc/OpenRA.Mods.Cnc.csproj b/OpenRA.Mods.Cnc/OpenRA.Mods.Cnc.csproj index 57f4fd537c..6cc0aaca7b 100644 --- a/OpenRA.Mods.Cnc/OpenRA.Mods.Cnc.csproj +++ b/OpenRA.Mods.Cnc/OpenRA.Mods.Cnc.csproj @@ -87,8 +87,6 @@ - - diff --git a/OpenRA.Mods.Cnc/Player/PlaceSimpleBeacon.cs b/OpenRA.Mods.Cnc/Player/PlaceSimpleBeacon.cs deleted file mode 100644 index a9842b24bc..0000000000 --- a/OpenRA.Mods.Cnc/Player/PlaceSimpleBeacon.cs +++ /dev/null @@ -1,84 +0,0 @@ -#region Copyright & License Information -/* - * Copyright 2007-2019 The OpenRA Developers (see AUTHORS) - * This file is part of OpenRA, which is free software. It is made - * available to you under the terms of the GNU General Public License - * as published by the Free Software Foundation, either version 3 of - * the License, or (at your option) any later version. For more - * information, see COPYING. - */ -#endregion - -using OpenRA.Mods.Cnc.Effects; -using OpenRA.Mods.Common.Traits; -using OpenRA.Traits; - -namespace OpenRA.Mods.Cnc.Traits -{ - [Desc("A beacon that consists of a single sprite that can be animated.")] - public class PlaceSimpleBeaconInfo : ITraitInfo - { - public readonly int Duration = 30 * 25; - - public readonly string NotificationType = "Sounds"; - - [NotificationReference(typeFromField: "NotificationType")] - public readonly string Notification = "Beacon"; - - public readonly bool IsPlayerPalette = false; - [PaletteReference("IsPlayerPalette")] public readonly string Palette = "effect"; - - public readonly string BeaconImage = "beacon"; - [SequenceReference("BeaconImage")] public readonly string BeaconSequence = "idle"; - - public object Create(ActorInitializer init) { return new PlaceSimpleBeacon(init.Self, this); } - } - - public class PlaceSimpleBeacon : IResolveOrder - { - readonly PlaceSimpleBeaconInfo info; - readonly RadarPings radarPings; - - AnimatedBeacon playerBeacon; - RadarPing playerRadarPing; - - public PlaceSimpleBeacon(Actor self, PlaceSimpleBeaconInfo info) - { - radarPings = self.World.WorldActor.TraitOrDefault(); - this.info = info; - } - - public void ResolveOrder(Actor self, Order order) - { - if (order.OrderString != "PlaceBeacon") - return; - - var pos = order.Target.CenterPosition; - - 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, - info.Duration); - } - }); - } - } -}