Merge pull request #5033 from pchote/wonderwall

Wall and D2K turret polish
This commit is contained in:
Matthias Mailänder
2014-04-05 08:29:45 +02:00
4 changed files with 121 additions and 153 deletions

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2014 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,
@@ -15,56 +15,87 @@ namespace OpenRA.Mods.RA.Render
{
class RenderBuildingWallInfo : RenderBuildingInfo
{
public override object Create(ActorInitializer init) { return new RenderBuildingWall( init, this ); }
public readonly string Type = "wall";
public readonly string Sequence = "idle";
public override object Create(ActorInitializer init) { return new RenderBuildingWall(init, this); }
}
class RenderBuildingWall : RenderBuilding, INotifyBuildComplete
class RenderBuildingWall : RenderBuilding, INotifyBuildComplete, INotifyAddedToWorld, INotifyRemovedFromWorld
{
string seqName;
int adjacentWalls = 0;
readonly RenderBuildingWallInfo info;
int adjacent = 0;
bool dirty = true;
public RenderBuildingWall( ActorInitializer init, RenderBuildingInfo info )
public RenderBuildingWall(ActorInitializer init, RenderBuildingWallInfo info)
: base(init, info)
{
seqName = "idle";
this.info = info;
}
public void BuildingComplete( Actor self )
public void BuildingComplete(Actor self)
{
anim.PlayFetchIndex(seqName, () => adjacentWalls);
anim.PlayFetchIndex(info.Sequence, () => adjacent);
}
public override void DamageStateChanged(Actor self, AttackInfo e)
{
anim.PlayFetchIndex(NormalizeSequence(anim, e.DamageState, "idle"), () => adjacentWalls);
anim.PlayFetchIndex(NormalizeSequence(anim, e.DamageState, info.Sequence), () => adjacent);
}
bool hasTicked = false;
public override void Tick(Actor self)
{
base.Tick(self);
if (!hasTicked)
{
var vec = new CVec(1, 1);
var adjWalls = self.World.FindActorsInBox(self.Location - vec, self.Location + vec)
.Where(a => a.Info == self.Info && a != self);
if (!dirty)
return;
foreach (var w in adjWalls)
{
w.Trait<RenderBuildingWall>().AddAdjacentWall(w.Location, self.Location);
AddAdjacentWall(self.Location, w.Location);
}
hasTicked = true;
// Update connection to neighbours
var vec = new CVec(1, 1);
var adjacentActors = self.World.FindActorsInBox(self.Location - vec, self.Location + vec);
adjacent = 0;
foreach (var a in adjacentActors)
{
var rb = a.TraitOrDefault<RenderBuildingWall>();
if (rb == null || rb.info.Type != info.Type)
continue;
var location = self.Location;
var otherLocation = a.Location;
if (otherLocation == location + new CVec(0, -1))
adjacent |= 1;
else if (otherLocation == location + new CVec(+1, 0))
adjacent |= 2;
else if (otherLocation == location + new CVec(0, +1))
adjacent |= 4;
else if (otherLocation == location + new CVec(-1, 0))
adjacent |= 8;
}
dirty = false;
}
void AddAdjacentWall(CPos location, CPos otherLocation)
void UpdateNeighbours(Actor self)
{
if (otherLocation == location + new CVec(0, -1)) adjacentWalls |= 1;
if (otherLocation == location + new CVec(+1, 0)) adjacentWalls |= 2;
if (otherLocation == location + new CVec(0, +1)) adjacentWalls |= 4;
if (otherLocation == location + new CVec(-1, 0)) adjacentWalls |= 8;
var vec = new CVec(1, 1);
var neighbours = self.World.FindActorsInBox(self.Location - vec, self.Location + vec)
.Select(a => a.TraitOrDefault<RenderBuildingWall>())
.Where(a => a != null);
foreach (var rb in neighbours)
rb.dirty = true;
}
public void AddedToWorld(Actor self)
{
UpdateNeighbours(self);
}
public void RemovedFromWorld(Actor self)
{
UpdateNeighbours(self);
}
}
}

View File

@@ -19,7 +19,10 @@ namespace OpenRA.Mods.RA.Render
{
class WithMuzzleFlashInfo : ITraitInfo, Requires<RenderSpritesInfo>, Requires<AttackBaseInfo>, Requires<ArmamentInfo>
{
public object Create(ActorInitializer init) { return new WithMuzzleFlash(init.self); }
[Desc("Ignore the weapon position, and always draw relative to the center of the actor")]
public readonly bool IgnoreOffset = false;
public object Create(ActorInitializer init) { return new WithMuzzleFlash(init.self, this); }
}
class WithMuzzleFlash : INotifyAttack, IRender, ITick
@@ -28,7 +31,7 @@ namespace OpenRA.Mods.RA.Render
Dictionary<Barrel, AnimationWithOffset> anims = new Dictionary<Barrel, AnimationWithOffset>();
Func<int> getFacing;
public WithMuzzleFlash(Actor self)
public WithMuzzleFlash(Actor self, WithMuzzleFlashInfo info)
{
var render = self.Trait<RenderSprites>();
var facing = self.TraitOrDefault<IFacing>();
@@ -52,7 +55,7 @@ namespace OpenRA.Mods.RA.Render
visible.Add(barrel, false);
anims.Add(barrel,
new AnimationWithOffset(muzzleFlash,
() => arm.MuzzleOffset(self, barrel),
() => info.IgnoreOffset ? WVec.Zero : arm.MuzzleOffset(self, barrel),
() => !visible[barrel],
p => WithTurret.ZOffsetFromCenter(self, p, 2)));
}

View File

@@ -452,7 +452,7 @@ WALL:
BuildSounds: CHUNG.WAV
SellSounds: CHUNG.WAV
Selectable:
Bounds: 32,32
Bounds: 32,40,0,-8
Priority: 3
-GivesBuildableArea:
Health:
@@ -462,18 +462,20 @@ WALL:
RevealsShroud:
Range: 8c0
RenderRangeCircle:
RenderBuilding:
-RenderBuilding:
RenderBuildingWall:
HasMakeAnimation: false
BodyOrientation:
QuantizedFacings: 32
WithTurret:
WithMuzzleFlash:
IgnoreOffset: true
Turreted:
ROT: 6
InitialFacing: 128
Armament:
Weapon: TurretGun
LocalOffset: 448,0,128
LocalOffset: 672,0,480
MuzzleSequence: muzzle
AttackTurreted:
AutoTarget:
@@ -502,7 +504,7 @@ WALL:
BuildSounds: CHUNG.WAV
SellSounds: CHUNG.WAV
Selectable:
Bounds: 32,32
Bounds: 32,40,0,-8
Priority: 3
-GivesBuildableArea:
Health:
@@ -512,14 +514,15 @@ WALL:
RevealsShroud:
Range: 10c0
RenderRangeCircle:
RenderBuilding:
-RenderBuilding:
RenderBuildingWall:
HasMakeAnimation: false
BodyOrientation:
QuantizedFacings: 32
WithTurret:
Armament:
Weapon: TowerMissile
LocalOffset: 256,384,448, 256,-384,448
LocalOffset: 256,384,768, 256,-384,768
AttackTurreted:
Turreted:
ROT: 8

View File

@@ -13,18 +13,10 @@ walla:
Frames: 2527, 2530, 2528, 2538, 2531, 2532, 2542, 2535, 2529, 2539, 2533, 2534, 2540, 2536, 2537, 2541
Length: 16
Offset: -16,16
scratched-idle: DATA
Frames: 2527, 2530, 2528, 2538, 2531, 2532, 2542, 2535, 2529, 2539, 2533, 2534, 2540, 2536, 2537, 2541
Length: 16
Offset: -16,16
damaged-idle: DATA
Frames: 2543, 2546, 2544, 2554, 2547, 2548, 2558, 2551, 2545, 2555, 2549, 2550, 2556, 2552, 2553, 2557
Length: 16
Offset: -16,16
critical-idle: DATA
Frames: 2543, 2546, 2544, 2554, 2547, 2548, 2558, 2551, 2545, 2555, 2549, 2550, 2556, 2552, 2553, 2557
Length: 16
Offset: -16,16
icon: DATA
Start: 4063
Offset: -30,-24
@@ -34,18 +26,10 @@ wallh:
Frames: 2687, 2690, 2688, 2698, 2691, 2692, 2702, 2695, 2689, 2699, 2693, 2694, 2700, 2696, 2697, 2701
Length: 16
Offset: -16,16
scratched-idle: DATA
Frames: 2687, 2690, 2688, 2698, 2691, 2692, 2702, 2695, 2689, 2699, 2693, 2694, 2700, 2696, 2697, 2701
Length: 16
Offset: -16,16
damaged-idle: DATA
Frames: 2703, 2706, 2704, 2714, 2707, 2708, 2718, 2711, 2705, 2715, 2709, 2710, 2716, 2712, 2713, 2717
Length: 16
Offset: -16,16
critical-idle: DATA
Frames: 2703, 2706, 2704, 2714, 2707, 2708, 2718, 2711, 2705, 2715, 2709, 2710, 2716, 2712, 2713, 2717
Length: 16
Offset: -16,16
icon: DATA
Start: 4064
Offset: -30,-24
@@ -55,47 +39,32 @@ wallo:
Frames: 2847, 2850, 2848, 2858, 2851, 2852, 2862, 2855, 2849, 2859, 2853, 2854, 2860, 2856, 2857, 2861
Length: 16
Offset: -16,16
scratched-idle: DATA
Frames: 2847, 2850, 2848, 2858, 2851, 2852, 2862, 2855, 2849, 2859, 2853, 2854, 2860, 2856, 2857, 2861
Length: 16
Offset: -16,16
damaged-idle: DATA
Frames: 2863, 2866, 2864, 2874, 2867, 2868, 2878, 2871, 2865, 2875, 2869, 2870, 2876, 2872, 2873, 2877
Length: 16
Offset: -16,16
critical-idle: DATA
Frames: 2863, 2866, 2864, 2874, 2867, 2868, 2878, 2871, 2865, 2875, 2869, 2870, 2876, 2872, 2873, 2877
Length: 16
Offset: -16,16
icon: DATA
Start: 4065
Offset: -30,-24
guntowera:
idle: DATA
Start: 2573
Facings: 1
Offset: -24,24
recoil: DATA
Start: 2573
Facings: 1
Offset: -24,24
Frames: 2573, 2576, 2574, 2584, 2577, 2578, 2588, 2581, 2575, 2585, 2579, 2580, 2586, 2582, 2583, 2587
Length: 16
Offset: -24,16
damaged-idle: DATA
Start: 2573
Facings: 1
Offset: -24,24
damaged-recoil: DATA
Start: 2573
Facings: 1
Offset: -24,24
Frames: 2621, 2624, 2622, 2632, 2625, 2626, 2636, 2629, 2623, 2633, 2627, 2628, 2634, 2630, 2631, 2635
Length: 16
Offset: -24,16
turret: DATA
Start: 2589
Facings: -32
Offset: -24,24
Offset: -24,16
muzzle: DATA
Frames: 3775, 3775, 3776, 3776, 3777, 3777, 3778, 3778, 3779, 3779, 3780, 3780, 3781, 3781, 3782, 3782, 3783, 3783, 3784, 3784, 3785, 3785, 3786, 3786, 3787, 3787, 3788, 3788, 3789, 3789, 3790, 3790, 3791, 3791, 3792, 3792, 3793, 3793, 3794, 3794, 3795, 3795, 3796, 3796, 3797, 3797, 3798, 3798, 3799, 3799, 3800, 3800, 3801, 3801, 3802, 3802, 3803, 3803, 3804, 3804, 3805, 3805, 3806, 3806
Frames: 3839, 3839, 3840, 3840, 3841, 3841, 3842, 3842, 3843, 3843, 3844, 3844, 3845, 3845, 3846, 3846, 3847, 3847, 3848, 3848, 3849, 3849, 3850, 3850, 3851, 3851, 3852, 3852, 3853, 3853, 3854, 3854, 3855, 3855, 3856, 3856, 3857, 3857, 3858, 3858, 3859, 3859, 3860, 3860, 3861, 3861, 3862, 3862, 3863, 3863, 3864, 3864, 3865, 3865, 3866, 3866, 3867, 3867, 3868, 3868, 3869, 3869, 3870, 3870
Facings: -32
Length: 2
Offset: 0,-12
BlendMode: Additive
icon: DATA
Start: 4069
@@ -103,29 +72,22 @@ guntowera:
guntowerh:
idle: DATA
Start: 2733
Facings: 1
Offset: -24,24
recoil: DATA
Start: 2733
Facings: 1
Offset: -24,24
Frames: 2733, 2736, 2734, 2744, 2737, 2738, 2748, 2741, 2735, 2745, 2739, 2740, 2746, 2742, 2743, 2747
Length: 16
Offset: -24,16
damaged-idle: DATA
Start: 2733
Facings: 1
Offset: -24,24
damaged-recoil: DATA
Start: 2733
Facings: 1
Offset: -24,24
Frames: 2781, 2784, 2782, 2792, 2785, 2786, 2796, 2789, 2783, 2793, 2787, 2788, 2794, 2790, 2791, 2795
Length: 16
Offset: -24,16
turret: DATA
Start: 2749
Facings: -32
Offset: -24,24
Offset: -24,16
muzzle: DATA
Frames: 3775, 3775, 3776, 3776, 3777, 3777, 3778, 3778, 3779, 3779, 3780, 3780, 3781, 3781, 3782, 3782, 3783, 3783, 3784, 3784, 3785, 3785, 3786, 3786, 3787, 3787, 3788, 3788, 3789, 3789, 3790, 3790, 3791, 3791, 3792, 3792, 3793, 3793, 3794, 3794, 3795, 3795, 3796, 3796, 3797, 3797, 3798, 3798, 3799, 3799, 3800, 3800, 3801, 3801, 3802, 3802, 3803, 3803, 3804, 3804, 3805, 3805, 3806, 3806
Frames: 3839, 3839, 3840, 3840, 3841, 3841, 3842, 3842, 3843, 3843, 3844, 3844, 3845, 3845, 3846, 3846, 3847, 3847, 3848, 3848, 3849, 3849, 3850, 3850, 3851, 3851, 3852, 3852, 3853, 3853, 3854, 3854, 3855, 3855, 3856, 3856, 3857, 3857, 3858, 3858, 3859, 3859, 3860, 3860, 3861, 3861, 3862, 3862, 3863, 3863, 3864, 3864, 3865, 3865, 3866, 3866, 3867, 3867, 3868, 3868, 3869, 3869, 3870, 3870
Facings: -32
Length: 2
Offset: 0,-12
BlendMode: Additive
icon: DATA
Frames: 4070
@@ -133,29 +95,22 @@ guntowerh:
guntowero:
idle: DATA
Start: 2893
Facings: 1
Offset: -24,24
recoil: DATA
Start: 2893
Facings: 1
Offset: -24,24
Frames: 2893, 2896, 2894, 2904, 2897, 2898, 2908, 2901, 2895, 2905, 2899, 2900, 2906, 2902, 2903, 2907
Length: 16
Offset: -24,16
damaged-idle: DATA
Start: 2893
Facings: 1
Offset: -24,24
damaged-recoil: DATA
Start: 2893
Facings: 1
Offset: -24,24
Frames: 2941, 2944, 2942, 2952, 2945, 2946, 2956, 2949, 2943, 2953, 2947, 2948, 2954, 2950, 2951, 2955
Length: 16
Offset: -24,16
turret: DATA
Start: 2909
Facings: -32
Offset: -24,24
Offset: -24,16
muzzle: DATA
Frames: 3775, 3775, 3776, 3776, 3777, 3777, 3778, 3778, 3779, 3779, 3780, 3780, 3781, 3781, 3782, 3782, 3783, 3783, 3784, 3784, 3785, 3785, 3786, 3786, 3787, 3787, 3788, 3788, 3789, 3789, 3790, 3790, 3791, 3791, 3792, 3792, 3793, 3793, 3794, 3794, 3795, 3795, 3796, 3796, 3797, 3797, 3798, 3798, 3799, 3799, 3800, 3800, 3801, 3801, 3802, 3802, 3803, 3803, 3804, 3804, 3805, 3805, 3806, 3806
Frames: 3839, 3839, 3840, 3840, 3841, 3841, 3842, 3842, 3843, 3843, 3844, 3844, 3845, 3845, 3846, 3846, 3847, 3847, 3848, 3848, 3849, 3849, 3850, 3850, 3851, 3851, 3852, 3852, 3853, 3853, 3854, 3854, 3855, 3855, 3856, 3856, 3857, 3857, 3858, 3858, 3859, 3859, 3860, 3860, 3861, 3861, 3862, 3862, 3863, 3863, 3864, 3864, 3865, 3865, 3866, 3866, 3867, 3867, 3868, 3868, 3869, 3869, 3870, 3870
Facings: -32
Length: 2
Offset: 0,-12
BlendMode: Additive
icon: DATA
Start: 4071
@@ -163,75 +118,51 @@ guntowero:
rockettowera:
idle: DATA
Start: 2733
Facings: 1
Offset: -24,24
recoil: DATA
Start: 2733
Facings: 1
Offset: -24,24
Frames: 2573, 2576, 2574, 2584, 2577, 2578, 2588, 2581, 2575, 2585, 2579, 2580, 2586, 2582, 2583, 2587
Length: 16
Offset: -24,16
damaged-idle: DATA
Start: 2733
Facings: 1
Offset: -24,24
damaged-recoil: DATA
Start: 2733
Facings: 1
Offset: -24,24
Frames: 2621, 2624, 2622, 2632, 2625, 2626, 2636, 2629, 2623, 2633, 2627, 2628, 2634, 2630, 2631, 2635
Length: 16
Offset: -24,16
turret: DATA
Start: 2637
Facings: -32
Offset: -24,24
Offset: -24,16
icon: DATA
Start: 4075
Offset: -30,-24
rockettowerh:
idle: DATA
Start: 2781
Facings: 1
Offset: -24,24
recoil: DATA
Start: 2781
Facings: 1
Offset: -24,24
Frames: 2733, 2736, 2734, 2744, 2737, 2738, 2748, 2741, 2735, 2745, 2739, 2740, 2746, 2742, 2743, 2747
Length: 16
Offset: -24,16
damaged-idle: DATA
Start: 2781
Facings: 1
Offset: -24,24
damaged-recoil: DATA
Start: 2781
Facings: 1
Offset: -24,24
Frames: 2781, 2784, 2782, 2792, 2785, 2786, 2796, 2789, 2783, 2793, 2787, 2788, 2794, 2790, 2791, 2795
Length: 16
Offset: -24,16
turret: DATA
Start: 2797
Facings: -32
Offset: -24,24
Offset: -24,16
icon: DATA
Start: 4076
Offset: -30,-24
rockettowero:
idle: DATA
Start: 2941
Facings: 1
Offset: -24,24
recoil: DATA
Start: 2941
Facings: 1
Offset: -24,24
Frames: 2893, 2896, 2894, 2904, 2897, 2898, 2908, 2901, 2895, 2905, 2899, 2900, 2906, 2902, 2903, 2907
Length: 16
Offset: -24,16
damaged-idle: DATA
Start: 2941
Facings: 1
Offset: -24,24
damaged-recoil: DATA
Start: 2941
Facings: 1
Offset: -24,24
Frames: 2941, 2944, 2942, 2952, 2945, 2946, 2956, 2949, 2943, 2953, 2947, 2948, 2954, 2950, 2951, 2955
Length: 16
Offset: -24,16
turret: DATA
Start: 2957
Facings: -32
Offset: -24,24
Offset: -24,16
icon: DATA
Start: 4077
Offset: -30,-24