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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
@@ -326,6 +326,8 @@
|
||||
<Compile Include="AttackMedic.cs" />
|
||||
<Compile Include="Activities\Heal.cs" />
|
||||
<Compile Include="SupportPowers\SupportPowerManager.cs" />
|
||||
<Compile Include="Buildings\ShakeOnDeath.cs" />
|
||||
<Compile Include="Buildings\SoundOnDamageTransition.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj">
|
||||
|
||||
@@ -107,10 +107,7 @@ namespace OpenRA.Mods.RA.Render
|
||||
self.World.AddFrameEndTask(w => w.Add(new Explosion(w, Traits.Util.CenterOfCell(cell), "building", false, 0)));
|
||||
}
|
||||
else if (e.DamageState >= DamageState.Heavy && e.PreviousDamageState < DamageState.Heavy)
|
||||
{
|
||||
anim.ReplaceAnim("damaged-idle");
|
||||
Sound.Play(self.Info.Traits.Get<BuildingInfo>().DamagedSound, self.CenterLocation);
|
||||
}
|
||||
else if (e.DamageState < DamageState.Heavy)
|
||||
anim.ReplaceAnim("idle");
|
||||
}
|
||||
|
||||
@@ -35,10 +35,7 @@ namespace OpenRA.Mods.RA.Render
|
||||
if (!e.DamageStateChanged) return;
|
||||
|
||||
if (e.DamageState >= DamageState.Heavy && e.PreviousDamageState < DamageState.Heavy)
|
||||
{
|
||||
anim.ReplaceAnim("damaged-idle");
|
||||
Sound.Play(self.Info.Traits.Get<BuildingInfo>().DamagedSound, self.CenterLocation);
|
||||
}
|
||||
else if (e.DamageState < DamageState.Heavy)
|
||||
anim.ReplaceAnim("idle");
|
||||
}
|
||||
|
||||
@@ -35,24 +35,14 @@ namespace OpenRA.Mods.RA.Render
|
||||
{
|
||||
if (!e.DamageStateChanged) return;
|
||||
|
||||
var bi = self.Info.Traits.Get<BuildingInfo>();
|
||||
|
||||
if (e.DamageState == DamageState.Medium && anim.HasSequence("scratched-idle"))
|
||||
seqName = "scratched-idle";
|
||||
else if (e.DamageState <= DamageState.Medium)
|
||||
seqName = "idle";
|
||||
else if (e.DamageState == DamageState.Critical && anim.HasSequence("critical-idle"))
|
||||
{
|
||||
seqName = "critical-idle";
|
||||
if (e.DamageState > e.PreviousDamageState)
|
||||
Sound.Play(bi.DamagedSound, self.CenterLocation);
|
||||
}
|
||||
else if (e.DamageState <= DamageState.Critical)
|
||||
{
|
||||
seqName = "damaged-idle";
|
||||
if (e.DamageState > e.PreviousDamageState)
|
||||
Sound.Play(bi.DamagedSound, self.CenterLocation);
|
||||
}
|
||||
|
||||
anim.PlayFetchIndex(seqName, () => adjacentWalls);
|
||||
}
|
||||
|
||||
BIN
mods/cnc/bits/sandbag2.aud
Normal file
BIN
mods/cnc/bits/sandbag2.aud
Normal file
Binary file not shown.
@@ -187,6 +187,7 @@
|
||||
Footprint: x
|
||||
BuildSounds: constru2.aud, hvydoor1.aud
|
||||
SellSounds: cashturn.aud
|
||||
SoundOnDamageTransition:
|
||||
DamagedSound: xplos.aud
|
||||
DestroyedSound: xplobig4.aud
|
||||
Buildable:
|
||||
@@ -208,6 +209,7 @@
|
||||
Notification: strclost.aud
|
||||
EditorAppearance:
|
||||
RelativeToTopLeft: yes
|
||||
ShakeOnDeath:
|
||||
|
||||
^CivBuilding:
|
||||
Inherits: ^Building
|
||||
@@ -243,8 +245,6 @@
|
||||
BuildSounds: hvydoor1.aud
|
||||
Capturable: false
|
||||
BaseNormal: no
|
||||
DamagedSound:
|
||||
DestroyedSound:
|
||||
Adjacent: 7
|
||||
TargetableBuilding:
|
||||
TargetTypes: Ground
|
||||
@@ -311,8 +311,9 @@
|
||||
BelowUnits:
|
||||
Health:
|
||||
HP: 1000
|
||||
Building:
|
||||
SoundOnDamageTransition:
|
||||
DamagedSound: xplos.aud
|
||||
DestroyedSound: xplobig4.aud
|
||||
Building:
|
||||
Footprint: ______ ______ ______ ______
|
||||
Dimensions: 6,4
|
||||
|
||||
@@ -569,8 +569,8 @@ BRIK:
|
||||
Type: Heavy
|
||||
Wall:
|
||||
CrushClasses: heavywall
|
||||
CrushSound:
|
||||
Building:
|
||||
-CrushSound:
|
||||
SoundOnDamageTransition:
|
||||
DestroyedSound: crumble.aud
|
||||
|
||||
GUN:
|
||||
|
||||
@@ -130,6 +130,9 @@
|
||||
Building:
|
||||
Dimensions: 1,1
|
||||
Footprint: x
|
||||
SoundOnDamageTransition:
|
||||
DamagedSound: kaboom1.aud
|
||||
DestroyedSound: kaboom22.aud
|
||||
RenderBuilding:
|
||||
RepairableBuilding:
|
||||
EmitInfantryOnSell:
|
||||
@@ -141,6 +144,7 @@
|
||||
Notification: strucap1.aud
|
||||
EditorAppearance:
|
||||
RelativeToTopLeft: yes
|
||||
ShakeOnDeath:
|
||||
|
||||
^Wall:
|
||||
AppearsOnRadar:
|
||||
@@ -150,9 +154,10 @@
|
||||
BuildSounds: placbldg.aud
|
||||
Capturable: false
|
||||
BaseNormal: no
|
||||
Adjacent: 7
|
||||
SoundOnDamageTransition:
|
||||
DamagedSound: sandbag2.aud
|
||||
DestroyedSound: sandbag2.aud
|
||||
Adjacent: 7
|
||||
Wall:
|
||||
CrushClasses: wall
|
||||
LineBuild:
|
||||
|
||||
@@ -1135,7 +1135,7 @@ BRIK:
|
||||
Tooltip:
|
||||
Name: Concrete Wall
|
||||
Description: Stop units and blocks enemy fire.
|
||||
Building:
|
||||
SoundOnDamageTransition:
|
||||
DamagedSound: crmble2.aud
|
||||
DestroyedSound: kaboom30.aud
|
||||
Health:
|
||||
|
||||
Reference in New Issue
Block a user