mirror of
https://github.com/OpenDiablo2/OpenDiablo2
synced 2024-12-25 11:36:26 -05:00
Added render priority for layers
This commit is contained in:
parent
6646efd0c3
commit
0402119ec7
@ -55,9 +55,10 @@ namespace OpenDiablo2.Common.Models
|
||||
public eMobMode MobMode { get; private set; }
|
||||
public List<AnimationData> Animations { get; private set; }
|
||||
|
||||
public IEnumerable<COFLayer> Layers { get; private set; }
|
||||
public COFLayer[] Layers { get; private set; }
|
||||
public Dictionary<eCompositType, int> CompositLayers { get; private set; }
|
||||
public IEnumerable<eAnimationFrame> AnimationFrames { get; private set; }
|
||||
public byte[] Priority { get; private set; }
|
||||
public eCompositType[] Priority { get; private set; }
|
||||
public int NumberOfDirections { get; internal set; }
|
||||
public int FramesPerDirection { get; internal set; }
|
||||
public int NumberOfLayers { get; internal set; }
|
||||
@ -80,6 +81,8 @@ namespace OpenDiablo2.Common.Models
|
||||
br.ReadBytes(25); // Skip 25 unknown bytes...
|
||||
|
||||
var layers = new List<COFLayer>();
|
||||
result.CompositLayers = new Dictionary<eCompositType, int>();
|
||||
|
||||
for (var layerIdx = 0; layerIdx < result.NumberOfLayers; layerIdx++)
|
||||
{
|
||||
var layer = new COFLayer
|
||||
@ -91,14 +94,15 @@ namespace OpenDiablo2.Common.Models
|
||||
br.ReadByte(); // Unknown
|
||||
layer.IsTransparent = br.ReadByte() != 0;
|
||||
layer.DrawEffect = (eDrawEffect)br.ReadByte();
|
||||
layers.Add(layer);
|
||||
layer.WeaponClass = Encoding.ASCII.GetString(br.ReadBytes(4)).Trim('\0').ToWeaponClass();
|
||||
layer.ShieldCode = ShieldCode;
|
||||
layer.WeaponCode = weaponCode;
|
||||
layers.Add(layer);
|
||||
result.CompositLayers[layer.CompositType] = layerIdx;
|
||||
}
|
||||
result.Layers = layers;
|
||||
result.Layers = layers.ToArray();
|
||||
result.AnimationFrames = br.ReadBytes(result.FramesPerDirection).Select(x => (eAnimationFrame)x);
|
||||
result.Priority = br.ReadBytes(result.FramesPerDirection * result.NumberOfLayers * result.NumberOfDirections);
|
||||
result.Priority = br.ReadBytes(result.FramesPerDirection * result.NumberOfLayers * result.NumberOfDirections).Select(x => (eCompositType)x).ToArray();
|
||||
|
||||
var cofName = $"{hero.ToToken()}{mobMode.ToToken()}{weaponClass.ToToken()}".ToUpper();
|
||||
result.Animations = animations[cofName];
|
||||
|
@ -89,8 +89,7 @@ namespace OpenDiablo2.Core
|
||||
binaryData = new byte[stream.Length];
|
||||
stream.Read(binaryData, 0, (int)stream.Length);
|
||||
}
|
||||
var result = new MPQDCC(binaryData, palette);
|
||||
return result;
|
||||
return new MPQDCC(binaryData, palette);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -192,23 +192,18 @@ namespace OpenDiablo2.SDL2_
|
||||
SDL.SDL_LockTexture(texture, IntPtr.Zero, out IntPtr pixels, out int pitch);
|
||||
UInt32* data = (UInt32*)pixels;
|
||||
|
||||
var priorities = new int[animationData.NumberOfLayers];
|
||||
Array.Copy(
|
||||
animationData.Priority,
|
||||
(directionConversion[LocationDetails.MovementDirection] * animationData.FramesPerDirection * animationData.NumberOfLayers)
|
||||
+ (frameIndex * animationData.NumberOfLayers),
|
||||
priorities,
|
||||
0,
|
||||
animationData.NumberOfLayers
|
||||
);
|
||||
|
||||
for (var i = 0; i < layerData.Length; i++)
|
||||
var priorityBase = (directionConversion[LocationDetails.MovementDirection] * animationData.FramesPerDirection * animationData.NumberOfLayers)
|
||||
+ (frameIndex * animationData.NumberOfLayers);
|
||||
for (var i = 0; i < animationData.NumberOfLayers; i++)
|
||||
{
|
||||
//var layer = layerData[priorities[i]];
|
||||
var layer = layerData[i];
|
||||
var comp = animationData.Priority[priorityBase + i];
|
||||
if (!animationData.CompositLayers.ContainsKey(comp))
|
||||
continue;
|
||||
|
||||
var layer = layerData[animationData.CompositLayers[comp]];
|
||||
|
||||
if (layer == null)
|
||||
continue;
|
||||
continue; // TODO: This is most likely not ok
|
||||
|
||||
var direction = layer.Directions[directionConversion[LocationDetails.MovementDirection]];
|
||||
var frame = direction.Frames[frameIndex];
|
||||
|
Loading…
Reference in New Issue
Block a user