Revamp cloak model
This commit is contained in:
@@ -15,33 +15,8 @@ namespace OpenRA.Mods.RA
|
||||
{
|
||||
class DetectCloakedInfo : TraitInfo<DetectCloaked>
|
||||
{
|
||||
public readonly int Interval = 12; // ~.5s
|
||||
public readonly float DecloakTime = 2f; // 2s
|
||||
public readonly int Range = 5;
|
||||
public readonly bool AffectOwnUnits = true;
|
||||
}
|
||||
|
||||
class DetectCloaked : ITick
|
||||
{
|
||||
[Sync]
|
||||
int ticks;
|
||||
|
||||
public void Tick(Actor self)
|
||||
{
|
||||
if (--ticks <= 0)
|
||||
{
|
||||
var info = self.Info.Traits.Get<DetectCloakedInfo>();
|
||||
ticks = info.Interval;
|
||||
|
||||
var toDecloak = self.World.FindUnitsInCircle(self.CenterLocation, info.Range * Game.CellSize)
|
||||
.Where(a => a.HasTrait<Cloak>());
|
||||
|
||||
if (!info.AffectOwnUnits)
|
||||
toDecloak = toDecloak.Where(a => self.Owner.Stances[a.Owner] != Stance.Ally);
|
||||
|
||||
foreach (var a in toDecloak)
|
||||
a.Trait<Cloak>().Decloak((int)(25 * info.DecloakTime));
|
||||
}
|
||||
}
|
||||
}
|
||||
class DetectCloaked {}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user