Mostly implemented Sonar Pulse
This commit is contained in:
30
OpenRa.Game/Traits/SonarPulsePower.cs
Normal file
30
OpenRa.Game/Traits/SonarPulsePower.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRa.Orders;
|
||||
|
||||
namespace OpenRa.Traits
|
||||
{
|
||||
public class SonarPulsePowerInfo : SupportPowerInfo
|
||||
{
|
||||
public override object Create(Actor self) { return new SonarPulsePower(self, this); }
|
||||
}
|
||||
|
||||
public class SonarPulsePower : SupportPower
|
||||
{
|
||||
public SonarPulsePower(Actor self, SonarPulsePowerInfo info) : base(self, info) { }
|
||||
|
||||
protected override void OnBeginCharging() { }
|
||||
protected override void OnFinishCharging() { Sound.Play("pulse1.aud"); }
|
||||
protected override void OnActivate()
|
||||
{
|
||||
// Question: Is this method synced? or does it have to go via an order?
|
||||
|
||||
// TODO: Reveal submarines
|
||||
|
||||
// Should this play for all players?
|
||||
Sound.Play("sonpulse.aud");
|
||||
FinishActivate();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,7 @@ using System.Text;
|
||||
|
||||
namespace OpenRa.Traits
|
||||
{
|
||||
abstract class SupportPowerInfo : ITraitInfo
|
||||
public abstract class SupportPowerInfo : ITraitInfo
|
||||
{
|
||||
public readonly bool RequiresPower = true;
|
||||
public readonly bool OneShot = false;
|
||||
@@ -20,7 +20,7 @@ namespace OpenRa.Traits
|
||||
public abstract object Create(Actor self);
|
||||
}
|
||||
|
||||
class SupportPower : ITick
|
||||
public class SupportPower : ITick
|
||||
{
|
||||
public readonly SupportPowerInfo Info;
|
||||
public int RemainingTime { get; private set; }
|
||||
@@ -58,7 +58,8 @@ namespace OpenRa.Traits
|
||||
}
|
||||
|
||||
// Do we have enough powered prerequisites?
|
||||
var isPowered = effectivePrereq.Any() && effectivePrereq.All(a => buildings[a].Any(b => !b.traits.Get<Building>().Disabled));
|
||||
// Hack in support for special powers without prereqs
|
||||
var isPowered = (Info.Prerequisites.Count() == 0) ? self.Owner.GetPowerState() == PowerState.Normal : effectivePrereq.Any() && effectivePrereq.All(a => buildings[a].Any(b => !b.traits.Get<Building>().Disabled));
|
||||
|
||||
if (IsAvailable && (!Info.RequiresPower || isPowered))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user