Add support for multiple (un)deploy sounds on GrantConditionOnDeploy

This commit is contained in:
abcdefg30
2019-03-02 18:40:24 +01:00
committed by Paul Chote
parent ab6ae7bc8d
commit 0ab7e0a855
7 changed files with 64 additions and 16 deletions

View File

@@ -597,6 +597,7 @@
<Compile Include="Traits\World\ActorSpawnManager.cs" />
<Compile Include="Traits\ActorSpawner.cs" />
<Compile Include="UpdateRules\Rules\20181215\MakeMobilePausableConditional.cs" />
<Compile Include="UpdateRules\Rules\20181215\MultipleDeploySounds.cs" />
<Compile Include="UpdateRules\Rules\20181215\RemoveAttackIgnoresVisibility.cs" />
<Compile Include="UpdateRules\Rules\20181215\RemoveAttackSuicides.cs" />
<Compile Include="UpdateRules\Rules\20181215\RemovedDemolishLocking.cs" />

View File

@@ -45,11 +45,11 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Facing that the actor must face before deploying. Set to -1 to deploy regardless of facing.")]
public readonly int Facing = -1;
[Desc("Sound to play when deploying.")]
public readonly string DeploySound = null;
[Desc("Play a randomly selected sound from this list when deploying.")]
public readonly string[] DeploySounds = null;
[Desc("Sound to play when undeploying.")]
public readonly string UndeploySound = null;
[Desc("Play a randomly selected sound from this list when undeploying.")]
public readonly string[] UndeploySounds = null;
[Desc("Skip make/deploy animation?")]
public readonly bool SkipMakeAnimation = false;
@@ -221,8 +221,8 @@ namespace OpenRA.Mods.Common.Traits
if (!IsValidTerrain(self.Location))
return;
if (!string.IsNullOrEmpty(Info.DeploySound))
Game.Sound.Play(SoundType.World, Info.DeploySound, self.CenterPosition);
if (Info.DeploySounds != null && Info.DeploySounds.Any())
Game.Sound.Play(SoundType.World, Info.DeploySounds.Random(self.World.LocalRandom), self.CenterPosition);
// Revoke condition that is applied while undeployed.
if (!init)
@@ -245,8 +245,8 @@ namespace OpenRA.Mods.Common.Traits
if (!init && deployState != DeployState.Deployed)
return;
if (!string.IsNullOrEmpty(Info.UndeploySound))
Game.Sound.Play(SoundType.World, Info.UndeploySound, self.CenterPosition);
if (Info.UndeploySounds != null && Info.UndeploySounds.Any())
Game.Sound.Play(SoundType.World, Info.UndeploySounds.Random(self.World.LocalRandom), self.CenterPosition);
if (!init)
OnUndeployStarted();

View File

@@ -0,0 +1,46 @@
#region Copyright & License Information
/*
* Copyright 2007-2019 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, either version 3 of
* the License, or (at your option) any later version. For more
* information, see COPYING.
*/
#endregion
using System;
using System.Collections.Generic;
namespace OpenRA.Mods.Common.UpdateRules.Rules
{
public class MultipleDeploySounds : UpdateRule
{
public override string Name { get { return "'GrantConditionOnDeploy' now supports multiple (un)deploy sounds"; } }
public override string Description
{
get
{
return "Renamed 'DeploySound' to 'DeploySounds' and 'UndeploySound' to 'UndeploySounds'\n" +
"on 'GrantConditionOnDeploy'.";
}
}
public override IEnumerable<string> UpdateActorNode(ModData modData, MiniYamlNode actorNode)
{
var grants = actorNode.ChildrenMatching("GrantConditionOnDeploy");
foreach (var g in grants)
{
var deploy = g.LastChildMatching("DeploySound");
if (deploy != null)
deploy.RenameKey("DeploySounds");
var undeploy = g.LastChildMatching("UndeploySound");
if (undeploy != null)
undeploy.RenameKey("UndeploySounds");
}
yield break;
}
}
}

View File

@@ -118,6 +118,7 @@ namespace OpenRA.Mods.Common.UpdateRules
{
// Bleed only changes here
new RemoveAttackSuicides(),
new MultipleDeploySounds(),
new MakeMobilePausableConditional(),
new StreamlineRepairableTraits(),
})

View File

@@ -349,8 +349,8 @@ JUGG:
UndeployedCondition: undeployed
Facing: 96
AllowedTerrainTypes: Clear, Road, DirtRoad, Rough
DeploySound: place2.aud
UndeploySound: clicky1.aud
DeploySounds: place2.aud
UndeploySounds: clicky1.aud
GrantCondition@PREVIEWWORKAROUND:
Condition: real-actor
QuantizeFacingsFromSequence:

View File

@@ -136,8 +136,8 @@ TTNK:
UndeployedCondition: undeployed
Facing: 160
AllowedTerrainTypes: Clear, Road, DirtRoad, Rough
DeploySound: place2.aud
UndeploySound: clicky1.aud
DeploySounds: place2.aud
UndeploySounds: clicky1.aud
GrantCondition@PREVIEWWORKAROUND:
Condition: real-actor
WithVoxelBody:
@@ -240,8 +240,8 @@ ART2:
UndeployedCondition: undeployed
Facing: 96
AllowedTerrainTypes: Clear, Road, DirtRoad, Rough
DeploySound: place2.aud
UndeploySound: clicky1.aud
DeploySounds: place2.aud
UndeploySounds: clicky1.aud
GrantCondition@PREVIEWWORKAROUND:
Condition: real-actor
WithVoxelBody:

View File

@@ -147,8 +147,8 @@ LPST:
UndeployedCondition: undeployed
Facing: 160
AllowedTerrainTypes: Clear, Road, DirtRoad, Rough
DeploySound: place2.aud
UndeploySound: clicky1.aud
DeploySounds: place2.aud
UndeploySounds: clicky1.aud
WithVoxelBody:
RequiresCondition: undeployed
WithSpriteBody@deployed: