change voxel image on water terrain type for APC
This commit is contained in:
@@ -64,6 +64,7 @@
|
|||||||
<Compile Include="Traits\Render\WithVoxelTurret.cs" />
|
<Compile Include="Traits\Render\WithVoxelTurret.cs" />
|
||||||
<Compile Include="Traits\Render\WithVoxelWalkerBody.cs" />
|
<Compile Include="Traits\Render\WithVoxelWalkerBody.cs" />
|
||||||
<Compile Include="Traits\Render\WithVoxelUnloadBody.cs" />
|
<Compile Include="Traits\Render\WithVoxelUnloadBody.cs" />
|
||||||
|
<Compile Include="Traits\Render\WithVoxelWaterBody.cs" />
|
||||||
<Compile Include="Traits\World\VoxelNormalsPalette.cs" />
|
<Compile Include="Traits\World\VoxelNormalsPalette.cs" />
|
||||||
<Compile Include="Traits\World\ShroudPalette.cs" />
|
<Compile Include="Traits\World\ShroudPalette.cs" />
|
||||||
<Compile Include="UtilityCommands\LegacyTilesetImporter.cs" />
|
<Compile Include="UtilityCommands\LegacyTilesetImporter.cs" />
|
||||||
|
|||||||
81
OpenRA.Mods.TS/Traits/Render/WithVoxelWaterBody.cs
Normal file
81
OpenRA.Mods.TS/Traits/Render/WithVoxelWaterBody.cs
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
#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 System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using OpenRA.Graphics;
|
||||||
|
using OpenRA.Mods.Common.Graphics;
|
||||||
|
using OpenRA.Traits;
|
||||||
|
|
||||||
|
namespace OpenRA.Mods.TS.Traits
|
||||||
|
{
|
||||||
|
public class WithVoxelWaterBodyInfo : ITraitInfo, IQuantizeBodyOrientationInfo, IRenderActorPreviewVoxelsInfo, Requires<RenderVoxelsInfo>
|
||||||
|
{
|
||||||
|
public readonly string WaterSequence = "water";
|
||||||
|
public readonly string LandSequence = "idle";
|
||||||
|
|
||||||
|
public object Create(ActorInitializer init) { return new WithVoxelWaterBody(init.Self, this); }
|
||||||
|
|
||||||
|
public IEnumerable<VoxelAnimation> RenderPreviewVoxels(ActorPreviewInitializer init, RenderVoxelsInfo rv, string image, WRot orientation, int facings, PaletteReference p)
|
||||||
|
{
|
||||||
|
var sequence = LandSequence;
|
||||||
|
if (init.Contains<LocationInit>())
|
||||||
|
{
|
||||||
|
var location = init.Get<LocationInit>().Value(init.World);
|
||||||
|
var onWater = init.World.Map.GetTerrainInfo(location).IsWater;
|
||||||
|
sequence = onWater ? WaterSequence : LandSequence;
|
||||||
|
}
|
||||||
|
|
||||||
|
var body = init.Actor.Traits.Get<BodyOrientationInfo>();
|
||||||
|
var voxel = VoxelProvider.GetVoxel(image, sequence);
|
||||||
|
yield return new VoxelAnimation(voxel, () => WVec.Zero,
|
||||||
|
() => new[] { body.QuantizeOrientation(orientation, facings) },
|
||||||
|
() => false, () => 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int QuantizedBodyFacings(ActorInfo ai, SequenceProvider sequenceProvider, string race) { return 0; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class WithVoxelWaterBody : IAutoSelectionSize
|
||||||
|
{
|
||||||
|
readonly Actor self;
|
||||||
|
readonly int2 size;
|
||||||
|
|
||||||
|
bool OverWater { get { return self.World.Map.GetTerrainInfo(self.Location).IsWater; } }
|
||||||
|
|
||||||
|
public WithVoxelWaterBody(Actor self, WithVoxelWaterBodyInfo info)
|
||||||
|
{
|
||||||
|
this.self = self;
|
||||||
|
|
||||||
|
var body = self.Trait<IBodyOrientation>();
|
||||||
|
var rv = self.Trait<RenderVoxels>();
|
||||||
|
|
||||||
|
var landVoxel = VoxelProvider.GetVoxel(rv.Image, info.LandSequence);
|
||||||
|
rv.Add(new VoxelAnimation(landVoxel, () => WVec.Zero,
|
||||||
|
() => new[] { body.QuantizeOrientation(self, self.Orientation) },
|
||||||
|
() => OverWater,
|
||||||
|
() => 0));
|
||||||
|
|
||||||
|
// Selection size
|
||||||
|
var rvi = self.Info.Traits.Get<RenderVoxelsInfo>();
|
||||||
|
var s = (int)(rvi.Scale * landVoxel.Size.Aggregate(Math.Max));
|
||||||
|
size = new int2(s, s);
|
||||||
|
|
||||||
|
var waterVoxel = VoxelProvider.GetVoxel(rv.Image, info.WaterSequence);
|
||||||
|
rv.Add(new VoxelAnimation(waterVoxel, () => WVec.Zero,
|
||||||
|
() => new[] { body.QuantizeOrientation(self, self.Orientation) },
|
||||||
|
() => !OverWater,
|
||||||
|
() => 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
public int2 SelectionSize(Actor self) { return size; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,6 +12,8 @@ APC:
|
|||||||
Mobile:
|
Mobile:
|
||||||
ROT: 5
|
ROT: 5
|
||||||
Speed: 113
|
Speed: 113
|
||||||
|
TerrainSpeeds:
|
||||||
|
Water: 80
|
||||||
Health:
|
Health:
|
||||||
HP: 200
|
HP: 200
|
||||||
Armor:
|
Armor:
|
||||||
@@ -26,7 +28,7 @@ APC:
|
|||||||
PipCount: 5
|
PipCount: 5
|
||||||
RenderSprites:
|
RenderSprites:
|
||||||
RenderVoxels:
|
RenderVoxels:
|
||||||
WithVoxelBody:
|
WithVoxelWaterBody:
|
||||||
LeavesTrails:
|
LeavesTrails:
|
||||||
Image: wake
|
Image: wake
|
||||||
Palette: effect
|
Palette: effect
|
||||||
|
|||||||
@@ -5,8 +5,9 @@ harv:
|
|||||||
idle:
|
idle:
|
||||||
unload: horv
|
unload: horv
|
||||||
|
|
||||||
apc: # TODO apcw in water
|
apc:
|
||||||
idle:
|
idle:
|
||||||
|
water: apcw
|
||||||
|
|
||||||
art2:
|
art2:
|
||||||
idle:
|
idle:
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ Terrain:
|
|||||||
Type: Water
|
Type: Water
|
||||||
Color: 61, 65, 72
|
Color: 61, 65, 72
|
||||||
TargetTypes: Water
|
TargetTypes: Water
|
||||||
|
IsWater: True
|
||||||
TerrainType@DirtRoad:
|
TerrainType@DirtRoad:
|
||||||
Type: DirtRoad
|
Type: DirtRoad
|
||||||
Color: 130,131,143
|
Color: 130,131,143
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ Terrain:
|
|||||||
Type: Water
|
Type: Water
|
||||||
Color: 116, 85, 55
|
Color: 116, 85, 55
|
||||||
TargetTypes: Water
|
TargetTypes: Water
|
||||||
|
IsWater: True
|
||||||
TerrainType@DirtRoad:
|
TerrainType@DirtRoad:
|
||||||
Type: DirtRoad
|
Type: DirtRoad
|
||||||
Color: 116, 85, 55
|
Color: 116, 85, 55
|
||||||
|
|||||||
Reference in New Issue
Block a user