Change crate graphics for christmas. Closes #4296.

This commit is contained in:
Paul Chote
2013-12-15 10:47:58 +13:00
parent f1372acf3f
commit e9e2e353f7
13 changed files with 140 additions and 8 deletions

View File

@@ -0,0 +1,47 @@
#region Copyright & License Information
/*
* Copyright 2007-2013 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;
using System.Linq;
using OpenRA.Graphics;
using OpenRA.Traits;
namespace OpenRA.Mods.RA.Render
{
class WithCrateBodyInfo : ITraitInfo, Requires<RenderSpritesInfo>
{
public readonly string[] Images = { "crate" };
public readonly string[] XmasImages = { };
public object Create(ActorInitializer init) { return new WithCrateBody(init.self, this); }
}
class WithCrateBody : INotifyParachuteLanded
{
Actor self;
Animation anim;
public WithCrateBody(Actor self, WithCrateBodyInfo info)
{
this.self = self;
var rs = self.Trait<RenderSprites>();
var images = info.XmasImages.Any() && DateTime.Today.Month == 12 ? info.XmasImages : info.Images;
anim = new Animation(images.Random(Game.CosmeticRandom));
anim.Play("idle");
rs.anims.Add("", anim);
}
public void OnLanded()
{
var seq = self.World.GetTerrainInfo(self.Location).IsWater ? "water" : "land";
anim.PlayRepeating(seq);
}
}
}