Arbitrary smudge types

This commit is contained in:
Paul Chote
2010-04-08 18:44:20 +12:00
committed by Bob
parent 916706fa75
commit 05f28bca23
3 changed files with 9 additions and 16 deletions

View File

@@ -52,9 +52,12 @@ namespace OpenRA
Sound.Play(GetImpactSound(warhead, isWater)); Sound.Play(GetImpactSound(warhead, isWater));
if (warhead.SmudgeType != SmudgeType.None) if (warhead.SmudgeType != null)
{ {
var smudgeLayer = world.WorldActor.traits.WithInterface<SmudgeLayer>().FirstOrDefault(x => x.Info.Type == warhead.SmudgeType); var smudgeLayer = world.WorldActor.traits.WithInterface<SmudgeLayer>().FirstOrDefault(x => x.Info.Type == warhead.SmudgeType);
if (smudgeLayer == null)
throw new NotImplementedException("Unknown smudge type `{0}`".F(warhead.SmudgeType));
if (!isWater) if (!isWater)
smudgeLayer.AddSmudge(targetTile); smudgeLayer.AddSmudge(targetTile);
} }

View File

@@ -1,4 +1,4 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford. * Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
* This file is part of OpenRA. * This file is part of OpenRA.
@@ -33,7 +33,7 @@ namespace OpenRA.GameRules
public readonly bool Wood = false; // can this damage wood? public readonly bool Wood = false; // can this damage wood?
public readonly bool Ore = false; // can this damage ore? public readonly bool Ore = false; // can this damage ore?
public readonly int Explosion = 0; // explosion effect to use public readonly int Explosion = 0; // explosion effect to use
public readonly SmudgeType SmudgeType = SmudgeType.None; // type of smudge to apply public readonly string SmudgeType = null; // type of smudge to apply
public readonly int[] Size = { 0, 0 }; // size of the explosion. provide 2 values for a ring effect (outer/inner) public readonly int[] Size = { 0, 0 }; // size of the explosion. provide 2 values for a ring effect (outer/inner)
public readonly int InfDeath = 0; // infantry death animation to use public readonly int InfDeath = 0; // infantry death animation to use
public readonly string ImpactSound = null; // sound to play on impact public readonly string ImpactSound = null; // sound to play on impact
@@ -54,13 +54,6 @@ namespace OpenRA.GameRules
concrete = 4, concrete = 4,
} }
public enum SmudgeType
{
None = 0,
Crater = 1,
Scorch = 2,
}
public enum DamageModel public enum DamageModel
{ {
Normal, // classic RA damage model: point actors, distance-based falloff Normal, // classic RA damage model: point actors, distance-based falloff

View File

@@ -23,13 +23,12 @@ using System.Linq;
using System.Drawing; using System.Drawing;
using OpenRA.Graphics; using OpenRA.Graphics;
using OpenRA.FileFormats; using OpenRA.FileFormats;
using OpenRA.GameRules;
namespace OpenRA.Traits namespace OpenRA.Traits
{ {
class SmudgeLayerInfo : ITraitInfo class SmudgeLayerInfo : ITraitInfo
{ {
public readonly SmudgeType Type = SmudgeType.Scorch; public readonly string Type = "Scorch";
public readonly string[] Types = {"sc1", "sc2", "sc3", "sc4", "sc5", "sc6"}; public readonly string[] Types = {"sc1", "sc2", "sc3", "sc4", "sc5", "sc6"};
public readonly int[] Depths = {1,1,1,1,1,1}; public readonly int[] Depths = {1,1,1,1,1,1};
public object Create(Actor self) { return new SmudgeLayer(self, this); } public object Create(Actor self) { return new SmudgeLayer(self, this); }
@@ -39,12 +38,10 @@ namespace OpenRA.Traits
{ {
public SmudgeLayerInfo Info; public SmudgeLayerInfo Info;
SpriteRenderer spriteRenderer; SpriteRenderer spriteRenderer;
World world;
TileReference<byte,byte>[,] tiles; TileReference<byte,byte>[,] tiles;
Sprite[][] smudgeSprites; Sprite[][] smudgeSprites;
string[] smudgeTypes; World world;
public SmudgeLayer(Actor self, SmudgeLayerInfo info) public SmudgeLayer(Actor self, SmudgeLayerInfo info)
{ {
spriteRenderer = new SpriteRenderer( Game.renderer, true ); spriteRenderer = new SpriteRenderer( Game.renderer, true );