Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ShakeOnDeath and remove hardcoded screen shaking from bridges #15108

Merged
merged 4 commits into from
May 6, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions OpenRA.Mods.Common/OpenRA.Mods.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,8 @@
<Compile Include="Traits\World\WeatherOverlay.cs" />
<Compile Include="Traits\World\ActorSpawnManager.cs" />
<Compile Include="Traits\ActorSpawner.cs" />
<Compile Include="UpdateRules\Rules\ChangeIntensityToDuration.cs" />
<Compile Include="UpdateRules\Rules\AddShakeToBridge.cs" />
<Compile Include="UpdateRules\Rules\IgnoreAbstractActors.cs" />
<Compile Include="UtilityCommands\CheckYaml.cs" />
<Compile Include="UtilityCommands\ConvertPngToShpCommand.cs" />
Expand Down
1 change: 0 additions & 1 deletion OpenRA.Mods.Common/Traits/Buildings/Bridge.cs
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,6 @@ public void Demolish(Actor saboteur, int direction)
// Use .FromPos since this actor is killed. Cannot use Target.FromActor
info.DemolishWeaponInfo.Impact(Target.FromPos(self.CenterPosition), saboteur, Enumerable.Empty<int>());

self.World.WorldActor.Trait<ScreenShaker>().AddEffect(15, self.CenterPosition, 6);
self.Kill(saboteur);
});

Expand Down
1 change: 0 additions & 1 deletion OpenRA.Mods.Common/Traits/Buildings/GroundLevelBridge.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ void IBridgeSegment.Demolish(Actor saboteur)
// Use .FromPos since this actor is dead. Cannot use Target.FromActor
Info.DemolishWeaponInfo.Impact(Target.FromPos(self.CenterPosition), saboteur, Enumerable.Empty<int>());

self.World.WorldActor.Trait<ScreenShaker>().AddEffect(15, self.CenterPosition, 6);
self.Kill(saboteur);
});
}
Expand Down
5 changes: 3 additions & 2 deletions OpenRA.Mods.Common/Traits/ShakeOnDeath.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ namespace OpenRA.Mods.Common.Traits
{
public class ShakeOnDeathInfo : ITraitInfo
{
public readonly int Intensity = 10;
public readonly int Duration = 10;
public readonly int Intensity = 1;
public object Create(ActorInitializer init) { return new ShakeOnDeath(this); }
}

Expand All @@ -30,7 +31,7 @@ public ShakeOnDeath(ShakeOnDeathInfo info)

void INotifyKilled.Killed(Actor self, AttackInfo e)
{
self.World.WorldActor.Trait<ScreenShaker>().AddEffect(info.Intensity, self.CenterPosition, 1);
self.World.WorldActor.Trait<ScreenShaker>().AddEffect(info.Duration, self.CenterPosition, info.Intensity);
}
}
}
47 changes: 47 additions & 0 deletions OpenRA.Mods.Common/UpdateRules/Rules/AddShakeToBridge.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#region Copyright & License Information
/*
* Copyright 2007-2018 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.Collections.Generic;
using System.Linq;

namespace OpenRA.Mods.Common.UpdateRules.Rules
{
public class AddShakeToBridge : UpdateRule
{
public override string Name { get { return "Screen shaking was removed from dying bridges."; } }
public override string Description
{
get
{
return "'Bridges' (and 'GroundLevelBridges') no longer shake the screen on their own.\n" +
"The 'ShakeOnDeath' trait is to be used instead.";
}
}

public override IEnumerable<string> UpdateActorNode(ModData modData, MiniYamlNode actorNode)
{
if (actorNode.ChildrenMatching("Bridge").Any())
AddShakeNode(actorNode);
else if (actorNode.ChildrenMatching("GroundLevelBridge").Any())
AddShakeNode(actorNode);

yield break;
}

void AddShakeNode(MiniYamlNode actorNode)
{
var shake = new MiniYamlNode("ShakeOnDeath", "");
shake.AddNode("Duration", "15");
shake.AddNode("Intensity", "6");
actorNode.AddNode(shake);
}
}
}
44 changes: 44 additions & 0 deletions OpenRA.Mods.Common/UpdateRules/Rules/ChangeIntensityToDuration.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#region Copyright & License Information
/*
* Copyright 2007-2018 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.Collections.Generic;

namespace OpenRA.Mods.Common.UpdateRules.Rules
{
public class ChangeIntensityToDuration : UpdateRule
{
public override string Name { get { return "Add a 'Duration' parameter to 'ShakeOnDeath'."; } }
public override string Description
{
get
{
return "The 'Intensity' parameter on 'ShakeOnDeath' has been used as duration\n" +
"by accident. A new 'Duration' parameter was added to fix that.\n" +
"Definitions of 'Intensity' will be automatically renamed to 'Duration'.\n" +
"The old 'Intensity' parameter will now change the intensity as intended.";
}
}

public override IEnumerable<string> UpdateActorNode(ModData modData, MiniYamlNode actorNode)
{
foreach (var sod in actorNode.ChildrenMatching("ShakeOnDeath"))
{
var intensity = sod.LastChildMatching("Intensity");
if (intensity == null)
continue;

intensity.RenameKeyPreservingSuffix("Duration");
}

yield break;
}
}
}
2 changes: 2 additions & 0 deletions OpenRA.Mods.Common/UpdateRules/UpdatePath.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ public class UpdatePath
new DefineSoundDefaults(),
new RenameWormSpawner(),
new RemoveWithReloadingSpriteTurret(),
new ChangeIntensityToDuration(),
new IgnoreAbstractActors(),
new AddShakeToBridge(),
new AddEditorPlayer(),
new RemovePaletteFromCurrentTileset(),
new DefineLocomotors()
Expand Down
3 changes: 3 additions & 0 deletions mods/cnc/rules/defaults.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -977,6 +977,9 @@
ScriptTriggers:
BodyOrientation:
QuantizedFacings: 1
ShakeOnDeath:
Duration: 15
Intensity: 6

^Crate:
Inherits@1: ^SpriteActor
Expand Down
3 changes: 3 additions & 0 deletions mods/ra/rules/defaults.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -939,6 +939,9 @@
QuantizedFacings: 1
Interactable:
Bounds: 96,48
ShakeOnDeath:
Duration: 15
Intensity: 6

^Rock:
Inherits@1: ^SpriteActor
Expand Down
6 changes: 6 additions & 0 deletions mods/ts/rules/bridges.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ LOBRDG_A:
ADestroyedSequences: adead
BDestroyedSequences: bdead
ABDestroyedSequences: abdead
ShakeOnDeath:
Duration: 15
Intensity: 6

LOBRDG_A_D:
Inherits: LOBRDG_A
Expand Down Expand Up @@ -99,6 +102,9 @@ LOBRDG_B:
ADestroyedSequences: adead
BDestroyedSequences: bdead
ABDestroyedSequences: abdead
ShakeOnDeath:
Duration: 15
Intensity: 6

LOBRDG_B_D:
Inherits: LOBRDG_B
Expand Down