Move damage sounds and shaking from Building/RenderBuilding into their own traits. Fix wall damage/death sounds under cnc.
This commit is contained in:
@@ -29,10 +29,9 @@ namespace OpenRA.Mods.RA.Buildings
|
||||
|
||||
public readonly string[] BuildSounds = {"placbldg.aud", "build5.aud"};
|
||||
public readonly string[] SellSounds = {"cashturn.aud"};
|
||||
public readonly string DamagedSound = "kaboom1.aud";
|
||||
public readonly string DestroyedSound = "kaboom22.aud";
|
||||
|
||||
public object Create(ActorInitializer init) { return new Building(init); }
|
||||
|
||||
public object Create(ActorInitializer init) { return new Building(init, this); }
|
||||
|
||||
public bool IsCloseEnoughToBase(World world, Player p, string buildingName, int2 topLeft)
|
||||
{
|
||||
@@ -73,11 +72,11 @@ namespace OpenRA.Mods.RA.Buildings
|
||||
|
||||
public int2 PxPosition { get { return ( 2 * topLeft + Info.Dimensions ) * Game.CellSize / 2; } }
|
||||
|
||||
public Building(ActorInitializer init)
|
||||
public Building(ActorInitializer init, BuildingInfo info)
|
||||
{
|
||||
this.self = init.self;
|
||||
this.topLeft = init.Get<LocationInit,int2>();
|
||||
this.Info = self.Info.Traits.Get<BuildingInfo>();
|
||||
this.Info = info;
|
||||
this.PlayerPower = init.self.Owner.PlayerActor.Trait<PowerManager>();
|
||||
}
|
||||
|
||||
@@ -95,12 +94,6 @@ namespace OpenRA.Mods.RA.Buildings
|
||||
// Power plants lose power with damage
|
||||
if (Info.Power > 0)
|
||||
PlayerPower.UpdateActor(self, GetPowerUsage());
|
||||
|
||||
if (e.DamageState == DamageState.Dead)
|
||||
{
|
||||
self.World.WorldActor.Trait<ScreenShaker>().AddEffect(10, self.CenterLocation, 1);
|
||||
Sound.Play(Info.DestroyedSound, self.CenterLocation);
|
||||
}
|
||||
}
|
||||
|
||||
public void ResolveOrder(Actor self, Order order)
|
||||
|
||||
38
OpenRA.Mods.RA/Buildings/ShakeOnDeath.cs
Normal file
38
OpenRA.Mods.RA/Buildings/ShakeOnDeath.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
#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 System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA.Buildings
|
||||
{
|
||||
public class ShakeOnDeathInfo : ITraitInfo
|
||||
{
|
||||
public readonly int Intensity = 10;
|
||||
public object Create(ActorInitializer init) { return new ShakeOnDeath(this); }
|
||||
}
|
||||
|
||||
public class ShakeOnDeath : INotifyDamage
|
||||
{
|
||||
readonly ShakeOnDeathInfo Info;
|
||||
public ShakeOnDeath(ShakeOnDeathInfo info)
|
||||
{
|
||||
this.Info = info;
|
||||
}
|
||||
|
||||
public void Damaged(Actor self, AttackInfo e)
|
||||
{
|
||||
if (e.DamageState == DamageState.Dead)
|
||||
self.World.WorldActor.Trait<ScreenShaker>().AddEffect(Info.Intensity, self.CenterLocation, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
48
OpenRA.Mods.RA/Buildings/SoundOnDamageTransition.cs
Normal file
48
OpenRA.Mods.RA/Buildings/SoundOnDamageTransition.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
#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 System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Mods.RA.Buildings;
|
||||
using OpenRA.Mods.RA.Effects;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA.Render
|
||||
{
|
||||
public class SoundOnDamageTransitionInfo : ITraitInfo
|
||||
{
|
||||
public readonly string DamagedSound;
|
||||
public readonly string DestroyedSound;
|
||||
|
||||
public object Create(ActorInitializer init) { return new SoundOnDamageTransition(this);}
|
||||
}
|
||||
|
||||
public class SoundOnDamageTransition : INotifyDamage
|
||||
{
|
||||
readonly SoundOnDamageTransitionInfo Info;
|
||||
public SoundOnDamageTransition( SoundOnDamageTransitionInfo info )
|
||||
{
|
||||
Info = info;
|
||||
}
|
||||
|
||||
public virtual void Damaged(Actor self, AttackInfo e)
|
||||
{
|
||||
if (!e.DamageStateChanged)
|
||||
return;
|
||||
|
||||
if (e.DamageState == DamageState.Dead)
|
||||
Sound.Play(Info.DestroyedSound, self.CenterLocation);
|
||||
else if (e.DamageState >= DamageState.Heavy && e.PreviousDamageState < DamageState.Heavy)
|
||||
Sound.Play(Info.DamagedSound, self.CenterLocation);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user