From 05f28bca230ef5da24e9e1e549136dbe7a29be99 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Thu, 8 Apr 2010 18:44:20 +1200 Subject: [PATCH] Arbitrary smudge types --- OpenRA.Game/Combat.cs | 5 ++++- OpenRA.Game/GameRules/WeaponInfo.cs | 11 ++--------- OpenRA.Game/Traits/World/SmudgeLayer.cs | 9 +++------ 3 files changed, 9 insertions(+), 16 deletions(-) diff --git a/OpenRA.Game/Combat.cs b/OpenRA.Game/Combat.cs index 78605b22ca..01fb78bee4 100644 --- a/OpenRA.Game/Combat.cs +++ b/OpenRA.Game/Combat.cs @@ -52,9 +52,12 @@ namespace OpenRA Sound.Play(GetImpactSound(warhead, isWater)); - if (warhead.SmudgeType != SmudgeType.None) + if (warhead.SmudgeType != null) { var smudgeLayer = world.WorldActor.traits.WithInterface().FirstOrDefault(x => x.Info.Type == warhead.SmudgeType); + if (smudgeLayer == null) + throw new NotImplementedException("Unknown smudge type `{0}`".F(warhead.SmudgeType)); + if (!isWater) smudgeLayer.AddSmudge(targetTile); } diff --git a/OpenRA.Game/GameRules/WeaponInfo.cs b/OpenRA.Game/GameRules/WeaponInfo.cs index 0fe697e518..cd257c81bf 100644 --- a/OpenRA.Game/GameRules/WeaponInfo.cs +++ b/OpenRA.Game/GameRules/WeaponInfo.cs @@ -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. * 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 Ore = false; // can this damage ore? 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 InfDeath = 0; // infantry death animation to use public readonly string ImpactSound = null; // sound to play on impact @@ -54,13 +54,6 @@ namespace OpenRA.GameRules concrete = 4, } - public enum SmudgeType - { - None = 0, - Crater = 1, - Scorch = 2, - } - public enum DamageModel { Normal, // classic RA damage model: point actors, distance-based falloff diff --git a/OpenRA.Game/Traits/World/SmudgeLayer.cs b/OpenRA.Game/Traits/World/SmudgeLayer.cs index a3d9f2797b..45c1a28f23 100644 --- a/OpenRA.Game/Traits/World/SmudgeLayer.cs +++ b/OpenRA.Game/Traits/World/SmudgeLayer.cs @@ -23,13 +23,12 @@ using System.Linq; using System.Drawing; using OpenRA.Graphics; using OpenRA.FileFormats; -using OpenRA.GameRules; namespace OpenRA.Traits { 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 int[] Depths = {1,1,1,1,1,1}; public object Create(Actor self) { return new SmudgeLayer(self, this); } @@ -39,12 +38,10 @@ namespace OpenRA.Traits { public SmudgeLayerInfo Info; SpriteRenderer spriteRenderer; - World world; - TileReference[,] tiles; Sprite[][] smudgeSprites; - string[] smudgeTypes; - + World world; + public SmudgeLayer(Actor self, SmudgeLayerInfo info) { spriteRenderer = new SpriteRenderer( Game.renderer, true );