Idle animations for infantry. Enabled for cnc e3.
This commit is contained in:
@@ -157,6 +157,7 @@ namespace OpenRA.Traits
|
||||
// Couldn't find a cell
|
||||
return target;
|
||||
}
|
||||
|
||||
public void ResolveOrder(Actor self, Order order)
|
||||
{
|
||||
if (order.OrderString == "Move")
|
||||
|
||||
47
OpenRA.Mods.RA/Activities/IdleAnimation.cs
Normal file
47
OpenRA.Mods.RA/Activities/IdleAnimation.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2010 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 LICENSE.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using OpenRA.Traits;
|
||||
using OpenRA.Mods.RA.Render;
|
||||
|
||||
namespace OpenRA.Mods.RA.Activities
|
||||
{
|
||||
public class IdleAnimation : IActivity
|
||||
{
|
||||
string sequence;
|
||||
int delay;
|
||||
|
||||
public IdleAnimation(string sequence, int delay)
|
||||
{
|
||||
this.sequence = sequence;
|
||||
this.delay = delay;
|
||||
}
|
||||
|
||||
public IActivity NextActivity { get; set; }
|
||||
|
||||
bool active = true;
|
||||
public IActivity Tick(Actor self)
|
||||
{
|
||||
if (!active) return NextActivity;
|
||||
|
||||
if (delay > 0 && --delay == 0)
|
||||
self.Trait<RenderInfantry>().anim.PlayThen(sequence, () => active = false);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public void Cancel(Actor self)
|
||||
{
|
||||
active = false;
|
||||
NextActivity = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
44
OpenRA.Mods.RA/IdleAnimation.cs
Normal file
44
OpenRA.Mods.RA/IdleAnimation.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2010 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 LICENSE.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using OpenRA.GameRules;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA
|
||||
{
|
||||
class IdleAnimationInfo : ITraitInfo
|
||||
{
|
||||
public readonly int IdleWaitTicks = 50;
|
||||
public readonly string[] Animations = {};
|
||||
public object Create(ActorInitializer init) { return new IdleAnimation(this); }
|
||||
}
|
||||
|
||||
// infantry prone behavior
|
||||
class IdleAnimation : INotifyDamage, INotifyIdle
|
||||
{
|
||||
IdleAnimationInfo Info;
|
||||
public IdleAnimation(IdleAnimationInfo info)
|
||||
{
|
||||
Info = info;
|
||||
}
|
||||
|
||||
public void Damaged(Actor self, AttackInfo e)
|
||||
{
|
||||
if (self.GetCurrentActivity() is IdleAnimation)
|
||||
self.CancelActivity();
|
||||
}
|
||||
|
||||
public void Idle(Actor self)
|
||||
{
|
||||
self.QueueActivity(new Activities.IdleAnimation(Info.Animations.Random(Game.CosmeticRandom),
|
||||
Info.IdleWaitTicks));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
@@ -239,6 +239,8 @@
|
||||
<Compile Include="HackyAI.cs" />
|
||||
<Compile Include="RALoadScreen.cs" />
|
||||
<Compile Include="NullLoadScreen.cs" />
|
||||
<Compile Include="Activities\IdleAnimation.cs" />
|
||||
<Compile Include="IdleAnimation.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj">
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
using OpenRA.Mods.RA.Effects;
|
||||
using OpenRA.Traits;
|
||||
using OpenRA.Traits.Activities;
|
||||
using OpenRA.Mods.RA.Activities;
|
||||
|
||||
namespace OpenRA.Mods.RA.Render
|
||||
{
|
||||
@@ -66,10 +67,9 @@ namespace OpenRA.Mods.RA.Render
|
||||
{
|
||||
base.Tick(self);
|
||||
if (inAttack) return;
|
||||
if (self.GetCurrentActivity() is Activities.IdleAnimation) return;
|
||||
if (ChooseMoveAnim(self)) return;
|
||||
|
||||
/* todo: idle anims, etc */
|
||||
|
||||
if (IsProne(self))
|
||||
anim.PlayFetchIndex("crawl", () => 0); /* what a hack. */
|
||||
else
|
||||
|
||||
@@ -65,6 +65,8 @@ E3:
|
||||
PrimaryOffset: 0,0,0,-10
|
||||
FireDelay: 5
|
||||
TakeCover:
|
||||
IdleAnimation:
|
||||
Animations: idle1,idle2
|
||||
|
||||
E4:
|
||||
Inherits: ^Infantry
|
||||
|
||||
@@ -38,6 +38,8 @@
|
||||
<sequence name="shoot" start="64" length="8" facings="8" />
|
||||
<sequence name="crawl" start="144" length="4" facings="8" />
|
||||
<sequence name="prone-shoot" start="192" length="10" facings="8" />
|
||||
<sequence name="idle1" start="274" length="12" />
|
||||
<sequence name="idle2" start="289" length="14" />
|
||||
<sequence name="die1" start="397" length="9" />
|
||||
<sequence name="die2" start="406" length="8" />
|
||||
<sequence name="die3" start="414" length="8" />
|
||||
|
||||
Reference in New Issue
Block a user