RMBO voices on build and kill.

This commit is contained in:
Paul Chote
2011-03-25 19:46:09 +13:00
parent a14968810c
commit ea626d4b39
6 changed files with 68 additions and 15 deletions

View File

@@ -87,9 +87,7 @@ namespace OpenRA.Traits
damage = (int)(damage * modifier); damage = (int)(damage * modifier);
hp -= damage; hp -= damage;
var ai = new AttackInfo
foreach (var nd in self.TraitsImplementing<INotifyDamage>().Concat(self.Owner.PlayerActor.TraitsImplementing<INotifyDamage>()))
nd.Damaged(self, new AttackInfo
{ {
Attacker = attacker, Attacker = attacker,
Damage = damage, Damage = damage,
@@ -99,7 +97,16 @@ namespace OpenRA.Traits
Warhead = warhead, Warhead = warhead,
PreviousHealth = hp + damage < 0 ? 0 : hp + damage, PreviousHealth = hp + damage < 0 ? 0 : hp + damage,
Health = hp Health = hp
}); };
foreach (var nd in self.TraitsImplementing<INotifyDamage>()
.Concat(self.Owner.PlayerActor.TraitsImplementing<INotifyDamage>()))
nd.Damaged(self, ai);
if (attacker != null && attacker.IsInWorld && !attacker.IsDead())
foreach (var nd in attacker.TraitsImplementing<INotifyAppliedDamage>()
.Concat(attacker.Owner.PlayerActor.TraitsImplementing<INotifyAppliedDamage>()))
nd.AppliedDamage(attacker, self, ai);
if (hp <= 0) if (hp <= 0)
{ {

View File

@@ -58,6 +58,7 @@ namespace OpenRA.Traits
public interface ICustomUnitOrderGenerator : IOrderGenerator {}; public interface ICustomUnitOrderGenerator : IOrderGenerator {};
public interface INotifySold { void Selling( Actor self ); void Sold( Actor self ); } public interface INotifySold { void Selling( Actor self ); void Sold( Actor self ); }
public interface INotifyDamage { void Damaged(Actor self, AttackInfo e); } public interface INotifyDamage { void Damaged(Actor self, AttackInfo e); }
public interface INotifyAppliedDamage { void AppliedDamage(Actor self, Actor damaged, AttackInfo e); }
public interface INotifyBuildComplete { void BuildingComplete(Actor self); } public interface INotifyBuildComplete { void BuildingComplete(Actor self); }
public interface INotifyProduction { void UnitProduced(Actor self, Actor other, int2 exit); } public interface INotifyProduction { void UnitProduced(Actor self, Actor other, int2 exit); }
public interface INotifyCapture { void OnCapture(Actor self, Actor captor, Player oldOwner, Player newOwner); } public interface INotifyCapture { void OnCapture(Actor self, Actor captor, Player oldOwner, Player newOwner); }

View File

@@ -0,0 +1,42 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 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.Drawing;
using OpenRA.Effects;
using OpenRA.Mods.RA.Move;
using OpenRA.Traits;
using OpenRA.Traits.Activities;
namespace OpenRA.Mods.RA
{
public class AnnounceOnBuildInfo : ITraitInfo
{
public object Create(ActorInitializer init) { return new AnnounceOnBuild(init.self); }
}
public class AnnounceOnBuild
{
public AnnounceOnBuild(Actor self)
{
Sound.PlayVoice("Build", self, self.Owner.Country.Race);
}
}
public class AnnounceOnKillInfo : TraitInfo<AnnounceOnKill> {}
public class AnnounceOnKill : INotifyAppliedDamage
{
public void AppliedDamage(Actor self, Actor damaged, AttackInfo e)
{
if (e.DamageState == DamageState.Dead)
Sound.PlayVoice("Kill", self, self.Owner.Country.Race);
}
}
}

View File

@@ -333,6 +333,7 @@
<Compile Include="Render\WithRotor.cs" /> <Compile Include="Render\WithRotor.cs" />
<Compile Include="Render\WithMuzzleFlash.cs" /> <Compile Include="Render\WithMuzzleFlash.cs" />
<Compile Include="Render\WithShadow.cs" /> <Compile Include="Render\WithShadow.cs" />
<Compile Include="AnnounceOnBuild.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj"> <ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj">

View File

@@ -180,3 +180,5 @@ RMBO:
PrimaryWeapon: Sniper PrimaryWeapon: Sniper
RenderInfantryProne: RenderInfantryProne:
IdleAnimations: idle1,idle2,idle3 IdleAnimations: idle1,idle2,idle3
AnnounceOnBuild:
AnnounceOnKill:

View File

@@ -30,7 +30,7 @@ CivilianFemaleVoice:
CommandoVoice: CommandoVoice:
Voices: Voices:
Select: rokroll1,yeah1,yes1,yo1 Select: yeah1,yes1,yo1
Move: cmon1,onit1,gotit1 Move: cmon1,onit1,gotit1
Attack: onit1,gotit1 Attack: onit1,gotit1
Demolish: bombit1 Demolish: bombit1