make C4 Demolition frozen actor aware
This commit is contained in:
@@ -83,11 +83,14 @@ namespace OpenRA.Traits
|
|||||||
public interface ISeedableResource { void Seed(Actor self); }
|
public interface ISeedableResource { void Seed(Actor self); }
|
||||||
|
|
||||||
public interface IAcceptInfiltrator { void OnInfiltrate(Actor self, Actor infiltrator); }
|
public interface IAcceptInfiltrator { void OnInfiltrate(Actor self, Actor infiltrator); }
|
||||||
|
|
||||||
|
public interface IDemolishableInfo { bool IsValidTarget(ActorInfo actorInfo, Actor saboteur); }
|
||||||
public interface IDemolishable
|
public interface IDemolishable
|
||||||
{
|
{
|
||||||
void Demolish(Actor self, Actor saboteur);
|
void Demolish(Actor self, Actor saboteur);
|
||||||
bool IsValidTarget(Actor self, Actor saboteur);
|
bool IsValidTarget(Actor self, Actor saboteur);
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface IStoreOre { int Capacity { get; } }
|
public interface IStoreOre { int Capacity { get; } }
|
||||||
public interface INotifyDocking { void Docked(Actor self, Actor harvester); void Undocked(Actor self, Actor harvester); }
|
public interface INotifyDocking { void Docked(Actor self, Actor harvester); void Undocked(Actor self, Actor harvester); }
|
||||||
public interface IEffectiveOwner
|
public interface IEffectiveOwner
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#region Copyright & License Information
|
#region Copyright & License Information
|
||||||
/*
|
/*
|
||||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
* Copyright 2007-2014 The OpenRA Developers (see AUTHORS)
|
||||||
* This file is part of OpenRA, which is free software. It is made
|
* 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
|
* available to you under the terms of the GNU General Public License
|
||||||
* as published by the Free Software Foundation. For more information,
|
* as published by the Free Software Foundation. For more information,
|
||||||
@@ -12,8 +12,10 @@ using OpenRA.Traits;
|
|||||||
|
|
||||||
namespace OpenRA.Mods.RA
|
namespace OpenRA.Mods.RA
|
||||||
{
|
{
|
||||||
class BridgeHutInfo : ITraitInfo
|
class BridgeHutInfo : IDemolishableInfo, ITraitInfo
|
||||||
{
|
{
|
||||||
|
public bool IsValidTarget(ActorInfo actorInfo, Actor saboteur) { return false; } // TODO: bridges don't support frozen under fog
|
||||||
|
|
||||||
public object Create(ActorInitializer init) { return new BridgeHut(init); }
|
public object Create(ActorInitializer init) { return new BridgeHut(init); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#region Copyright & License Information
|
#region Copyright & License Information
|
||||||
/*
|
/*
|
||||||
* Copyright 2007-2013 The OpenRA Developers (see AUTHORS)
|
* Copyright 2007-2014 The OpenRA Developers (see AUTHORS)
|
||||||
* This file is part of OpenRA, which is free software. It is made
|
* 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
|
* available to you under the terms of the GNU General Public License
|
||||||
* as published by the Free Software Foundation. For more information,
|
* as published by the Free Software Foundation. For more information,
|
||||||
@@ -14,7 +14,12 @@ using OpenRA.FileFormats;
|
|||||||
namespace OpenRA.Mods.RA
|
namespace OpenRA.Mods.RA
|
||||||
{
|
{
|
||||||
[Desc("Handle demolitions from C4 explosives.")]
|
[Desc("Handle demolitions from C4 explosives.")]
|
||||||
public class DemolishableInfo : TraitInfo<Demolishable> { }
|
public class DemolishableInfo : IDemolishableInfo, ITraitInfo
|
||||||
|
{
|
||||||
|
public bool IsValidTarget(ActorInfo actorInfo, Actor saboteur) { return true; }
|
||||||
|
|
||||||
|
public object Create(ActorInitializer init) { return new Demolishable(); }
|
||||||
|
}
|
||||||
|
|
||||||
public class Demolishable : IDemolishable
|
public class Demolishable : IDemolishable
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#region Copyright & License Information
|
#region Copyright & License Information
|
||||||
/*
|
/*
|
||||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
* Copyright 2007-2014 The OpenRA Developers (see AUTHORS)
|
||||||
* This file is part of OpenRA, which is free software. It is made
|
* 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
|
* available to you under the terms of the GNU General Public License
|
||||||
* as published by the Free Software Foundation. For more information,
|
* as published by the Free Software Foundation. For more information,
|
||||||
@@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
using OpenRA.Mods.RA.Activities;
|
using OpenRA.Mods.RA.Activities;
|
||||||
using OpenRA.Mods.RA.Orders;
|
using OpenRA.Mods.RA.Orders;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
@@ -19,6 +20,7 @@ namespace OpenRA.Mods.RA
|
|||||||
class C4DemolitionInfo : ITraitInfo
|
class C4DemolitionInfo : ITraitInfo
|
||||||
{
|
{
|
||||||
public readonly int C4Delay = 45; // 1.8 seconds
|
public readonly int C4Delay = 45; // 1.8 seconds
|
||||||
|
|
||||||
public object Create(ActorInitializer init) { return new C4Demolition(this); }
|
public object Create(ActorInitializer init) { return new C4Demolition(this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,20 +85,12 @@ namespace OpenRA.Mods.RA
|
|||||||
if (modifiers.HasModifier(TargetModifiers.ForceMove))
|
if (modifiers.HasModifier(TargetModifiers.ForceMove))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
var demolishable = target.TraitOrDefault<IDemolishable>();
|
return target.TraitsImplementing<IDemolishable>().Any(i => i.IsValidTarget(target, self));
|
||||||
if (demolishable == null || !demolishable.IsValidTarget(target, self))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool CanTargetFrozenActor(Actor self, FrozenActor target, TargetModifiers modifiers, ref string cursor)
|
public override bool CanTargetFrozenActor(Actor self, FrozenActor target, TargetModifiers modifiers, ref string cursor)
|
||||||
{
|
{
|
||||||
// TODO: Bridges don't yet support FrozenUnderFog.
|
return target.Info.Traits.WithInterface<IDemolishableInfo>().Any(i => i.IsValidTarget(target.Info, self));
|
||||||
if (target.Actor != null && target.Actor.HasTrait<BridgeHut>())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user