GPS Satellite.
This commit is contained in:
@@ -12,7 +12,7 @@ using System.Linq;
|
||||
using OpenRA.Effects;
|
||||
using OpenRA.Mods.RA.Effects;
|
||||
using OpenRA.Traits;
|
||||
/*
|
||||
|
||||
namespace OpenRA.Mods.RA
|
||||
{
|
||||
class GpsPowerInfo : SupportPowerInfo
|
||||
@@ -26,29 +26,21 @@ namespace OpenRA.Mods.RA
|
||||
{
|
||||
public GpsPower(Actor self, GpsPowerInfo info) : base(self, info) { }
|
||||
|
||||
protected override void OnFinishCharging()
|
||||
public override void Charged(Actor self, string key)
|
||||
{
|
||||
var launchSite = Owner.World.Queries.OwnedBy[Owner]
|
||||
.FirstOrDefault(a => a.HasTrait<GpsLaunchSite>());
|
||||
self.Owner.PlayerActor.Trait<SupportPowerManager>().Powers[key].Activate(new Order());
|
||||
}
|
||||
|
||||
if (launchSite == null)
|
||||
return;
|
||||
|
||||
Owner.World.AddFrameEndTask(w =>
|
||||
public override void Activate(Actor self, Order order)
|
||||
{
|
||||
self.World.AddFrameEndTask(w =>
|
||||
{
|
||||
Sound.PlayToPlayer(Owner, Info.LaunchSound);
|
||||
Sound.PlayToPlayer(self.Owner, Info.LaunchSound);
|
||||
|
||||
w.Add(new SatelliteLaunch(launchSite));
|
||||
w.Add(new SatelliteLaunch(self));
|
||||
w.Add(new DelayedAction((Info as GpsPowerInfo).RevealDelay * 25,
|
||||
() => Owner.Shroud.Disabled = true));
|
||||
() => self.Owner.Shroud.Disabled = true));
|
||||
});
|
||||
|
||||
FinishActivate();
|
||||
}
|
||||
}
|
||||
|
||||
// tag trait to identify the building
|
||||
class GpsLaunchSiteInfo : TraitInfo<GpsLaunchSite> { }
|
||||
class GpsLaunchSite { }
|
||||
}
|
||||
*/
|
||||
@@ -20,13 +20,15 @@ namespace OpenRA.Mods.RA
|
||||
public readonly string Image = null;
|
||||
public readonly string Description = "";
|
||||
public readonly string LongDesc = "";
|
||||
public readonly bool AllowMultiple = false;
|
||||
public readonly bool OneShot = false;
|
||||
|
||||
public readonly string OrderName;
|
||||
public readonly string BeginChargeSound = null;
|
||||
public readonly string EndChargeSound = null;
|
||||
public readonly string SelectTargetSound = null;
|
||||
public readonly string LaunchSound = null;
|
||||
public readonly bool AllowMultiple = false;
|
||||
|
||||
public readonly string OrderName;
|
||||
public abstract object Create(ActorInitializer init);
|
||||
|
||||
public SupportPowerInfo() { OrderName = GetType().Name + "Order"; }
|
||||
@@ -43,6 +45,16 @@ namespace OpenRA.Mods.RA
|
||||
this.self = self;
|
||||
}
|
||||
|
||||
public virtual void Charging(Actor self, string key)
|
||||
{
|
||||
Sound.PlayToPlayer(self.Owner, Info.BeginChargeSound);
|
||||
}
|
||||
|
||||
public virtual void Charged(Actor self, string key)
|
||||
{
|
||||
Sound.PlayToPlayer(self.Owner, Info.EndChargeSound);
|
||||
}
|
||||
|
||||
public virtual void Activate(Actor self, Order order) { }
|
||||
public virtual IOrderGenerator OrderGenerator(string order, SupportPowerManager manager)
|
||||
{
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace OpenRA.Mods.RA
|
||||
}
|
||||
else
|
||||
{
|
||||
var si = new SupportPowerInstance(this)
|
||||
var si = new SupportPowerInstance(key, this)
|
||||
{
|
||||
Instances = new List<SupportPower>() { t },
|
||||
RemainingTime = t.Info.ChargeTime * 25,
|
||||
@@ -91,38 +91,42 @@ namespace OpenRA.Mods.RA
|
||||
public void Target(string key)
|
||||
{
|
||||
if (Powers.ContainsKey(key))
|
||||
Powers[key].Target(key);
|
||||
Powers[key].Target();
|
||||
}
|
||||
|
||||
public class SupportPowerInstance
|
||||
{
|
||||
SupportPowerManager Manager;
|
||||
string Key;
|
||||
|
||||
public List<SupportPower> Instances;
|
||||
public int RemainingTime;
|
||||
public int TotalTime;
|
||||
public bool Active;
|
||||
public bool Disabled;
|
||||
|
||||
public SupportPowerInfo Info { get { return Instances.First().Info; } }
|
||||
public bool Ready { get { return Active && RemainingTime == 0; } }
|
||||
|
||||
public SupportPowerInstance(SupportPowerManager manager)
|
||||
public SupportPowerInstance(string key, SupportPowerManager manager)
|
||||
{
|
||||
Manager = manager;
|
||||
Key = key;
|
||||
}
|
||||
|
||||
bool notifiedCharging;
|
||||
bool notifiedReady;
|
||||
public void Tick()
|
||||
{
|
||||
Active = Instances.Any(i => !i.self.TraitsImplementing<IDisable>().Any(d => d.Disabled));
|
||||
Active = !Disabled && Instances.Any(i => !i.self.TraitsImplementing<IDisable>().Any(d => d.Disabled));
|
||||
var power = Instances.First();
|
||||
|
||||
if (Active)
|
||||
{
|
||||
if (RemainingTime > 0) --RemainingTime;
|
||||
if (!notifiedCharging)
|
||||
{
|
||||
Sound.PlayToPlayer(Instances.First().self.Owner, Info.BeginChargeSound);
|
||||
//instance.OnBeginCharging();
|
||||
power.Charging(power.self, Key);
|
||||
notifiedCharging = true;
|
||||
}
|
||||
}
|
||||
@@ -130,18 +134,17 @@ namespace OpenRA.Mods.RA
|
||||
if (RemainingTime == 0
|
||||
&& !notifiedReady)
|
||||
{
|
||||
Sound.PlayToPlayer(Instances.First().self.Owner, Info.EndChargeSound);
|
||||
//instance.FinishCharging();
|
||||
power.Charged(power.self, Key);
|
||||
notifiedReady = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void Target(string key)
|
||||
public void Target()
|
||||
{
|
||||
if (!Ready)
|
||||
return;
|
||||
|
||||
Manager.self.World.OrderGenerator = Instances.First().OrderGenerator(key, Manager);
|
||||
Manager.self.World.OrderGenerator = Instances.First().OrderGenerator(Key, Manager);
|
||||
}
|
||||
|
||||
public void Activate(Order order)
|
||||
@@ -154,6 +157,9 @@ namespace OpenRA.Mods.RA
|
||||
power.Activate(power.self, order);
|
||||
RemainingTime = TotalTime;
|
||||
notifiedCharging = notifiedReady = false;
|
||||
|
||||
if (Info.OneShot)
|
||||
Disabled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,7 +75,8 @@ namespace OpenRA.Mods.RA.Widgets
|
||||
if( world.LocalPlayer == null ) return;
|
||||
|
||||
var manager = world.LocalPlayer.PlayerActor.Trait<SupportPowerManager>();
|
||||
var numPowers = manager.Powers.Count;
|
||||
var powers = manager.Powers.Where(p => !p.Value.Disabled);
|
||||
var numPowers = powers.Count();
|
||||
if (numPowers == 0) return;
|
||||
|
||||
var rectBounds = RenderBounds;
|
||||
@@ -89,7 +90,7 @@ namespace OpenRA.Mods.RA.Widgets
|
||||
rectBounds.Height = 10 + numPowers * 51 + 21;
|
||||
|
||||
var y = rectBounds.Y + 10;
|
||||
foreach (var kv in manager.Powers)
|
||||
foreach (var kv in powers)
|
||||
{
|
||||
var sp = kv.Value;
|
||||
var image = spsprites[sp.Info.Image];
|
||||
|
||||
@@ -519,7 +519,15 @@ ATEK:
|
||||
Range: 10
|
||||
Bib:
|
||||
IronCurtainable:
|
||||
# GpsLaunchSite:
|
||||
GpsPower:
|
||||
Image: gpssicon
|
||||
OneShot: yes
|
||||
# ChargeTime: 480
|
||||
ChargeTime: 10
|
||||
Description: GPS Satellite
|
||||
LongDesc: Reveals the entire map
|
||||
RevealDelay: 15
|
||||
LaunchSound: satlnch1.aud
|
||||
|
||||
WEAP:
|
||||
Inherits: ^Building
|
||||
|
||||
@@ -25,15 +25,6 @@ Player:
|
||||
BuildSpeed: .4
|
||||
LowPowerSlowdown: 3
|
||||
PlaceBuilding:
|
||||
# GpsPower:
|
||||
# Image: gpssicon
|
||||
# OneShot: yes
|
||||
# ChargeTime: 8
|
||||
# Description: GPS Satellite
|
||||
# LongDesc: Reveals the entire map
|
||||
# Prerequisites: ATEK
|
||||
# RevealDelay: 15
|
||||
# LaunchSound: satlnch1.aud
|
||||
# IronCurtainPower:
|
||||
# Image: infxicon
|
||||
# ChargeTime: 2
|
||||
|
||||
Reference in New Issue
Block a user