Merge pull request #7483 from pchote/deadbuildingstate

Fix missing first animation frame and remove DeadBuildingState.
This commit is contained in:
Matthias Mailänder
2015-02-21 14:00:23 +01:00
11 changed files with 90 additions and 67 deletions

View File

@@ -79,6 +79,8 @@ namespace OpenRA.Graphics
backwards = false; backwards = false;
tickAlways = false; tickAlways = false;
CurrentSequence = sequenceProvider.GetSequence(name, sequenceName); CurrentSequence = sequenceProvider.GetSequence(name, sequenceName);
timeUntilNextFrame = CurrentSequence != null ? CurrentSequence.Tick : defaultTick;
frame = 0; frame = 0;
tickFunc = () => tickFunc = () =>
{ {
@@ -94,6 +96,8 @@ namespace OpenRA.Graphics
return false; return false;
CurrentSequence = sequenceProvider.GetSequence(name, sequenceName); CurrentSequence = sequenceProvider.GetSequence(name, sequenceName);
var tick = CurrentSequence != null ? CurrentSequence.Tick : defaultTick;
timeUntilNextFrame = Math.Min(tick, timeUntilNextFrame);
frame %= CurrentSequence.Length; frame %= CurrentSequence.Length;
return true; return true;
} }
@@ -103,6 +107,8 @@ namespace OpenRA.Graphics
backwards = false; backwards = false;
tickAlways = false; tickAlways = false;
CurrentSequence = sequenceProvider.GetSequence(name, sequenceName); CurrentSequence = sequenceProvider.GetSequence(name, sequenceName);
timeUntilNextFrame = CurrentSequence != null ? CurrentSequence.Tick : defaultTick;
frame = 0; frame = 0;
tickFunc = () => tickFunc = () =>
{ {
@@ -127,6 +133,8 @@ namespace OpenRA.Graphics
backwards = false; backwards = false;
tickAlways = true; tickAlways = true;
CurrentSequence = sequenceProvider.GetSequence(name, sequenceName); CurrentSequence = sequenceProvider.GetSequence(name, sequenceName);
timeUntilNextFrame = CurrentSequence != null ? CurrentSequence.Tick : defaultTick;
frame = func(); frame = func();
tickFunc = () => frame = func(); tickFunc = () => frame = func();
} }

View File

@@ -246,7 +246,6 @@
<Compile Include="Traits\Buildings\Building.cs" /> <Compile Include="Traits\Buildings\Building.cs" />
<Compile Include="Traits\Buildings\BuildingInfluence.cs" /> <Compile Include="Traits\Buildings\BuildingInfluence.cs" />
<Compile Include="Traits\Buildings\BuildingUtils.cs" /> <Compile Include="Traits\Buildings\BuildingUtils.cs" />
<Compile Include="Traits\Buildings\DeadBuildingState.cs" />
<Compile Include="Traits\Buildings\Exit.cs" /> <Compile Include="Traits\Buildings\Exit.cs" />
<Compile Include="Traits\Buildings\FootprintUtils.cs" /> <Compile Include="Traits\Buildings\FootprintUtils.cs" />
<Compile Include="Traits\Buildings\FreeActor.cs" /> <Compile Include="Traits\Buildings\FreeActor.cs" />

View File

@@ -1,50 +0,0 @@
#region Copyright & License Information
/*
* Copyright 2007-2015 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 OpenRA.Effects;
using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits
{
class DeadBuildingStateInfo : ITraitInfo, Requires<HealthInfo>, Requires<RenderSimpleInfo>
{
public readonly int LingerTime = 20;
public object Create(ActorInitializer init) { return new DeadBuildingState(init.Self, this); }
}
class DeadBuildingState : INotifyKilled
{
DeadBuildingStateInfo info;
RenderSimple rs;
public DeadBuildingState(Actor self, DeadBuildingStateInfo info)
{
this.info = info;
rs = self.Trait<RenderSimple>();
self.Trait<Health>().RemoveOnDeath = !rs.DefaultAnimation.HasSequence("dead");
}
public void Killed(Actor self, AttackInfo e)
{
if (!rs.DefaultAnimation.HasSequence("dead")) return;
if (rs.DefaultAnimation.GetSequence("dead").Length > 1)
rs.DefaultAnimation.Play("dead");
else
rs.DefaultAnimation.PlayRepeating("dead");
self.World.AddFrameEndTask(
w => w.Add(
new DelayedAction(info.LingerTime,
() => self.Destroy())));
}
}
}

View File

@@ -8,6 +8,8 @@
*/ */
#endregion #endregion
using System.Collections.Generic;
using OpenRA.Effects;
using OpenRA.Mods.Common.Effects; using OpenRA.Mods.Common.Effects;
using OpenRA.Traits; using OpenRA.Traits;
@@ -19,6 +21,9 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Explosion sequence name to use")] [Desc("Explosion sequence name to use")]
public readonly string Sequence = "building"; public readonly string Sequence = "building";
[Desc("Delay the explosions by this many ticks.")]
public readonly int Delay = 0;
[Desc("Custom palette name")] [Desc("Custom palette name")]
public readonly string Palette = "effect"; public readonly string Palette = "effect";
@@ -37,8 +42,18 @@ namespace OpenRA.Mods.Common.Traits
public void Killed(Actor self, AttackInfo e) public void Killed(Actor self, AttackInfo e)
{ {
var buildingInfo = self.Info.Traits.Get<BuildingInfo>(); var buildingInfo = self.Info.Traits.Get<BuildingInfo>();
FootprintUtils.UnpathableTiles(self.Info.Name, buildingInfo, self.Location).Do( var cells = FootprintUtils.UnpathableTiles(self.Info.Name, buildingInfo, self.Location);
t => self.World.AddFrameEndTask(w => w.Add(new Explosion(w, w.Map.CenterOfCell(t), info.Sequence, info.Palette))));
if (info.Delay > 0)
self.World.AddFrameEndTask(w => w.Add(new DelayedAction(info.Delay, () => SpawnExplosions(self.World, cells))));
else
SpawnExplosions(self.World, cells);
}
void SpawnExplosions(World world, IEnumerable<CPos> cells)
{
foreach (var c in cells)
world.AddFrameEndTask(w => w.Add(new Explosion(w, w.Map.CenterOfCell(c), info.Sequence, info.Palette)));
} }
} }
} }

View File

@@ -401,6 +401,7 @@
DestroyedSound: crumble.aud DestroyedSound: crumble.aud
RenderBuilding: RenderBuilding:
WithBuildingExplosion: WithBuildingExplosion:
Delay: 1
EmitInfantryOnSell: EmitInfantryOnSell:
ActorTypes: e6,e1 ActorTypes: e6,e1
GivesExperience: GivesExperience:
@@ -432,7 +433,9 @@
RepairableBuilding: RepairableBuilding:
RepairPercent: 40 RepairPercent: 40
RepairStep: 14 RepairStep: 14
DeadBuildingState: WithDeathAnimation:
DeathSequence: dead
UseDeathTypeSuffix: false
GivesBuildableArea: GivesBuildableArea:
EngineerRepairable: EngineerRepairable:
Sellable: Sellable:
@@ -560,7 +563,6 @@
RelativeToTopLeft: yes RelativeToTopLeft: yes
Health: Health:
HP: 500 HP: 500
DeadBuildingState:
Armor: Armor:
Type: Wood Type: Wood
AutoTargetIgnore: AutoTargetIgnore:

View File

@@ -616,7 +616,7 @@ GUN:
WithMuzzleFlash: WithMuzzleFlash:
AutoTarget: AutoTarget:
-RenderBuilding: -RenderBuilding:
-DeadBuildingState: -WithDeathAnimation:
RenderRangeCircle: RenderRangeCircle:
RenderDetectionCircle: RenderDetectionCircle:
DetectCloaked: DetectCloaked:

View File

@@ -17,6 +17,7 @@ fact:
Tick: 100 Tick: 100
dead: dead:
Start: 48 Start: 48
Tick: 800
make: factmake make: factmake
Start: 0 Start: 0
Length: * Length: *
@@ -38,7 +39,7 @@ nuke:
Tick: 1000 Tick: 1000
dead: dead:
Start: 8 Start: 8
Tick: 1000 Tick: 800
make: nukemake make: nukemake
Start: 0 Start: 0
Length: * Length: *
@@ -60,6 +61,7 @@ proc:
Tick: 120 Tick: 120
dead: dead:
Start: 60 Start: 60
Tick: 800
make: procmake make: procmake
Start: 0 Start: 0
Length: * Length: *
@@ -90,6 +92,7 @@ silo:
dead: dead:
Start: 10 Start: 10
Offset: 0,-1 Offset: 0,-1
Tick: 800
make: silomake make: silomake
Start: 0 Start: 0
Length: * Length: *
@@ -109,6 +112,7 @@ hand:
Start: 1 Start: 1
dead: dead:
Start: 2 Start: 2
Tick: 800
make: handmake make: handmake
Start: 0 Start: 0
Length: * Length: *
@@ -130,7 +134,7 @@ pyle:
Tick: 100 Tick: 100
dead: dead:
Start: 20 Start: 20
Tick: 100 Tick: 800
make: pylemake make: pylemake
Start: 0 Start: 0
Length: * Length: *
@@ -148,6 +152,7 @@ weap:
Start: 1 Start: 1
dead: dead:
Start: 2 Start: 2
Tick: 800
build-top: weap2 build-top: weap2
Start: 0 Start: 0
Length: 10 Length: 10
@@ -190,6 +195,7 @@ afld:
dead: dead:
Start: 32 Start: 32
ZOffset: -1023 ZOffset: -1023
Tick: 800
make: afldmake make: afldmake
Start: 0 Start: 0
Length: * Length: *
@@ -211,6 +217,7 @@ hq:
Tick: 100 Tick: 100
dead: dead:
Start: 32 Start: 32
Tick: 800
make: hqmake make: hqmake
Start: 0 Start: 0
Length: * Length: *
@@ -232,6 +239,7 @@ nuk2:
Tick: 1000 Tick: 1000
dead: dead:
Start: 8 Start: 8
Tick: 800
make: nuk2make make: nuk2make
Start: 0 Start: 0
Length: * Length: *
@@ -262,6 +270,7 @@ hpad:
dead: dead:
Start: 14 Start: 14
ZOffset: -1023 ZOffset: -1023
Tick: 800
make: hpadmake make: hpadmake
Start: 0 Start: 0
Length: * Length: *
@@ -287,6 +296,7 @@ fix:
dead: dead:
Start: 14 Start: 14
ZOffset: -1c511 ZOffset: -1c511
Tick: 800
make: fixmake make: fixmake
Start: 0 Start: 0
Length: 14 Length: 14
@@ -309,6 +319,7 @@ eye:
Tick: 100 Tick: 100
dead: dead:
Start: 32 Start: 32
Tick: 800
make: eyemake make: eyemake
Start: 0 Start: 0
Length: * Length: *
@@ -332,6 +343,7 @@ tmpl:
Length: 5 Length: 5
dead: dead:
Start: 10 Start: 10
Tick: 800
make: tmplmake make: tmplmake
Start: 0 Start: 0
Length: * Length: *
@@ -357,6 +369,7 @@ obli:
Tick: 680 Tick: 680
dead: dead:
Start: 8 Start: 8
Tick: 800
make: oblimake make: oblimake
Start: 0 Start: 0
Length: 13 Length: 13
@@ -470,6 +483,7 @@ sam:
Tick: 30 Tick: 30
dead: dead:
Start: 128 Start: 128
Tick: 800
make: sammake make: sammake
Start: 0 Start: 0
Length: 20 Length: 20
@@ -488,6 +502,7 @@ gtwr:
Start: 1 Start: 1
dead: dead:
Start: 2 Start: 2
Tick: 800
make: gtwrmake make: gtwrmake
Start: 0 Start: 0
Length: * Length: *
@@ -513,6 +528,7 @@ atwr:
dead: dead:
Start: 2 Start: 2
Offset: 0,-1 Offset: 0,-1
Tick: 800
make: atwrmake make: atwrmake
Start: 0 Start: 0
Length: * Length: *

View File

@@ -89,7 +89,11 @@ HOSP:
Range: 3c0 Range: 3c0
Bib: Bib:
HasMinibib: Yes HasMinibib: Yes
DeadBuildingState: WithDeathAnimation:
DeathSequence: dead
UseDeathTypeSuffix: false
WithBuildingExplosion:
Delay: 1
V01: V01:
Inherits: ^CivBuilding Inherits: ^CivBuilding
@@ -291,7 +295,11 @@ MISS:
Tooltip: Tooltip:
Name: Technology Center Name: Technology Center
Bib: Bib:
DeadBuildingState: WithDeathAnimation:
DeathSequence: dead
UseDeathTypeSuffix: false
WithBuildingExplosion:
Delay: 1
BIO: BIO:
Inherits: ^TechBuilding Inherits: ^TechBuilding
@@ -303,7 +311,11 @@ BIO:
EngineerRepairable: EngineerRepairable:
Tooltip: Tooltip:
Name: Biological Lab Name: Biological Lab
DeadBuildingState: WithDeathAnimation:
DeathSequence: dead
UseDeathTypeSuffix: false
WithBuildingExplosion:
Delay: 1
OILB: OILB:
Inherits: ^TechBuilding Inherits: ^TechBuilding

View File

@@ -581,7 +581,6 @@
Types: Tree Types: Tree
Health: Health:
HP: 500 HP: 500
DeadBuildingState:
Armor: Armor:
Type: Wood Type: Wood
AutoTargetIgnore: AutoTargetIgnore:

View File

@@ -903,12 +903,16 @@ FACT:
ProductionBar@Defense: ProductionBar@Defense:
ProductionType: Defense ProductionType: Defense
Color: 138,138,138 Color: 138,138,138
DeadBuildingState:
BaseProvider: BaseProvider:
Range: 16 Range: 16
WithBuildingPlacedAnimation: WithBuildingPlacedAnimation:
Power: Power:
Amount: 0 Amount: 0
WithDeathAnimation:
DeathSequence: dead
UseDeathTypeSuffix: false
WithBuildingExplosion:
Delay: 1
PROC: PROC:
Inherits: ^Building Inherits: ^Building
@@ -951,11 +955,15 @@ PROC:
Percentage: 50 Percentage: 50
Minimum: 500 Minimum: 500
SoundToVictim: credit1.aud SoundToVictim: credit1.aud
DeadBuildingState:
WithIdleOverlay@TOP: WithIdleOverlay@TOP:
Sequence: idle-top Sequence: idle-top
Power: Power:
Amount: -30 Amount: -30
WithDeathAnimation:
DeathSequence: dead
UseDeathTypeSuffix: false
WithBuildingExplosion:
Delay: 1
SILO: SILO:
Inherits: ^Building Inherits: ^Building
@@ -1191,7 +1199,6 @@ POWR:
RevealsShroud: RevealsShroud:
Range: 4c0 Range: 4c0
Bib: Bib:
DeadBuildingState:
Power: Power:
Amount: 100 Amount: 100
InfiltrateForPowerOutage: InfiltrateForPowerOutage:
@@ -1200,6 +1207,11 @@ POWR:
TargetTypes: Ground, C4, DetonateAttack, SpyInfiltrate TargetTypes: Ground, C4, DetonateAttack, SpyInfiltrate
ScalePowerWithHealth: ScalePowerWithHealth:
DisabledOverlay: DisabledOverlay:
WithDeathAnimation:
DeathSequence: dead
UseDeathTypeSuffix: false
WithBuildingExplosion:
Delay: 1
APWR: APWR:
Inherits: ^Building Inherits: ^Building
@@ -1224,7 +1236,6 @@ APWR:
RevealsShroud: RevealsShroud:
Range: 4c0 Range: 4c0
Bib: Bib:
DeadBuildingState:
Power: Power:
Amount: 200 Amount: 200
InfiltrateForPowerOutage: InfiltrateForPowerOutage:
@@ -1233,6 +1244,11 @@ APWR:
TargetTypes: Ground, C4, DetonateAttack, SpyInfiltrate TargetTypes: Ground, C4, DetonateAttack, SpyInfiltrate
ScalePowerWithHealth: ScalePowerWithHealth:
DisabledOverlay: DisabledOverlay:
WithDeathAnimation:
DeathSequence: dead
UseDeathTypeSuffix: false
WithBuildingExplosion:
Delay: 1
STEK: STEK:
Inherits: ^Building Inherits: ^Building

View File

@@ -19,6 +19,7 @@ hosp:
Length: 4 Length: 4
dead: dead:
Start: 8 Start: 8
Tick: 800
make: hospmake make: hospmake
Start: 0 Start: 0
Length: * Length: *
@@ -36,6 +37,7 @@ bio:
Start: 1 Start: 1
dead: dead:
Start: 2 Start: 2
Tick: 800
make: biomake make: biomake
Start: 0 Start: 0
Length: * Length: *
@@ -67,6 +69,7 @@ fact:
Length: 25 Length: 25
dead: factdead dead: factdead
Start: 0 Start: 0
Tick: 800
bib: bib2 bib: bib2
Start: 0 Start: 0
Length: * Length: *
@@ -93,7 +96,7 @@ proc:
Length: * Length: *
dead: procdead dead: procdead
Start: 0 Start: 0
ZOffset: -1c511 Tick: 800
bib: bib2 bib: bib2
Start: 0 Start: 0
Length: * Length: *
@@ -129,6 +132,7 @@ powr:
Length: * Length: *
dead: powrdead dead: powrdead
Start: 0 Start: 0
Tick: 800
bib: bib3 bib: bib3
Start: 0 Start: 0
Length: * Length: *
@@ -145,6 +149,7 @@ apwr:
Length: * Length: *
dead: apwrdead dead: apwrdead
Start: 0 Start: 0
Tick: 800
bib: bib2 bib: bib2
Start: 0 Start: 0
Length: * Length: *
@@ -636,6 +641,7 @@ miss:
Start: 1 Start: 1
dead: dead:
Start: 2 Start: 2
Tick: 800
make: missmake make: missmake
Start: 0 Start: 0
Length: * Length: *