Remove PlaceSimpleBeacon and AnimatedBeacon

This commit is contained in:
abcdefg30
2018-12-26 10:37:16 +01:00
committed by reaperrr
parent 8578ce1346
commit 2ab127537c
3 changed files with 0 additions and 161 deletions

View File

@@ -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<IRenderable> IEffect.Render(WorldRenderer r) { return SpriteRenderable.None; }
IEnumerable<IRenderable> 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);
}
}
}

View File

@@ -87,8 +87,6 @@
<Compile Include="UtilityCommands\LegacyTilesetImporter.cs" />
<Compile Include="Traits\World\TSShroudPalette.cs" />
<Compile Include="UtilityCommands\ImportTSMapCommand.cs" />
<Compile Include="Player\PlaceSimpleBeacon.cs" />
<Compile Include="Effects\AnimatedBeacon.cs" />
<Compile Include="UtilityCommands\LegacyRulesImporter.cs" />
<Compile Include="UtilityCommands\LegacySequenceImporter.cs" />
<Compile Include="Widgets\Logic\PreReleaseWarningPrompt.cs" />

View File

@@ -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<RadarPings>();
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);
}
});
}
}
}