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