Moved AttackLeap to Mods.RA.Traits, moved AttackPopupTurreted to
Mods.Cnc.Traits
This commit is contained in:
@@ -1,53 +0,0 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2014 The OpenRA Developers (see AUTHORS)
|
||||
* 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
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using OpenRA.Activities;
|
||||
using OpenRA.Mods.RA.Activities;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA
|
||||
{
|
||||
[Desc("Dogs use this attack model.")]
|
||||
class AttackLeapInfo : AttackFrontalInfo
|
||||
{
|
||||
[Desc("Leap speed (in units/tick).")]
|
||||
public readonly WRange Speed = new WRange(426);
|
||||
public readonly WAngle Angle = WAngle.FromDegrees(20);
|
||||
|
||||
public override object Create(ActorInitializer init) { return new AttackLeap(init.self, this); }
|
||||
}
|
||||
|
||||
class AttackLeap : AttackFrontal, ISync
|
||||
{
|
||||
AttackLeapInfo info;
|
||||
|
||||
public AttackLeap(Actor self, AttackLeapInfo info)
|
||||
: base(self, info)
|
||||
{
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
public override void DoAttack(Actor self, Target target)
|
||||
{
|
||||
if (target.Type != TargetType.Actor || !CanAttack(self, target))
|
||||
return;
|
||||
|
||||
var a = ChooseArmamentForTarget(target);
|
||||
if (a == null)
|
||||
return;
|
||||
|
||||
if (!target.IsInRange(self.CenterPosition, a.Weapon.Range))
|
||||
return;
|
||||
|
||||
self.CancelActivity();
|
||||
self.QueueActivity(new Leap(self, target.Actor, a.Weapon, info.Speed, info.Angle));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,115 +0,0 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2014 The OpenRA Developers (see AUTHORS)
|
||||
* 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
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Linq;
|
||||
using OpenRA.Activities;
|
||||
using OpenRA.GameRules;
|
||||
using OpenRA.Mods.Common.Traits;
|
||||
using OpenRA.Mods.RA.Buildings;
|
||||
using OpenRA.Mods.RA.Render;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA
|
||||
{
|
||||
[Desc("Actor's turret rises from the ground before attacking.")]
|
||||
class AttackPopupTurretedInfo : AttackTurretedInfo, Requires<BuildingInfo>, Requires<RenderBuildingInfo>
|
||||
{
|
||||
[Desc("How many game ticks should pass before closing the actor's turret.")]
|
||||
public int CloseDelay = 125;
|
||||
public int DefaultFacing = 0;
|
||||
|
||||
[Desc("The percentage of damage that is received while this actor is closed.")]
|
||||
public int ClosedDamageMultiplier = 50;
|
||||
|
||||
public override object Create(ActorInitializer init) { return new AttackPopupTurreted(init, this); }
|
||||
}
|
||||
|
||||
class AttackPopupTurreted : AttackTurreted, INotifyBuildComplete, INotifyIdle, IDamageModifier
|
||||
{
|
||||
enum PopupState { Open, Rotating, Transitioning, Closed }
|
||||
|
||||
AttackPopupTurretedInfo info;
|
||||
RenderBuilding rb;
|
||||
|
||||
int idleTicks = 0;
|
||||
PopupState state = PopupState.Open;
|
||||
Turreted turret;
|
||||
bool skippedMakeAnimation;
|
||||
|
||||
public AttackPopupTurreted(ActorInitializer init, AttackPopupTurretedInfo info)
|
||||
: base(init.self, info)
|
||||
{
|
||||
this.info = info;
|
||||
turret = turrets.FirstOrDefault();
|
||||
rb = init.self.Trait<RenderBuilding>();
|
||||
skippedMakeAnimation = init.Contains<SkipMakeAnimsInit>();
|
||||
}
|
||||
|
||||
protected override bool CanAttack(Actor self, Target target)
|
||||
{
|
||||
if (state == PopupState.Transitioning || !building.Value.BuildComplete)
|
||||
return false;
|
||||
|
||||
if (!base.CanAttack(self, target))
|
||||
return false;
|
||||
|
||||
idleTicks = 0;
|
||||
if (state == PopupState.Closed)
|
||||
{
|
||||
state = PopupState.Transitioning;
|
||||
rb.PlayCustomAnimThen(self, "opening", () =>
|
||||
{
|
||||
state = PopupState.Open;
|
||||
rb.PlayCustomAnimRepeating(self, "idle");
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!turret.FaceTarget(self, target))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void TickIdle(Actor self)
|
||||
{
|
||||
if (state == PopupState.Open && idleTicks++ > info.CloseDelay)
|
||||
{
|
||||
turret.DesiredFacing = info.DefaultFacing;
|
||||
state = PopupState.Rotating;
|
||||
}
|
||||
else if (state == PopupState.Rotating && turret.TurretFacing == info.DefaultFacing)
|
||||
{
|
||||
state = PopupState.Transitioning;
|
||||
rb.PlayCustomAnimThen(self, "closing", () =>
|
||||
{
|
||||
state = PopupState.Closed;
|
||||
rb.PlayCustomAnimRepeating(self, "closed-idle");
|
||||
turret.DesiredFacing = null;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public void BuildingComplete(Actor self)
|
||||
{
|
||||
if (skippedMakeAnimation)
|
||||
{
|
||||
state = PopupState.Closed;
|
||||
rb.PlayCustomAnimRepeating(self, "closed-idle");
|
||||
turret.DesiredFacing = null;
|
||||
}
|
||||
}
|
||||
|
||||
public int GetDamageModifier(Actor attacker, DamageWarhead warhead)
|
||||
{
|
||||
return state == PopupState.Closed ? info.ClosedDamageMultiplier : 100;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,12 +15,12 @@ using OpenRA.Traits;
|
||||
namespace OpenRA.Mods.RA
|
||||
{
|
||||
[Desc("Actor has a visual turret used to attack.")]
|
||||
class AttackTurretedInfo : AttackFollowInfo, Requires<TurretedInfo>
|
||||
public class AttackTurretedInfo : AttackFollowInfo, Requires<TurretedInfo>
|
||||
{
|
||||
public override object Create(ActorInitializer init) { return new AttackTurreted(init.self, this); }
|
||||
}
|
||||
|
||||
class AttackTurreted : AttackFollow, ITick, ISync
|
||||
public class AttackTurreted : AttackFollow, ITick, ISync
|
||||
{
|
||||
protected IEnumerable<Turreted> turrets;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user