Merge pull request #7974 from Mailaender/ts-hover-wakes

Added the Hovercraft wake animation
This commit is contained in:
Paul Chote
2015-04-26 18:50:42 +12:00
4 changed files with 63 additions and 0 deletions

View File

@@ -367,6 +367,7 @@
<Compile Include="Traits\ProximityCapturable.cs" />
<Compile Include="Traits\RadarColorFromTerrain.cs" />
<Compile Include="Traits\Render\Hovers.cs" />
<Compile Include="Traits\Render\LeavesTrails.cs" />
<Compile Include="Traits\Render\RenderBuilding.cs" />
<Compile Include="Traits\Render\RenderBuildingCharge.cs" />
<Compile Include="Traits\Render\RenderBuildingTurreted.cs" />

View File

@@ -0,0 +1,53 @@
#region Copyright & License Information
/*
* Copyright 2007-2015 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.Effects;
using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits
{
[Desc("Renders a sprite effect when leaving a cell.")]
public class LeavesTrailsInfo : ITraitInfo
{
public readonly string Image = null;
public readonly string Palette = "effect";
[Desc("Only do so when the terrain types match with the previous cell.")]
public readonly string[] TerrainTypes = { };
public object Create(ActorInitializer init) { return new LeavesTrails(this, init.Self); }
}
public class LeavesTrails : ITick
{
readonly LeavesTrailsInfo info;
public LeavesTrails(LeavesTrailsInfo info, Actor self)
{
this.info = info;
}
CPos cachedLocation;
public void Tick(Actor self)
{
if (cachedLocation != self.Location)
{
var type = self.World.Map.GetTerrainInfo(cachedLocation).Type;
var pos = self.World.Map.CenterOfCell(cachedLocation);
if (info.TerrainTypes.Contains(type) && !string.IsNullOrEmpty(info.Image))
self.World.AddFrameEndTask(w => w.Add(new SpriteEffect(pos, self.World, info.Image, info.Palette)));
cachedLocation = self.Location;
}
}
}
}

View File

@@ -69,6 +69,10 @@ HVR:
WithVoxelBody:
WithVoxelTurret:
Hovers:
LeavesTrails:
Image: wake
Palette: effect
TerrainTypes: Water
SMECH:
Inherits: ^Tank

View File

@@ -226,6 +226,11 @@ moveflsh:
Length: *
Tick: 30
wake:
idle: wake2
Length: *
Tick: 180
resources:
Defaults:
UseTilesetExtension: true