Small refactoring.

This commit is contained in:
Lucca Faria Ferri 2023-02-01 06:45:24 -08:00
parent 85de65c041
commit 95293710ce
41 changed files with 1653 additions and 1639 deletions

View File

@ -1,5 +1,6 @@
//Blizzless Project 2022
using System;
using System.Collections.Generic;
namespace DiIiS_NA.Core.Extensions
{
@ -20,5 +21,89 @@ namespace DiIiS_NA.Core.Extensions
TimeSpan diff = time.ToUniversalTime() - DateTime.UnixEpoch;
return (ulong)((diff.TotalSeconds - 946695547L) * 1000000000L);
}
/// <summary>
/// Transforms a timespan to a readable text.
/// E.g.:
/// 1 day, 2 hours, 3 minutes and 4 seconds
/// 5 hours, 6 minutes and 7 seconds
///
/// If over certain threshold (millennium or more) it will only return the number of days.
/// </summary>
/// <param name="span">The timespan to be converted</param>
/// <returns>The readable text</returns>
public static string ToText(this TimeSpan span)
{
List<string> parts = new();
// if days are divided by 365, we have years, otherwise we have months or days
if (span.Days / 365 > 0)
{
// if days are divided by 365, we have years
parts.Add($"{((double)span.Days / 365):F} year{(span.Days / 365 > 1 ? "s" : "")}");
// get months from the remaining days
int months = span.Days % 365 / 30;
if (months > 0)
parts.Add($"{months} month{(months > 1 ? "s" : "")}");
// get remaining days
int days = span.Days % 365 % 30;
if (days > 0)
parts.Add($"{days} day{(days > 1 ? "s" : "")}");
}
else if (span.Days / 30 > 0)
{
// if days are divided by 30, we have months
parts.Add($"{((double)span.Days / 30):F} month{(span.Days / 30 > 1 ? "s" : "")}");
// get remaining days
int days = span.Days % 30;
if (days > 0)
parts.Add($"{days} day{(days > 1 ? "s" : "")}");
}
else if (span.Days > 0)
// if days are not divided by 365 or 30, we have days
parts.Add( $"{span.Days} day{(span.Days > 1 ? "s" : "")}");
if (span.Hours > 0)
parts.Add($"{span.Hours} hour{(span.Hours > 1 ? "s" : "")}");
if (span.Minutes > 0)
parts.Add($"{span.Minutes} minute{(span.Minutes > 1 ? "s" : "")}");
if (span.Seconds > 0)
parts.Add($"{span.Seconds} second{(span.Seconds > 1 ? "s" : "")}");
var result = parts.ToArray();
return string.Join(", ", result[..^1]) + (result.Length > 1 ? " and " : "") + parts[^1];
}
public static string ToSmallText(this TimeSpan span)
{
List<string> parts = new();
if (span.Days / 365 > 0)
{
parts.Add($"{((double)span.Days / 365):F}y");
int months = span.Days % 365 / 30;
if (months > 0)
parts.Add($"{months}m");
int days = span.Days % 365 % 30;
if (days > 0)
parts.Add($"{days}d");
}
else if (span.Days / 30 > 0)
{
parts.Add($"{((double)span.Days / 30):F}m");
int days = span.Days % 30;
if (days > 0)
parts.Add($"{days}d");
}
else if (span.Days > 0)
parts.Add($"{span.Days}d");
if (span.Hours > 0)
parts.Add($"{span.Hours}h");
if (span.Minutes > 0)
parts.Add($"{span.Minutes}m");
if (span.Seconds > 0)
parts.Add($"{span.Seconds}s");
return string.Join(" ", parts);
}
}
}

View File

@ -8,21 +8,29 @@ namespace DiIiS_NA.Core.Extensions;
public static class EnumerableExtensions
{
public static string HexDump(this IEnumerable<byte> collection)
public static string ToHex(this byte b) => b.ToString("X2");
public static string HexDump(this byte[] collection, bool skipSpace = false)
{
var sb = new StringBuilder();
foreach (byte value in collection)
{
sb.Append(value.ToString("X2"));
sb.Append(' ');
sb.Append(value.ToHex());
if (!skipSpace)
sb.Append(' ');
}
if (sb.Length > 0)
if (!skipSpace && sb.Length > 0)
sb.Remove(sb.Length - 1, 1);
return sb.ToString();
}
public static string ToEncodedString(this IEnumerable<byte> collection, Encoding encoding)
public static string HexDump(this IEnumerable<byte> collection, bool skipSpace = false)
{
return collection.ToArray().HexDump(skipSpace);
}
public static string ToEncodedString(this IEnumerable<byte> collection, Encoding encoding = null)
{
encoding ??= Encoding.UTF8;
return encoding.GetString(collection.ToArray());
}
@ -34,7 +42,7 @@ public static class EnumerableExtensions
int i = 0;
foreach (byte value in collection)
{
if (i > 0 && ((i % 16) == 0))
if (i > 0 && i % 16 == 0)
{
output.Append(hex);
output.Append(' ');
@ -44,27 +52,21 @@ public static class EnumerableExtensions
}
hex.Append(value.ToString("X2"));
hex.Append(' ');
text.Append($"{((char.IsWhiteSpace((char)value) && (char)value != ' ') ? '.' : (char)value)}"); // prettify text
text.Append($"{(char.IsWhiteSpace((char)value) && (char)value != ' ' ? '.' : (char)value)}"); // prettify text
++i;
}
var hexstring = hex.ToString();
var hexRepresentation = hex.ToString();
if (text.Length < 16)
{
hexstring = hexstring.PadRight(48); // pad the hex representation in-case it's smaller than a regular 16 value line.
hexRepresentation = hexRepresentation.PadRight(48); // pad the hex representation in-case it's smaller than a regular 16 value line.
}
output.Append(hexstring);
output.Append(hexRepresentation);
output.Append(' ');
output.Append(text);
return output.ToString();
}
public static TItem PickRandom<TItem>(this IEnumerable<TItem> source)
{
return RandomHelper.RandomItem(source);
}
public static bool TryPickRandom<TItem>(this IEnumerable<TItem> source, out TItem randomItem)
{
return RandomHelper.TryGetRandomItem(source, out randomItem);
}
public static TItem PickRandom<TItem>(this IEnumerable<TItem> source) => RandomHelper.RandomItem(source);
public static bool TryPickRandom<TItem>(this IEnumerable<TItem> source, out TItem randomItem) => RandomHelper.TryGetRandomItem(source, out randomItem);
}

View File

@ -1,4 +1,9 @@
//Blizzless Project 2022
using System;
using System.Collections.Generic;
using System.Text;
namespace DiIiS_NA.Core.Extensions
{
public static class StringExtensions
@ -25,6 +30,7 @@ namespace DiIiS_NA.Core.Extensions
{
sB.Append((char)item);
}
ms.Close();
sw.Dispose();
ms.Dispose();
@ -53,11 +59,14 @@ namespace DiIiS_NA.Core.Extensions
{
sB.Append((char)byteArray[i]);
}
sr.Close();
ms.Close();
sr.Dispose();
ms.Dispose();
return sB.ToString();
}
public static byte[] ToBytes(this string bytes, Encoding encoding) => encoding.GetBytes(bytes);
public static byte[] ToBytes(this string bytes) => bytes.ToBytes(Encoding.UTF8);
}
}

View File

@ -17,8 +17,8 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
{
var stream = file.Open();
this.Header = new Header(stream);
this.I0 = stream.ReadValueS32();
Header = new Header(stream);
I0 = stream.ReadValueS32();
stream.Close();
}

View File

@ -20,20 +20,20 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
public Act(MpqFile file)
{
var stream = file.Open();
this.Header = new Header(stream);
Header = new Header(stream);
this.ActQuestInfo = stream.ReadSerializedData<ActQuestInfo>(); //12
ActQuestInfo = stream.ReadSerializedData<ActQuestInfo>(); //12
stream.Position += 12;
this.WayPointInfo = new WaypointInfo[100]; //32
WayPointInfo = new WaypointInfo[100]; //32
for (int i = 0; i < WayPointInfo.Length; i++)
this.WayPointInfo[i] = new WaypointInfo(stream);
WayPointInfo[i] = new WaypointInfo(stream);
this.ResolvedPortalDestination = new ResolvedPortalDestination(stream);
ResolvedPortalDestination = new ResolvedPortalDestination(stream);
this.ActStartLocOverrides = new ActStartLocOverride[6];
ActStartLocOverrides = new ActStartLocOverride[6];
for (int i = 0; i < ActStartLocOverrides.Length; i++)
this.ActStartLocOverrides[i] = new ActStartLocOverride(stream);
ActStartLocOverrides[i] = new ActStartLocOverride(stream);
stream.Close();
}

View File

@ -47,52 +47,52 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
var stream = file.Open();
Header = new Header(stream);
//+16
this.Flags = stream.ReadValueS32();
this.Type = (ActorType)stream.ReadValueS32();
this.ApperanceSNO = stream.ReadValueS32();
this.PhysMeshSNO = stream.ReadValueS32();
this.Cylinder = new AxialCylinder(stream);
this.Sphere = new Sphere(stream);
this.AABBBounds = new AABB(stream);
Flags = stream.ReadValueS32();
Type = (ActorType)stream.ReadValueS32();
ApperanceSNO = stream.ReadValueS32();
PhysMeshSNO = stream.ReadValueS32();
Cylinder = new AxialCylinder(stream);
Sphere = new Sphere(stream);
AABBBounds = new AABB(stream);
this.TagMap = stream.ReadSerializedItem<TagMap>();
TagMap = stream.ReadSerializedItem<TagMap>();
stream.Position += (2 * 4);
this.AnimSetSNO = stream.ReadValueS32();
this.MonsterSNO = stream.ReadValueS32();
AnimSetSNO = stream.ReadValueS32();
MonsterSNO = stream.ReadValueS32();
//stream.Position += 8;
MsgTriggeredEvents = stream.ReadSerializedData<MsgTriggeredEvent>();
this.AniimTreeSno = stream.ReadValueS32();
AniimTreeSno = stream.ReadValueS32();
//stream.Position += 4;
//this.IntNew = stream.ReadValueS32();
//stream.Position += 8;
this.MsgTriggeredEventCount = MsgTriggeredEvents.Count;
MsgTriggeredEventCount = MsgTriggeredEvents.Count;
stream.Position += 12;
this.LocationPowerSrc = new Vector3D(stream.ReadValueF32(), stream.ReadValueF32(), stream.ReadValueF32());
LocationPowerSrc = new Vector3D(stream.ReadValueF32(), stream.ReadValueF32(), stream.ReadValueF32());
this.Looks = new WeightedLook[8];
Looks = new WeightedLook[8];
for (int i = 0; i < 8; i++)
{
this.Looks[i] = new WeightedLook(stream);
Looks[i] = new WeightedLook(stream);
}
this.PhysicsSNO = stream.ReadValueS32();
this.PhysicsFlags = stream.ReadValueS32();
this.Material = stream.ReadValueS32();
this.ExplosiionFactor = stream.ReadValueF32();
this.WindFactor = stream.ReadValueF32();
this.PartialRagdollResponsiveness = stream.ReadValueF32();
PhysicsSNO = stream.ReadValueS32();
PhysicsFlags = stream.ReadValueS32();
Material = stream.ReadValueS32();
ExplosiionFactor = stream.ReadValueF32();
WindFactor = stream.ReadValueF32();
PartialRagdollResponsiveness = stream.ReadValueF32();
this.ActorCollisionData = new ActorCollisionData(stream);
ActorCollisionData = new ActorCollisionData(stream);
this.InventoryImages = new int[7]; //Was 5*8/4 - Darklotus
InventoryImages = new int[7]; //Was 5*8/4 - Darklotus
for (int i = 0; i < InventoryImages.Length; i++)
{
this.InventoryImages[i] = stream.ReadValueS32();
InventoryImages[i] = stream.ReadValueS32();
}
stream.Position += (4 * 7);
this.SocketedImage = stream.ReadValueS32();
SocketedImage = stream.ReadValueS32();
stream.Position += (4 * 5);
CastingNotes = stream.ReadSerializedString();
VoiceOverRole = stream.ReadSerializedString();
@ -129,10 +129,10 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
public ActorCollisionFlags(MpqFileStream stream)
{
this.I0 = stream.ReadValueS32();
this.I1 = stream.ReadValueS32();
this.I2 = stream.ReadValueS32();
this.I3 = stream.ReadValueS32();
I0 = stream.ReadValueS32();
I1 = stream.ReadValueS32();
I2 = stream.ReadValueS32();
I3 = stream.ReadValueS32();
}
}
@ -144,7 +144,7 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
public AxialCylinder(MpqFileStream stream)
{
this.Position = new Vector3D(stream.ReadValueF32(), stream.ReadValueF32(), stream.ReadValueF32());
Position = new Vector3D(stream.ReadValueF32(), stream.ReadValueF32(), stream.ReadValueF32());
Ax1 = stream.ReadValueF32();
Ax2 = stream.ReadValueF32();
}
@ -169,7 +169,7 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
public WeightedLook(MpqFileStream stream)
{
this.LookLink = stream.ReadString(64, true);
LookLink = stream.ReadString(64, true);
Int0 = stream.ReadValueS32();
}
}

View File

@ -20,13 +20,13 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
public Adventure(MpqFile file)
{
var stream = file.Open();
this.Header = new Header(stream);
this.ActorSNO = stream.ReadValueS32();
this.F0 = stream.ReadValueF32();
this.Angle0 = stream.ReadValueF32();
this.Angle1 = stream.ReadValueF32();
this.Angle2 = stream.ReadValueF32();
this.MarkerSetSNO = stream.ReadValueS32();
Header = new Header(stream);
ActorSNO = stream.ReadValueS32();
F0 = stream.ReadValueF32();
Angle0 = stream.ReadValueF32();
Angle1 = stream.ReadValueF32();
Angle2 = stream.ReadValueF32();
MarkerSetSNO = stream.ReadValueS32();
stream.Close();
}
}

View File

@ -26,15 +26,15 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
public AmbientSound(MpqFile file)
{
var stream = file.Open();
this.Header = new Header(stream);
this.I0 = stream.ReadValueS32();
this.SoundSNO00 = stream.ReadValueS32();
this.RandomAmbientSoundParams = new RandomAmbientSoundParams(stream);
Header = new Header(stream);
I0 = stream.ReadValueS32();
SoundSNO00 = stream.ReadValueS32();
RandomAmbientSoundParams = new RandomAmbientSoundParams(stream);
//stream.Position = 76;
this.SoundSNO01 = stream.ReadValueS32();
SoundSNO01 = stream.ReadValueS32();
Time01 = stream.ReadValueF32();
Time02 = stream.ReadValueF32();
this.Text = stream.ReadString(64);
Text = stream.ReadString(64);
F0 = stream.ReadValueF32();
F1 = stream.ReadValueF32();
F2 = stream.ReadValueF32();

View File

@ -22,14 +22,14 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
public Anim(MpqFile file)
{
var stream = file.Open();
this.Header = new Header(stream);
this.Flags = stream.ReadValueS32();
this.PlaybackMode = stream.ReadValueS32();
this.SNOAppearance = stream.ReadValueS32();
this.Permutations = stream.ReadSerializedData<AnimPermutation>();
this.PermutationCount = stream.ReadValueS32();
Header = new Header(stream);
Flags = stream.ReadValueS32();
PlaybackMode = stream.ReadValueS32();
SNOAppearance = stream.ReadValueS32();
Permutations = stream.ReadSerializedData<AnimPermutation>();
PermutationCount = stream.ReadValueS32();
stream.Position += 12;
this.MachineTime = stream.ReadValueS32();
MachineTime = stream.ReadValueS32();
stream.Close();
}
}
@ -74,49 +74,49 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
public void Read(MpqFileStream stream)
{
this.Flags = stream.ReadValueS32();
this.PermutationName = stream.ReadString(65, true);
Flags = stream.ReadValueS32();
PermutationName = stream.ReadString(65, true);
stream.Position += 3;
this.FrameRate = stream.ReadValueF32();
this.Compression = stream.ReadValueF32();
this.TramslationCompressionRatio = stream.ReadValueF32();
this.RotationComressionRatio = stream.ReadValueF32();
this.ScaleCompressionRatio = stream.ReadValueF32();
this.BlendTime = stream.ReadValueS32();
this.FromPermBlendTime = stream.ReadValueS32();
this.Weight = stream.ReadValueS32();
this.SpeedMultMin = stream.ReadValueF32();
this.SpeedMultDelta = stream.ReadValueF32();
this.RagdollVelocityFactor = stream.ReadValueF32();
this.RagdollMomentumFactor = stream.ReadValueF32();
this.BoneNameCount = stream.ReadValueS32();
this.BoneNames = stream.ReadSerializedData<BoneName>();
FrameRate = stream.ReadValueF32();
Compression = stream.ReadValueF32();
TramslationCompressionRatio = stream.ReadValueF32();
RotationComressionRatio = stream.ReadValueF32();
ScaleCompressionRatio = stream.ReadValueF32();
BlendTime = stream.ReadValueS32();
FromPermBlendTime = stream.ReadValueS32();
Weight = stream.ReadValueS32();
SpeedMultMin = stream.ReadValueF32();
SpeedMultDelta = stream.ReadValueF32();
RagdollVelocityFactor = stream.ReadValueF32();
RagdollMomentumFactor = stream.ReadValueF32();
BoneNameCount = stream.ReadValueS32();
BoneNames = stream.ReadSerializedData<BoneName>();
stream.Position += 12;
this.KeyframePosCount = stream.ReadValueS32();
this.TranslationCurves = stream.ReadSerializedData<TranslationCurve>();
KeyframePosCount = stream.ReadValueS32();
TranslationCurves = stream.ReadSerializedData<TranslationCurve>();
stream.Position += 12;
this.RotationCurves = stream.ReadSerializedData<RotationCurve>();
RotationCurves = stream.ReadSerializedData<RotationCurve>();
stream.Position += 8;
this.ScaleCurves = stream.ReadSerializedData<ScaleCurve>();
ScaleCurves = stream.ReadSerializedData<ScaleCurve>();
stream.Position += 8;
this.ContactKeyframe0 = stream.ReadValueF32();
this.ContactKeyframe1 = stream.ReadValueF32();
this.ContactKeyframe2 = stream.ReadValueF32();
this.ContactKeyframe3 = stream.ReadValueF32();
this.ContactOffset0 = new Vector3D(stream);
this.ContactOffset1 = new Vector3D(stream);
this.ContactOffset2 = new Vector3D(stream);
this.ContactOffset3 = new Vector3D(stream);
this.EarliestInterruptKeyFrame = stream.ReadValueF32();
this.KeyedAttachments = stream.ReadSerializedData<KeyframedAttachment>();
this.KeyedAttachmentsCount = stream.ReadValueS32();
ContactKeyframe0 = stream.ReadValueF32();
ContactKeyframe1 = stream.ReadValueF32();
ContactKeyframe2 = stream.ReadValueF32();
ContactKeyframe3 = stream.ReadValueF32();
ContactOffset0 = new Vector3D(stream);
ContactOffset1 = new Vector3D(stream);
ContactOffset2 = new Vector3D(stream);
ContactOffset3 = new Vector3D(stream);
EarliestInterruptKeyFrame = stream.ReadValueF32();
KeyedAttachments = stream.ReadSerializedData<KeyframedAttachment>();
KeyedAttachmentsCount = stream.ReadValueS32();
stream.Position += 8;
this.KeyframePosList = stream.ReadSerializedData<Vector3D>();
KeyframePosList = stream.ReadSerializedData<Vector3D>();
stream.Position += 8;
this.NonlinearOffset = stream.ReadSerializedData<Vector3D>();
NonlinearOffset = stream.ReadSerializedData<Vector3D>();
stream.Position += 8;
this.AvgVelocity = new VelocityVector3D(stream);
this.HardPointLink = new HardPointLink(stream);
AvgVelocity = new VelocityVector3D(stream);
HardPointLink = new HardPointLink(stream);
//this.S0 = stream.ReadString(256, true);
//this.S1 = stream.ReadString(256, true);
stream.Position += 8;
@ -129,7 +129,7 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
public void Read(MpqFileStream stream)
{
this.Name = stream.ReadString(64, true);
Name = stream.ReadString(64, true);
}
}
@ -140,8 +140,8 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
public void Read(MpqFileStream stream)
{
this.I0 = stream.ReadValueS32();
this.Keys = stream.ReadSerializedData<TranslationKey>();
I0 = stream.ReadValueS32();
Keys = stream.ReadSerializedData<TranslationKey>();
}
}
@ -152,8 +152,8 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
public void Read(MpqFileStream stream)
{
this.I0 = stream.ReadValueS32();
this.Keys = stream.ReadSerializedData<RotationKey>();
I0 = stream.ReadValueS32();
Keys = stream.ReadSerializedData<RotationKey>();
}
}
@ -164,8 +164,8 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
public void Read(MpqFileStream stream)
{
this.I0 = stream.ReadValueS32();
this.Keys = stream.ReadSerializedData<ScaleKey>();
I0 = stream.ReadValueS32();
Keys = stream.ReadSerializedData<ScaleKey>();
}
}
@ -176,8 +176,8 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
public void Read(MpqFileStream stream)
{
this.I0 = stream.ReadValueS32();
this.Location = new Vector3D(stream);
I0 = stream.ReadValueS32();
Location = new Vector3D(stream);
}
}
@ -188,8 +188,8 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
public void Read(MpqFileStream stream)
{
this.I0 = stream.ReadValueS32();
this.Q0 = new Quaternion16(stream);
I0 = stream.ReadValueS32();
Q0 = new Quaternion16(stream);
}
}
@ -200,8 +200,8 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
public void Read(MpqFileStream stream)
{
this.I0 = stream.ReadValueS32();
this.Scale = stream.ReadValueF32();
I0 = stream.ReadValueS32();
Scale = stream.ReadValueF32();
}
}
@ -212,8 +212,8 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
public void Read(MpqFileStream stream)
{
this.KeyframeIndex = stream.ReadValueF32();
this.Event = new TriggerEvent(stream);
KeyframeIndex = stream.ReadValueF32();
Event = new TriggerEvent(stream);
}
}
@ -225,9 +225,9 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
public VelocityVector3D(MpqFileStream stream)
{
this.VelocityX = stream.ReadValueF32();
this.VelocityY = stream.ReadValueF32();
this.VelocityZ = stream.ReadValueF32();
VelocityX = stream.ReadValueF32();
VelocityY = stream.ReadValueF32();
VelocityZ = stream.ReadValueF32();
}
}
@ -246,10 +246,10 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
/// <param name="stream">The MPQFileStream to read from.</param>
public Quaternion16(MpqFileStream stream)
{
this.Short0 = stream.ReadValueS16();
this.Short1 = stream.ReadValueS16();
this.Short2 = stream.ReadValueS16();
this.Short3 = stream.ReadValueS16();
Short0 = stream.ReadValueS16();
Short1 = stream.ReadValueS16();
Short2 = stream.ReadValueS16();
Short3 = stream.ReadValueS16();
}
}
}

View File

@ -63,8 +63,8 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
public AnimSet(MpqFile file)
{
var stream = file.Open();
this.Header = new Header(stream);
this.SNOParentAnimSet = stream.ReadValueS32();
Header = new Header(stream);
SNOParentAnimSet = stream.ReadValueS32();
TagMapAnimDefault = stream.ReadSerializedItem<TagMap>();
stream.Position += 8;
AnimSetTagMaps = new TagMap[28];

View File

@ -20,13 +20,13 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
public Animation2D(MpqFile file)
{
var stream = file.Open();
this.Header = new Header(stream);
this.I0 = stream.ReadValueS32();
this.I1 = stream.ReadValueS32();
this.FrameAnim = new FrameAnim(stream);
this.SNOSound = stream.ReadValueS32();
this.I2 = stream.ReadValueS32();
this.Anim2DFrame = new Anim2DFrame(stream);
Header = new Header(stream);
I0 = stream.ReadValueS32();
I1 = stream.ReadValueS32();
FrameAnim = new FrameAnim(stream);
SNOSound = stream.ReadValueS32();
I2 = stream.ReadValueS32();
Anim2DFrame = new Anim2DFrame(stream);
stream.Close();
}
@ -42,11 +42,11 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
public FrameAnim(MpqFileStream stream)
{
this.I0 = stream.ReadValueS32();
this.Velocity0 = stream.ReadValueF32();
this.Velocity1 = stream.ReadValueF32();
this.I1 = stream.ReadValueS32();
this.I2 = stream.ReadValueS32();
I0 = stream.ReadValueS32();
Velocity0 = stream.ReadValueF32();
Velocity1 = stream.ReadValueF32();
I1 = stream.ReadValueS32();
I2 = stream.ReadValueS32();
}
}
public class Anim2DFrame
@ -56,7 +56,7 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
public Anim2DFrame(MpqFileStream stream)
{
this.Text = stream.ReadString(64);
Text = stream.ReadString(64);
DT_RGBACOLOR = new DT_RGBACOLOR(stream);
}
}
@ -69,10 +69,10 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
public DT_RGBACOLOR(MpqFileStream stream)
{
this.B0 = stream.ReadValueU8();
this.B1 = stream.ReadValueU8();
this.B2 = stream.ReadValueU8();
this.B3 = stream.ReadValueU8();
B0 = stream.ReadValueU8();
B1 = stream.ReadValueU8();
B2 = stream.ReadValueU8();
B3 = stream.ReadValueU8();
}
}
}

View File

@ -32,29 +32,29 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
public BossEncounter(MpqFile file)
{
var stream = file.Open();
this.Header = new Header(stream);
this.I0 = stream.ReadValueS32();
this.I1 = stream.ReadValueS32();
this.I2 = stream.ReadValueS32();
this.I3 = stream.ReadValueS32();
this.I4 = stream.ReadValueS32();
this.I5 = stream.ReadValueS32();
this.I6 = stream.ReadValueS32();
this.I7 = stream.ReadValueS32();
this.I8 = stream.ReadValueS32();
this.I9 = stream.ReadValueS32();
this.I10 = stream.ReadValueS32();
this.I11 = stream.ReadValueS32();
this.F0 = stream.ReadValueF32();
this.SNOQuestRange = stream.ReadValueS32();
this.Worlds = new int[4];
Header = new Header(stream);
I0 = stream.ReadValueS32();
I1 = stream.ReadValueS32();
I2 = stream.ReadValueS32();
I3 = stream.ReadValueS32();
I4 = stream.ReadValueS32();
I5 = stream.ReadValueS32();
I6 = stream.ReadValueS32();
I7 = stream.ReadValueS32();
I8 = stream.ReadValueS32();
I9 = stream.ReadValueS32();
I10 = stream.ReadValueS32();
I11 = stream.ReadValueS32();
F0 = stream.ReadValueF32();
SNOQuestRange = stream.ReadValueS32();
Worlds = new int[4];
for (int i = 0; i < 4; i++)
this.Worlds[i] = stream.ReadValueS32();
this.Scripts = new int[3];
Worlds[i] = stream.ReadValueS32();
Scripts = new int[3];
for (int i = 0; i < 3; i++)
this.Scripts[i] = stream.ReadValueS32();
this.LevelAreaSNO = stream.ReadValueS32();
this.ActorSNO = stream.ReadValueS32();
Scripts[i] = stream.ReadValueS32();
LevelAreaSNO = stream.ReadValueS32();
ActorSNO = stream.ReadValueS32();
stream.Close();
}
}

View File

@ -70,94 +70,94 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
public Condition(MpqFile file)
{
var stream = file.Open();
this.Header = new Header(stream); //0
Header = new Header(stream); //0
//+16
this.I0 = stream.ReadValueS32(); //12 + 16 = 28
this.I1 = stream.ReadValueS32(); //32
this.Class = new int[7]; //36
I0 = stream.ReadValueS32(); //12 + 16 = 28
I1 = stream.ReadValueS32(); //32
Class = new int[7]; //36
for (int i = 0; i < 7; i++)
this.Class[i] = stream.ReadValueS32();
Class[i] = stream.ReadValueS32();
this.I2 = stream.ReadValueS32(); //48 + 16 = 64
this.I3 = stream.ReadValueS32(); //68
this.I4 = stream.ReadValueS32(); //72
this.I5 = stream.ReadValueS32(); //76
I2 = stream.ReadValueS32(); //48 + 16 = 64
I3 = stream.ReadValueS32(); //68
I4 = stream.ReadValueS32(); //72
I5 = stream.ReadValueS32(); //76
this.LoreCondition = new LoreSubcondition[3]; //80
LoreCondition = new LoreSubcondition[3]; //80
for (int i = 0; i < 3; i++)
this.LoreCondition[i] = new LoreSubcondition(stream);
LoreCondition[i] = new LoreSubcondition(stream);
this.QuestCondition = new QuestSubcondition[3]; //104
QuestCondition = new QuestSubcondition[3]; //104
for (int i = 0; i < 3; i++)
this.QuestCondition[i] = new QuestSubcondition(stream);
QuestCondition[i] = new QuestSubcondition(stream);
this.I6 = stream.ReadValueS32(); //152
this.I7 = stream.ReadValueS32(); //156
this.I8 = stream.ReadValueS32(); //160
this.ItemCondition = new ItemSubcondition[3]; //164
I6 = stream.ReadValueS32(); //152
I7 = stream.ReadValueS32(); //156
I8 = stream.ReadValueS32(); //160
ItemCondition = new ItemSubcondition[3]; //164
for (int i = 0; i < 3; i++)
this.ItemCondition[i] = new ItemSubcondition(stream);
ItemCondition[i] = new ItemSubcondition(stream);
this.I9 = stream.ReadValueS32(); //212
this.I10 = stream.ReadValueS32(); //216
this.I11 = stream.ReadValueS32(); //220
this.I12 = stream.ReadValueS32(); //224
this.I13 = stream.ReadValueS32(); //228
I9 = stream.ReadValueS32(); //212
I10 = stream.ReadValueS32(); //216
I11 = stream.ReadValueS32(); //220
I12 = stream.ReadValueS32(); //224
I13 = stream.ReadValueS32(); //228
this.I14 = stream.ReadValueS32(); //232
this.I15 = stream.ReadValueS32(); //236
this.I16 = stream.ReadValueS32(); //240
I14 = stream.ReadValueS32(); //232
I15 = stream.ReadValueS32(); //236
I16 = stream.ReadValueS32(); //240
stream.Position += 4;
this.I17 = stream.ReadValueS32(); //248
this.I18 = stream.ReadValueS32(); //252
I17 = stream.ReadValueS32(); //248
I18 = stream.ReadValueS32(); //252
this.I19 = stream.ReadValueS32(); //256
this.I20 = stream.ReadValueS32(); //260
I19 = stream.ReadValueS32(); //256
I20 = stream.ReadValueS32(); //260
this.SNOCurrentWorld = stream.ReadValueS32(); //264
this.SNOCurrentLevelArea = stream.ReadValueS32(); //268
this.SNOQuestRange = stream.ReadValueS32(); //272
this.FollowerCondition = new FollowerSubcondition(stream); //276
SNOCurrentWorld = stream.ReadValueS32(); //264
SNOCurrentLevelArea = stream.ReadValueS32(); //268
SNOQuestRange = stream.ReadValueS32(); //272
FollowerCondition = new FollowerSubcondition(stream); //276
this.LabelCondition = new LabelSubcondition[3]; //284
LabelCondition = new LabelSubcondition[3]; //284
for (int i = 0; i < 3; i++)
this.LabelCondition[i] = new LabelSubcondition(stream);
LabelCondition[i] = new LabelSubcondition(stream);
this.SkillCondition = new SkillSubcondition[3]; //308
SkillCondition = new SkillSubcondition[3]; //308
for (int i = 0; i < 3; i++)
this.SkillCondition[i] = new SkillSubcondition(stream);
SkillCondition[i] = new SkillSubcondition(stream);
this.I21 = stream.ReadValueS32(); //344
this.I22 = stream.ReadValueS32(); //348
this.I23 = stream.ReadValueS32(); //352
this.I24 = stream.ReadValueS32(); //356
this.I25 = stream.ReadValueS32(); //360
I21 = stream.ReadValueS32(); //344
I22 = stream.ReadValueS32(); //348
I23 = stream.ReadValueS32(); //352
I24 = stream.ReadValueS32(); //356
I25 = stream.ReadValueS32(); //360
this.I26 = stream.ReadValueS32(); //364
this.I27 = stream.ReadValueS32(); //368
this.I28 = stream.ReadValueS32(); //372
this.I29 = stream.ReadValueS32(); //376
I26 = stream.ReadValueS32(); //364
I27 = stream.ReadValueS32(); //368
I28 = stream.ReadValueS32(); //372
I29 = stream.ReadValueS32(); //376
this.MonsterCondition = new MonsterSubcondition[15]; //380
MonsterCondition = new MonsterSubcondition[15]; //380
for (int i = 0; i < 15; i++)
this.MonsterCondition[i] = new MonsterSubcondition(stream);
MonsterCondition[i] = new MonsterSubcondition(stream);
this.GameFlagCondition = new GameFlagSubcondition[3]; //440
GameFlagCondition = new GameFlagSubcondition[3]; //440
for (int i = 0; i < 3; i++)
this.GameFlagCondition[i] = new GameFlagSubcondition(stream);
GameFlagCondition[i] = new GameFlagSubcondition(stream);
this.PlayerFlagCondition = new PlayerFlagSubcondition[3]; //824
PlayerFlagCondition = new PlayerFlagSubcondition[3]; //824
for (int i = 0; i < 3; i++)
this.PlayerFlagCondition[i] = new PlayerFlagSubcondition(stream);
PlayerFlagCondition[i] = new PlayerFlagSubcondition(stream);
this.BuffSubCondition = new BuffSubcondition[3]; //1208
BuffSubCondition = new BuffSubcondition[3]; //1208
for (int i = 0; i < 3; i++)
this.BuffSubCondition[i] = new BuffSubcondition(stream);
BuffSubCondition[i] = new BuffSubcondition(stream);
this.I30 = stream.ReadValueS32(); //1244
this.I31 = stream.ReadValueS32(); //1248
this.I32 = stream.ReadValueS32(); //1252
I30 = stream.ReadValueS32(); //1244
I31 = stream.ReadValueS32(); //1248
I32 = stream.ReadValueS32(); //1252
stream.Close();
}
@ -170,8 +170,8 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
public LoreSubcondition(MpqFileStream stream)
{
this.SNOLore = stream.ReadValueS32();
this.I0 = stream.ReadValueS32();
SNOLore = stream.ReadValueS32();
I0 = stream.ReadValueS32();
}
}
@ -184,10 +184,10 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
public QuestSubcondition(MpqFileStream stream)
{
this.SNOQuest = stream.ReadValueS32();
this.I0 = stream.ReadValueS32();
this.I1 = stream.ReadValueS32();
this.I2 = stream.ReadValueS32();
SNOQuest = stream.ReadValueS32();
I0 = stream.ReadValueS32();
I1 = stream.ReadValueS32();
I2 = stream.ReadValueS32();
}
}
@ -200,10 +200,10 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
public ItemSubcondition(MpqFileStream stream)
{
this.ItemGBId = stream.ReadValueS32();
this.I0 = stream.ReadValueS32();
this.I1 = stream.ReadValueS32();
this.I2 = stream.ReadValueS32();
ItemGBId = stream.ReadValueS32();
I0 = stream.ReadValueS32();
I1 = stream.ReadValueS32();
I2 = stream.ReadValueS32();
}
}
@ -214,8 +214,8 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
public FollowerSubcondition(MpqFileStream stream)
{
this.Type = (FollowerType)stream.ReadValueS32();
this.I0 = stream.ReadValueS32();
Type = (FollowerType)stream.ReadValueS32();
I0 = stream.ReadValueS32();
}
}
@ -226,8 +226,8 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
public LabelSubcondition(MpqFileStream stream)
{
this.LabelGBId = stream.ReadValueS32();
this.I0 = stream.ReadValueS32();
LabelGBId = stream.ReadValueS32();
I0 = stream.ReadValueS32();
}
}
@ -239,9 +239,9 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
public SkillSubcondition(MpqFileStream stream)
{
this.SNOSkillPower = stream.ReadValueS32();
this.I0 = stream.ReadValueS32();
this.I1 = stream.ReadValueS32();
SNOSkillPower = stream.ReadValueS32();
I0 = stream.ReadValueS32();
I1 = stream.ReadValueS32();
}
}
@ -251,7 +251,7 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
public MonsterSubcondition(MpqFileStream stream)
{
this.SNOMonsterActor = stream.ReadValueS32();
SNOMonsterActor = stream.ReadValueS32();
}
}
@ -261,7 +261,7 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
public GameFlagSubcondition(MpqFileStream stream)
{
this.S0 = stream.ReadString(128, true);
S0 = stream.ReadString(128, true);
}
}
@ -271,7 +271,7 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
public PlayerFlagSubcondition(MpqFileStream stream)
{
this.S0 = stream.ReadString(128, true);
S0 = stream.ReadString(128, true);
}
}
@ -283,9 +283,9 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
public BuffSubcondition(MpqFileStream stream)
{
this.SNOPower = stream.ReadValueS32();
this.I0 = stream.ReadValueS32();
this.I1 = stream.ReadValueS32();
SNOPower = stream.ReadValueS32();
I0 = stream.ReadValueS32();
I1 = stream.ReadValueS32();
}
}

View File

@ -5,6 +5,7 @@ using CrystalMpq;
using Gibbed.IO;
using DiIiS_NA.GameServer.Core.Types.SNO;
using DiIiS_NA.Core.MPQ.FileFormats.Types;
using Newtonsoft.Json;
namespace DiIiS_NA.Core.MPQ.FileFormats
{
@ -33,31 +34,31 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
{
MpqFileStream stream = file.Open();
this.Header = new Header(stream); //0
Header = new Header(stream); //0
//+16
this.ConversationType = (ConversationTypes)stream.ReadValueS32(); //12
this.ConversationIcon = stream.ReadValueS32(); //16
this.snoConvPiggyback = stream.ReadValueS32(); //20
ConversationType = (ConversationTypes)stream.ReadValueS32(); //12
ConversationIcon = stream.ReadValueS32(); //16
snoConvPiggyback = stream.ReadValueS32(); //20
this.snoConvUnlocks = new int[3];
snoConvUnlocks = new int[3];
for (int i = 0; i < snoConvUnlocks.Length; i++) //24
this.snoConvUnlocks[i] = stream.ReadValueS32();
snoConvUnlocks[i] = stream.ReadValueS32();
this.Flags = stream.ReadValueS32(); //36
this.SetPlayerFlags = stream.ReadString(128, true); //40
this.SNOPrimaryNpc = stream.ReadValueS32(); //168
this.SNOAltNpc1 = stream.ReadValueS32(); //172
this.SNOAltNpc2 = stream.ReadValueS32(); //176
this.SNOAltNpc3 = stream.ReadValueS32(); //180
this.SNOAltNpc4 = stream.ReadValueS32(); //184
this.LineUID = stream.ReadValueS32(); //188-192
Flags = stream.ReadValueS32(); //36
SetPlayerFlags = stream.ReadString(128, true); //40
SNOPrimaryNpc = stream.ReadValueS32(); //168
SNOAltNpc1 = stream.ReadValueS32(); //172
SNOAltNpc2 = stream.ReadValueS32(); //176
SNOAltNpc3 = stream.ReadValueS32(); //180
SNOAltNpc4 = stream.ReadValueS32(); //184
LineUID = stream.ReadValueS32(); //188-192
stream.Position += 8;
RootTreeNodes = stream.ReadSerializedData<ConversationTreeNode>(); // 200
stream.Position = stream.Position;
CompiiledScript = stream.ReadSerializedByteArray(); //216
stream.Position = stream.Position;
this.SNOBossEncounter = stream.ReadValueS32(); //264
this.Pad = stream.ReadValueS32(); //268
SNOBossEncounter = stream.ReadValueS32(); //264
Pad = stream.ReadValueS32(); //268
stream.Close();
}
@ -129,15 +130,15 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
ClassFilter = stream.ReadValueS32();
for (int i = 0; i < CompressedDisplayTimes.Length; i++) //40 //328
CompressedDisplayTimes[i] = new ConvLocalDisplayTimes(stream);
this.GBIDConvVarCheck = stream.ReadValueS32(); //1104
GBIDConvVarCheck = stream.ReadValueS32(); //1104
ConvVarCheckOp = (TypeConv)stream.ReadValueS32();
this.ConvVarCheckVal = stream.ReadValueS32();
this.GBIDConvVarSet = stream.ReadValueS32();
ConvVarCheckVal = stream.ReadValueS32();
GBIDConvVarSet = stream.ReadValueS32();
ConvVarSetOp = (Ref)stream.ReadValueS32(); //1408
this.ConvVarSetVal = stream.ReadValueS32();
this.BranchIndex = stream.ReadValueS32();
this.Weight = stream.ReadValueS32();
ConvVarSetVal = stream.ReadValueS32();
BranchIndex = stream.ReadValueS32();
Weight = stream.ReadValueS32();
//strea3.Position += 4; // these are unaccounted for...xml offsets just skips ahead
stream.Position += (2 * 4);
TrueNodes = stream.ReadSerializedData<ConversationTreeNode>();
@ -190,14 +191,13 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
s.Append(' ', pad); s.AppendLine("}");
}
}
}
public class ConvLocalDisplayTimes
{
public int[] Languages = new int[14];
public ConvLocalDisplayTimes(CrystalMpq.MpqFileStream stream)
public ConvLocalDisplayTimes(MpqFileStream stream)
{
for (int i = 0; i < Languages.Length; i++)
Languages[i] = stream.ReadValueS32();

View File

@ -17,8 +17,8 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
public ConversationList()
{
if (this.ConversationListEntries == null) this.ConversationListEntries = new List<ConversationListEntry>();
if (this.AmbientConversationListEntries == null) this.AmbientConversationListEntries = new List<ConversationListEntry>();
if (ConversationListEntries == null) ConversationListEntries = new List<ConversationListEntry>();
if (AmbientConversationListEntries == null) AmbientConversationListEntries = new List<ConversationListEntry>();
}
}
@ -29,11 +29,11 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
{
get
{
return (ConversationTypes)this.Flags;
return (ConversationTypes)Flags;
}
set
{
this.Flags = (int)value;
Flags = (int)value;
}
}
@ -86,22 +86,22 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
//*
public ConversationListEntry(ConversationTypes type, int i0, int questId, int convId, int questStep, int act)
{
this.SNOConversation = convId;
this.SpecialEventFlag = act;
this.Type = type;
this.SNOQuestCurrent = -1;
this.SNOQuestAssigned = -1;
this.SNOQuestComplete = -1;
this.SNOQuestRange = -1;
this.SNOLevelArea = -1;
this.SNOQuestActive = questId;
this.ConditionReqs = i0;
SNOConversation = convId;
SpecialEventFlag = act;
Type = type;
SNOQuestCurrent = -1;
SNOQuestAssigned = -1;
SNOQuestComplete = -1;
SNOQuestRange = -1;
SNOLevelArea = -1;
SNOQuestActive = questId;
ConditionReqs = i0;
//this.I1 = -1;
this.CrafterType = -1;
this.StepUIDCurrent = questStep;
this.GbidItem = -1;
this.Label = "";
this.PlayerFlag = "";
CrafterType = -1;
StepUIDCurrent = questStep;
GbidItem = -1;
Label = "";
PlayerFlag = "";
}
}
}

View File

@ -24,15 +24,15 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
public EffectGroup(MpqFile file)
{
var stream = file.Open();
this.Header = new Header(stream);
this.I0 = stream.ReadValueS32();
this.EffectItems = stream.ReadSerializedData<EffectItem>();
this.EffectItemsCount = stream.ReadValueS32();
Header = new Header(stream);
I0 = stream.ReadValueS32();
EffectItems = stream.ReadSerializedData<EffectItem>();
EffectItemsCount = stream.ReadValueS32();
stream.Position += 12; // pad 1
this.I2 = stream.ReadValueS32();
this.I3 = stream.ReadValueS32();
this.I4 = stream.ReadValueS32();
this.SnoPower = stream.ReadValueS32();
I2 = stream.ReadValueS32();
I3 = stream.ReadValueS32();
I4 = stream.ReadValueS32();
SnoPower = stream.ReadValueS32();
I5 = new int[16];
for (int i = 0; i < I5.Length; i++)
@ -49,9 +49,9 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
public void Read(MpqFileStream stream)
{
this.Weight = stream.ReadValueS32();
this.Hash = stream.ReadString(64, true);
this.TriggeredEvent.Read(stream);
Weight = stream.ReadValueS32();
Hash = stream.ReadString(64, true);
TriggeredEvent.Read(stream);
}
}
}

View File

@ -17,10 +17,10 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
public Encounter(MpqFile file)
{
var stream = file.Open();
this.Header = new Header(stream);
this.SNOSpawn = stream.ReadValueS32();
Header = new Header(stream);
SNOSpawn = stream.ReadValueS32();
stream.Position += (2 * 4);// pad 2 int
this.Spawnoptions = stream.ReadSerializedData<EncounterSpawnOptions>();
Spawnoptions = stream.ReadSerializedData<EncounterSpawnOptions>();
stream.Close();
}
}
@ -34,10 +34,10 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
public void Read(MpqFileStream stream)
{
this.SNOSpawn = stream.ReadValueS32();
this.Probability = stream.ReadValueS32();
this.I1 = stream.ReadValueS32();
this.SNOCondition = stream.ReadValueS32();
SNOSpawn = stream.ReadValueS32();
Probability = stream.ReadValueS32();
I1 = stream.ReadValueS32();
SNOCondition = stream.ReadValueS32();
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -127,50 +127,50 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
public Globals(MpqFile file)
{
var stream = file.Open();
this.Header = new Header(stream);
Header = new Header(stream);
stream.Position += (3 * 4);
this.ServerData = stream.ReadSerializedData<GlobalServerData>();
ServerData = stream.ReadSerializedData<GlobalServerData>();
stream.Position += 4;
this.I0 = stream.ReadValueS32(); //32
I0 = stream.ReadValueS32(); //32
stream.Position += 12;
this.StartLocationNames = new Dictionary<int, FileFormats.StartLocationName>();
StartLocationNames = new Dictionary<int, StartLocationName>();
foreach (var startLocation in stream.ReadSerializedData<StartLocationName>())
StartLocationNames.Add(startLocation.I0, startLocation);
this.F0 = stream.ReadValueF32(); //56
this.F1 = stream.ReadValueF32(); //60
this.F2 = stream.ReadValueF32(); //64
this.F3 = stream.ReadValueF32(); //68
F0 = stream.ReadValueF32(); //56
F1 = stream.ReadValueF32(); //60
F2 = stream.ReadValueF32(); //64
F3 = stream.ReadValueF32(); //68
this.I1 = stream.ReadValueS32();
this.I2 = stream.ReadValueS32();
this.F4 = stream.ReadValueF32();
this.F5 = stream.ReadValueF32();
this.I3 = stream.ReadValueS32();
this.F6 = stream.ReadValueF32();
this.F7 = stream.ReadValueF32();
this.F8 = stream.ReadValueF32();
this.F9 = stream.ReadValueF32();
this.F10 = stream.ReadValueF32();
this.I4 = stream.ReadValueS32();
this.I6 = new int[4];
I1 = stream.ReadValueS32();
I2 = stream.ReadValueS32();
F4 = stream.ReadValueF32();
F5 = stream.ReadValueF32();
I3 = stream.ReadValueS32();
F6 = stream.ReadValueF32();
F7 = stream.ReadValueF32();
F8 = stream.ReadValueF32();
F9 = stream.ReadValueF32();
F10 = stream.ReadValueF32();
I4 = stream.ReadValueS32();
I6 = new int[4];
for (int i = 0; i < 4; i++)
this.I6[i] = stream.ReadValueS32();
I6[i] = stream.ReadValueS32();
stream.Position += 4;
this.BannerParams = new BannerParams(stream);
this.I5 = stream.ReadValueS32();
this.I7 = stream.ReadValueS32();
this.I8 = stream.ReadValueS32();
this.I9 = stream.ReadValueS32();
this.F11 = stream.ReadValueF32();
this.F12 = stream.ReadValueF32();
this.F13 = stream.ReadValueF32();
this.F14 = stream.ReadValueF32();
this.F15 = stream.ReadValueF32();
this.F16 = stream.ReadValueF32();
this.F17 = stream.ReadValueF32();
this.F18 = stream.ReadValueF32();
BannerParams = new BannerParams(stream);
I5 = stream.ReadValueS32();
I7 = stream.ReadValueS32();
I8 = stream.ReadValueS32();
I9 = stream.ReadValueS32();
F11 = stream.ReadValueF32();
F12 = stream.ReadValueF32();
F13 = stream.ReadValueF32();
F14 = stream.ReadValueF32();
F15 = stream.ReadValueF32();
F16 = stream.ReadValueF32();
F17 = stream.ReadValueF32();
F18 = stream.ReadValueF32();
stream.Close();
}
}
@ -190,16 +190,16 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
public DifficultyTuningParams(MpqFileStream stream)
{
this.F0 = stream.ReadValueF32();
this.F1 = stream.ReadValueF32();
this.F2 = stream.ReadValueF32();
this.F3 = stream.ReadValueF32();
this.F4 = stream.ReadValueF32();
this.F5 = stream.ReadValueF32();
this.F6 = stream.ReadValueF32();
this.F7 = stream.ReadValueF32();
this.F8 = stream.ReadValueF32();
this.F9 = stream.ReadValueF32();
F0 = stream.ReadValueF32();
F1 = stream.ReadValueF32();
F2 = stream.ReadValueF32();
F3 = stream.ReadValueF32();
F4 = stream.ReadValueF32();
F5 = stream.ReadValueF32();
F6 = stream.ReadValueF32();
F7 = stream.ReadValueF32();
F8 = stream.ReadValueF32();
F9 = stream.ReadValueF32();
}
}
@ -210,8 +210,8 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
public void Read(MpqFileStream stream)
{
this.UHash = stream.ReadValueS32();
this.S0 = stream.ReadString(64, true);
UHash = stream.ReadValueS32();
S0 = stream.ReadString(64, true);
}
}
@ -222,8 +222,8 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
public void Read(MpqFileStream stream)
{
this.I0 = stream.ReadValueS32();
this.S0 = stream.ReadString(64, true);
I0 = stream.ReadValueS32();
S0 = stream.ReadString(64, true);
}
}
@ -235,9 +235,9 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
public void Read(MpqFileStream stream)
{
this.UHash = stream.ReadValueS32();
this.S0 = stream.ReadString(32, true);
this.F0 = stream.ReadValueF32();
UHash = stream.ReadValueS32();
S0 = stream.ReadString(32, true);
F0 = stream.ReadValueF32();
}
}
@ -389,48 +389,48 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
public float F65 { get; private set; }
public void Read(MpqFileStream stream)
{
this.ActorGroups = new Dictionary<int, FileFormats.ActorGroup>();
ActorGroups = new Dictionary<int, ActorGroup>();
foreach (var group in stream.ReadSerializedData<ActorGroup>()) //166
this.ActorGroups.Add(group.UHash, group);
ActorGroups.Add(group.UHash, group);
stream.Position += 8;
this.ScriptGlobalVars = stream.ReadSerializedData<GlobalScriptVariable>();
ScriptGlobalVars = stream.ReadSerializedData<GlobalScriptVariable>();
stream.Position += 8;
this.TuningParams = new DifficultyTuningParams[4];
TuningParams = new DifficultyTuningParams[4];
for (int i = 0; i < 4; i++)
this.TuningParams[i] = new DifficultyTuningParams(stream);
this.F0 = stream.ReadValueF32();
this.F1 = stream.ReadValueF32();
this.F2 = stream.ReadValueF32();
this.F3 = stream.ReadValueF32();
this.F4 = stream.ReadValueF32();
this.I0 = stream.ReadValueS32();
this.I1 = stream.ReadValueS32();
this.F5 = stream.ReadValueF32();
this.F6 = stream.ReadValueF32();
this.F7 = stream.ReadValueF32();
this.F8 = stream.ReadValueF32();
this.F20 = stream.ReadValueF32();
this.F21 = stream.ReadValueF32();
this.F22 = stream.ReadValueF32();
this.I5 = stream.ReadValueS32();
this.F23 = stream.ReadValueF32();
this.I2 = stream.ReadValueS32();
this.I3 = stream.ReadValueS32();
this.I4 = stream.ReadValueS32();
this.F9 = stream.ReadValueF32();
this.F10 = stream.ReadValueF32();
this.F11 = stream.ReadValueF32();
this.F12 = stream.ReadValueF32();
this.F13 = stream.ReadValueF32();
this.F14 = stream.ReadValueF32();
this.F15 = stream.ReadValueF32();
this.F16 = stream.ReadValueF32();
this.F17 = stream.ReadValueF32();
this.F18 = stream.ReadValueF32();
this.F28 = new float[17];
TuningParams[i] = new DifficultyTuningParams(stream);
F0 = stream.ReadValueF32();
F1 = stream.ReadValueF32();
F2 = stream.ReadValueF32();
F3 = stream.ReadValueF32();
F4 = stream.ReadValueF32();
I0 = stream.ReadValueS32();
I1 = stream.ReadValueS32();
F5 = stream.ReadValueF32();
F6 = stream.ReadValueF32();
F7 = stream.ReadValueF32();
F8 = stream.ReadValueF32();
F20 = stream.ReadValueF32();
F21 = stream.ReadValueF32();
F22 = stream.ReadValueF32();
I5 = stream.ReadValueS32();
F23 = stream.ReadValueF32();
I2 = stream.ReadValueS32();
I3 = stream.ReadValueS32();
I4 = stream.ReadValueS32();
F9 = stream.ReadValueF32();
F10 = stream.ReadValueF32();
F11 = stream.ReadValueF32();
F12 = stream.ReadValueF32();
F13 = stream.ReadValueF32();
F14 = stream.ReadValueF32();
F15 = stream.ReadValueF32();
F16 = stream.ReadValueF32();
F17 = stream.ReadValueF32();
F18 = stream.ReadValueF32();
F28 = new float[17];
for (var i = 0; i < 17; i++)
this.F28[i] = stream.ReadValueF32();
F28[i] = stream.ReadValueF32();
}
}
@ -454,33 +454,33 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
public BannerParams(MpqFileStream stream)
{
stream.Position += 8;
this.TexBackgrounds = stream.ReadSerializedData<BannerTexturePair>();
this.I0 = stream.ReadValueS32(); //16
TexBackgrounds = stream.ReadSerializedData<BannerTexturePair>();
I0 = stream.ReadValueS32(); //16
stream.Position += 12;
this.TexPatterns = stream.ReadSerializedData<BannerTexturePair>();
this.I0 = stream.ReadValueS32(); //40
TexPatterns = stream.ReadSerializedData<BannerTexturePair>();
I0 = stream.ReadValueS32(); //40
stream.Position += 12;
this.TexMainSigils = stream.ReadSerializedData<BannerTexturePair>();
TexMainSigils = stream.ReadSerializedData<BannerTexturePair>();
stream.Position += 8;
this.TexVariantSigils = stream.ReadSerializedData<BannerTexturePair>();
this.I0 = stream.ReadValueS32(); //80
TexVariantSigils = stream.ReadSerializedData<BannerTexturePair>();
I0 = stream.ReadValueS32(); //80
stream.Position += 12;
this.TexSigilAccents = stream.ReadSerializedData<BannerTexturePair>();
this.I0 = stream.ReadValueS32(); //104
TexSigilAccents = stream.ReadSerializedData<BannerTexturePair>();
I0 = stream.ReadValueS32(); //104
stream.Position += 12;
this.ColorSets = stream.ReadSerializedData<BannerColorSet>();
ColorSets = stream.ReadSerializedData<BannerColorSet>();
stream.Position += 8;
this.SigilPlacements = stream.ReadSerializedData<BannerSigilPlacement>();
SigilPlacements = stream.ReadSerializedData<BannerSigilPlacement>();
stream.Position += 8;
this.SNOActorBases = stream.ReadSerializedInts();
SNOActorBases = stream.ReadSerializedInts();
stream.Position += 8;
this.SNOActorCaps = stream.ReadSerializedInts();
SNOActorCaps = stream.ReadSerializedInts();
stream.Position += 8;
this.SNOActorPoles = stream.ReadSerializedInts();
SNOActorPoles = stream.ReadSerializedInts();
stream.Position += 8;
this.SNOActorRibbons = stream.ReadSerializedInts();
SNOActorRibbons = stream.ReadSerializedInts();
stream.Position += 8;
this.EpicBannerDescriptions = stream.ReadSerializedData<EpicBannerDescription>();
EpicBannerDescriptions = stream.ReadSerializedData<EpicBannerDescription>();
stream.Position += 8;
}
}
@ -492,8 +492,8 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
public void Read(MpqFileStream stream)
{
this.SNOTexture = stream.ReadValueS32();
this.I0 = stream.ReadValueS32();
SNOTexture = stream.ReadValueS32();
I0 = stream.ReadValueS32();
stream.Position += 4;
}
}
@ -507,12 +507,12 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
public void Read(MpqFileStream stream)
{
this.Color = new RGBAColor[2];
Color = new RGBAColor[2];
for (int i = 0; i < 2; i++)
this.Color[i] = new RGBAColor(stream);
this.String1 = stream.ReadString(64, true);
this.I0 = stream.ReadValueS32();
this.I1 = stream.ReadValueS32();
Color[i] = new RGBAColor(stream);
String1 = stream.ReadString(64, true);
I0 = stream.ReadValueS32();
I1 = stream.ReadValueS32();
stream.Position += 4;
}
}
@ -524,8 +524,8 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
public void Read(MpqFileStream stream)
{
this.S0 = stream.ReadString(64, true);
this.I0 = stream.ReadValueS32();
S0 = stream.ReadString(64, true);
I0 = stream.ReadValueS32();
}
}
@ -539,11 +539,11 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
public void Read(MpqFileStream stream)
{
this.SNOBannerShape = stream.ReadValueS32();
this.SNOBannerBase = stream.ReadValueS32();
this.SNOBannerPole = stream.ReadValueS32();
this.I3 = stream.ReadValueS32();
this.S0 = stream.ReadString(128, true);
SNOBannerShape = stream.ReadValueS32();
SNOBannerBase = stream.ReadValueS32();
SNOBannerPole = stream.ReadValueS32();
I3 = stream.ReadValueS32();
S0 = stream.ReadString(128, true);
}
}
@ -554,8 +554,8 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
public void Read(MpqFileStream stream)
{
this.I0 = stream.ReadValueS32();
this.I1 = stream.ReadValueS32();
I0 = stream.ReadValueS32();
I1 = stream.ReadValueS32();
}
}
}

View File

@ -22,13 +22,13 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
{
var stream = file.Open();
this.Header = new Header(stream);
this.I0 = stream.ReadValueS32();
this.SNOLevelArea0 = stream.ReadValueS32();
this.SNOLevelArea1 = stream.ReadValueS32();
Header = new Header(stream);
I0 = stream.ReadValueS32();
SNOLevelArea0 = stream.ReadValueS32();
SNOLevelArea1 = stream.ReadValueS32();
stream.Position += 8;
if (stream.Position + 8 != stream.Length)
this.LevelAreaServerData = stream.ReadSerializedData<LevelAreaServerData>(); //32 - 48
LevelAreaServerData = stream.ReadSerializedData<LevelAreaServerData>(); //32 - 48
stream.Close();
}
@ -45,11 +45,11 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
public void Read(MpqFileStream stream)
{
this.SNOLevelArea0 = stream.ReadValueS32();
this.LocSet = new GizmoLocSet(stream);
this.SNOLevelArea1 = stream.ReadValueS32();
this.I0 = stream.ReadValueS32();
this.SpawnPopulation = stream.ReadSerializedData<LevelAreaSpawnPopulation>();
SNOLevelArea0 = stream.ReadValueS32();
LocSet = new GizmoLocSet(stream);
SNOLevelArea1 = stream.ReadValueS32();
I0 = stream.ReadValueS32();
SpawnPopulation = stream.ReadSerializedData<LevelAreaSpawnPopulation>();
}
}
@ -60,9 +60,9 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
public GizmoLocSet(MpqFileStream stream)
{
//stream.Position = 0;
this.SpawnType = new GizmoLocSpawnType[52];
SpawnType = new GizmoLocSpawnType[52];
for (int i = 0; i < 52; i++)
this.SpawnType[i] = new GizmoLocSpawnType(stream);
SpawnType[i] = new GizmoLocSpawnType(stream);
}
}
@ -75,7 +75,7 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
public GizmoLocSpawnType(MpqFileStream stream)
{
stream.Position += 8;
this.SpawnEntry = stream.ReadSerializedData<GizmoLocSpawnEntry>();
SpawnEntry = stream.ReadSerializedData<GizmoLocSpawnEntry>();
//this.Description = stream.ReadString(80, true);
//this.Comment = stream.ReadString(256, true);
}
@ -91,10 +91,10 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
public void Read(MpqFileStream stream)
{
this.SNOHandle = new SNOHandle(stream);
this.ForceRandomFacing = stream.ReadValueS32();
this.Weight = stream.ReadValueF32();
this.MaxTimesPicked = stream.ReadValueS32();
SNOHandle = new SNOHandle(stream);
ForceRandomFacing = stream.ReadValueS32();
Weight = stream.ReadValueF32();
MaxTimesPicked = stream.ReadValueS32();
}
}
@ -112,16 +112,16 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
public void Read(MpqFileStream stream)
{
this.Min = stream.ReadValueS32();
this.Max = stream.ReadValueS32();
Min = stream.ReadValueS32();
Max = stream.ReadValueS32();
//this.SNOHandle = new SNOHandle(stream);
this.SnoRequiredQuest = stream.ReadValueS32();
this.SnoCondition = stream.ReadValueS32();
this.Flags = stream.ReadValueS32();
this.HighPrecisionPercent = stream.ReadValueF32();
this.ConditionSNO = stream.ReadValueS32();
SnoRequiredQuest = stream.ReadValueS32();
SnoCondition = stream.ReadValueS32();
Flags = stream.ReadValueS32();
HighPrecisionPercent = stream.ReadValueF32();
ConditionSNO = stream.ReadValueS32();
stream.Position += 8;
this.GizmoLocSpawnChoices = stream.ReadSerializedData<GizmoLocSpawnChoice>();
GizmoLocSpawnChoices = stream.ReadSerializedData<GizmoLocSpawnChoice>();
}
}
@ -145,25 +145,25 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
public int SNO { get; private set; }
public void Read(MpqFileStream stream)
{
this.Description = stream.ReadString(64, true);
this.I0 = stream.ReadValueS32();
this.F0 = stream.ReadValueF32();
this.F1 = stream.ReadValueF32();
Description = stream.ReadString(64, true);
I0 = stream.ReadValueS32();
F0 = stream.ReadValueF32();
F1 = stream.ReadValueF32();
this.I1 = new int[4];
I1 = new int[4];
for (int i = 0; i < 4; i++)
this.I1[i] = stream.ReadValueS32();
this.I2 = new int[4];
I1[i] = stream.ReadValueS32();
I2 = new int[4];
for (int i = 0; i < 4; i++)
this.I2[i] = stream.ReadValueS32();
this.SpawnGroupsCount = stream.ReadValueS32();
I2[i] = stream.ReadValueS32();
SpawnGroupsCount = stream.ReadValueS32();
stream.Position += 8;
this.SpawnGroup = stream.ReadSerializedData<LevelAreaSpawnGroup>();
SpawnGroup = stream.ReadSerializedData<LevelAreaSpawnGroup>();
stream.Position += 8;
SNOs = stream.ReadSerializedInts();
this.SNO = stream.ReadValueS32();
SNO = stream.ReadValueS32();
}
}
@ -188,16 +188,16 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
public int SNO { get; private set; }
public void Read(MpqFileStream stream)
{
this.GroupType = (SpawnGroupType)stream.ReadValueS32();
this.F0 = stream.ReadValueF32();
this.F1 = stream.ReadValueF32();
this.I0 = stream.ReadValueS32();
this.SpawnItemsCount = stream.ReadValueS32();
GroupType = (SpawnGroupType)stream.ReadValueS32();
F0 = stream.ReadValueF32();
F1 = stream.ReadValueF32();
I0 = stream.ReadValueS32();
SpawnItemsCount = stream.ReadValueS32();
stream.Position += 12;
this.SpawnItems = stream.ReadSerializedData<LevelAreaSpawnItem>();
this.I2 = stream.ReadValueS32();
this.I3 = stream.ReadValueS32();
this.SNO = stream.ReadValueS32();
SpawnItems = stream.ReadSerializedData<LevelAreaSpawnItem>();
I2 = stream.ReadValueS32();
I3 = stream.ReadValueS32();
SNO = stream.ReadValueS32();
}
}
@ -225,13 +225,13 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
public void Read(MpqFileStream stream)
{
this.SNOHandle = new SNOHandle(stream);
this.SpawnType = (SpawnType)stream.ReadValueS32();
this.I0 = stream.ReadValueS32();
this.I1 = stream.ReadValueS32();
this.I2 = stream.ReadValueS32();
this.I3 = stream.ReadValueS32();
this.F0 = stream.ReadValueF32();
SNOHandle = new SNOHandle(stream);
SpawnType = (SpawnType)stream.ReadValueS32();
I0 = stream.ReadValueS32();
I1 = stream.ReadValueS32();
I2 = stream.ReadValueS32();
I3 = stream.ReadValueS32();
F0 = stream.ReadValueF32();
}
}

View File

@ -20,13 +20,13 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
public Lore(MpqFile file)
{
var stream = file.Open();
this.Header = new Header(stream);
this.I0 = stream.ReadValueS32();
this.Category = (LoreCategory)stream.ReadValueS32();
this.I1 = stream.ReadValueS32();
this.I2 = stream.ReadValueS32();
this.SNOConversation = stream.ReadValueS32();
this.I3 = stream.ReadValueS32();
Header = new Header(stream);
I0 = stream.ReadValueS32();
Category = (LoreCategory)stream.ReadValueS32();
I1 = stream.ReadValueS32();
I2 = stream.ReadValueS32();
SNOConversation = stream.ReadValueS32();
I3 = stream.ReadValueS32();
stream.Close();
}
}

View File

@ -25,12 +25,12 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
public MarkerSet(MpqFile file)
{
var stream = file.Open();
this.Header = new Header(stream);//0
this.Markers = stream.ReadSerializedData<Marker>(); //28
Header = new Header(stream);//0
Markers = stream.ReadSerializedData<Marker>(); //28
stream.Position += 4;
NoSpawns = stream.ReadSerializedData<Circle>(); //96
stream.Position += (15 * 4);
this.AABB = new AABB(stream); //160
AABB = new AABB(stream); //160
//stream.Position += (14 * 4);
int i0 = stream.ReadValueS32(); //184
@ -38,11 +38,11 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
//this.ContainsActorLocations = false;
throw new System.Exception("Farmy thought this field is a bool, but apparently its not");
else
this.ContainsActorLocations = i0 == 1;
ContainsActorLocations = i0 == 1;
this.NLabel = stream.ReadValueS32(); //200
this.SpecialIndexCount = stream.ReadValueS32(); //204
this.SpecialIndexList = stream.ReadSerializedShorts(); //208
NLabel = stream.ReadValueS32(); //200
SpecialIndexCount = stream.ReadValueS32(); //204
SpecialIndexList = stream.ReadSerializedShorts(); //208
stream.Close();
}
}
@ -59,14 +59,14 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
public void Read(MpqFileStream stream)
{
this.Name = stream.ReadString(128, true);
this.Type = (MarkerType)stream.ReadValueS32();
this.PRTransform = new PRTransform(stream);
this.SNOHandle = new SNOHandle(stream);
this.TagMap = stream.ReadSerializedItem<TagMap>();
Name = stream.ReadString(128, true);
Type = (MarkerType)stream.ReadValueS32();
PRTransform = new PRTransform(stream);
SNOHandle = new SNOHandle(stream);
TagMap = stream.ReadSerializedItem<TagMap>();
stream.Position += 8;
this.MarkerLinksCount = stream.ReadValueS32();
this.MarkerLinks = stream.ReadSerializedData<MarkerLink>();
MarkerLinksCount = stream.ReadValueS32();
MarkerLinks = stream.ReadSerializedData<MarkerLink>();
stream.Position += (3 * 4);
}
@ -95,8 +95,8 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
public void Read(MpqFileStream stream)
{
this.String1 = stream.ReadString(128, true);
this.String2 = stream.ReadString(128, true);
String1 = stream.ReadString(128, true);
String2 = stream.ReadString(128, true);
}
}

View File

@ -76,17 +76,17 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
public Monster(MpqFile file)
{
var stream = file.Open();
this.Header = new Header(stream);
this.Flags = stream.ReadValueS32(); //12
this.ActorSNO = stream.ReadValueS32(); //16
this.LookIndex = stream.ReadValueS32(); //20
this.Type = (MonsterType)stream.ReadValueS32(); //40 - 24
this.Race = (MonsterRace)stream.ReadValueS32(); //44 - 28
this.Size = (MonsterSize)stream.ReadValueS32(); //48 - 32
this.Monsterdef = new MonsterDef(stream); //52 - 36
this.Resists = (Resistance)stream.ReadValueS32(); //56
this.DefaultCountMin = stream.ReadValueS32(); //60
this.DefaultCountDelta = stream.ReadValueS32(); //64
Header = new Header(stream);
Flags = stream.ReadValueS32(); //12
ActorSNO = stream.ReadValueS32(); //16
LookIndex = stream.ReadValueS32(); //20
Type = (MonsterType)stream.ReadValueS32(); //40 - 24
Race = (MonsterRace)stream.ReadValueS32(); //44 - 28
Size = (MonsterSize)stream.ReadValueS32(); //48 - 32
Monsterdef = new MonsterDef(stream); //52 - 36
Resists = (Resistance)stream.ReadValueS32(); //56
DefaultCountMin = stream.ReadValueS32(); //60
DefaultCountDelta = stream.ReadValueS32(); //64
AttributeModifiers = new float[146]; //68
for (int i = 0; i < 146; i++)
{
@ -99,90 +99,90 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
HPMinion = stream.ReadValueF32();
HPDeltaMinion = stream.ReadValueF32(); //672
this.GoldGranted = stream.ReadValueS32();
this.HealthDropNormal = new HealthDropInfo(stream);
this.HealthDropChampion = new HealthDropInfo(stream);
this.HealthDropRare = new HealthDropInfo(stream);
this.HealthDropMinion = new HealthDropInfo(stream);
GoldGranted = stream.ReadValueS32();
HealthDropNormal = new HealthDropInfo(stream);
HealthDropChampion = new HealthDropInfo(stream);
HealthDropRare = new HealthDropInfo(stream);
HealthDropMinion = new HealthDropInfo(stream);
// 716
this.SNOSkillKit = stream.ReadValueS32();
this.SkillDeclarations = new SkillDeclaration[8];
SNOSkillKit = stream.ReadValueS32();
SkillDeclarations = new SkillDeclaration[8];
for (int i = 0; i < 8; i++)
{
this.SkillDeclarations[i] = new SkillDeclaration(stream);
SkillDeclarations[i] = new SkillDeclaration(stream);
}
this.MonsterSkillDeclarations = new MonsterSkillDeclaration[8];
MonsterSkillDeclarations = new MonsterSkillDeclaration[8];
for (int i = 0; i < 8; i++)
{
this.MonsterSkillDeclarations[i] = new MonsterSkillDeclaration(stream);
MonsterSkillDeclarations[i] = new MonsterSkillDeclaration(stream);
}
// 912
this.SNOTreasureClassFirstKill = stream.ReadValueS32();
this.SNOTreasureClass = stream.ReadValueS32();
this.SNOTreasureClassRare = stream.ReadValueS32();
this.SNOTreasureClassChampion = stream.ReadValueS32();
this.SNOTreasureClassChampionLight = stream.ReadValueS32();
SNOTreasureClassFirstKill = stream.ReadValueS32();
SNOTreasureClass = stream.ReadValueS32();
SNOTreasureClassRare = stream.ReadValueS32();
SNOTreasureClassChampion = stream.ReadValueS32();
SNOTreasureClassChampionLight = stream.ReadValueS32();
// 932
this.NoDropScalar = stream.ReadValueF32();
this.FleeChance = stream.ReadValueF32();
this.FleeCooldownMin = stream.ReadValueF32();
this.FleeCooldownDelta = stream.ReadValueF32();
this.SummonCountPer = stream.ReadValueS32();
this.SummonLifetime = stream.ReadValueF32();
this.SummonMaxConcurrent = stream.ReadValueS32();
this.SummonMaxTotal = stream.ReadValueS32();
this.SNOInventory = stream.ReadValueS32(); //3D0 - 976 + 28 =1004
this.SNOSecondaryInventory = stream.ReadValueS32();
this.SNOLore = stream.ReadValueS32();
this.AIBehavior = new int[6];
NoDropScalar = stream.ReadValueF32();
FleeChance = stream.ReadValueF32();
FleeCooldownMin = stream.ReadValueF32();
FleeCooldownDelta = stream.ReadValueF32();
SummonCountPer = stream.ReadValueS32();
SummonLifetime = stream.ReadValueF32();
SummonMaxConcurrent = stream.ReadValueS32();
SummonMaxTotal = stream.ReadValueS32();
SNOInventory = stream.ReadValueS32(); //3D0 - 976 + 28 =1004
SNOSecondaryInventory = stream.ReadValueS32();
SNOLore = stream.ReadValueS32();
AIBehavior = new int[6];
for (int i = 0; i < 6; i++)
{
this.AIBehavior[i] = stream.ReadValueS32();
AIBehavior[i] = stream.ReadValueS32();
}
this.GBIdMovementStyles = new int[8];
GBIdMovementStyles = new int[8];
for (int i = 0; i < 8; i++)
{
this.GBIdMovementStyles[i] = stream.ReadValueS32();
GBIdMovementStyles[i] = stream.ReadValueS32();
}
this.SNOSummonActor = new int[6];
SNOSummonActor = new int[6];
for (int i = 0; i < 6; i++)
{
this.SNOSummonActor[i] = stream.ReadValueS32();
SNOSummonActor[i] = stream.ReadValueS32();
}
this.RandomAffixes = stream.ReadValueS32();
RandomAffixes = stream.ReadValueS32();
GBIdAffixes = new int[4];
for (int i = 0; i < 4; i++)
{
this.GBIdAffixes[i] = stream.ReadValueS32();
GBIdAffixes[i] = stream.ReadValueS32();
}
GBIdDisallowedAffixes = new int[6];
for (int i = 0; i < 6; i++)
{
this.GBIdDisallowedAffixes[i] = stream.ReadValueS32();
GBIdDisallowedAffixes[i] = stream.ReadValueS32();
}
// 1096
this.AITargetStyleNormal = stream.ReadValueS32();
this.AITargetStyleChampion = stream.ReadValueS32();
this.AITargetStyleRare = stream.ReadValueS32();
this.PowerType = (MonsterPowerType)stream.ReadValueS32(); //1152
AITargetStyleNormal = stream.ReadValueS32();
AITargetStyleChampion = stream.ReadValueS32();
AITargetStyleRare = stream.ReadValueS32();
PowerType = (MonsterPowerType)stream.ReadValueS32(); //1152
//0x468
stream.Position += (3 * 4);
this.TagMap = stream.ReadSerializedItem<TagMap>(); //1180
TagMap = stream.ReadSerializedItem<TagMap>(); //1180
stream.Position = 1196;
this.MinionSpawnGroupCount = stream.ReadValueS32(); //1196
MinionSpawnGroupCount = stream.ReadValueS32(); //1196
stream.Position += (3 * 4);
this.MonsterMinionSpawngroup = stream.ReadSerializedData<MonsterMinionSpawnGroup>(); //1212
this.ChampionSpawnGroupCount = stream.ReadValueS32(); //1220
this.MonsterChampionSpawngroup = stream.ReadSerializedData<MonsterChampionSpawnGroup>(); //1236
this.Name = stream.ReadString(128, true); //1244
this.DoesNotDropNecroCorpse = stream.ReadValueS32(); //1344
this.Pad = stream.ReadValueS32(); //1344
this.snoAIStateAttackerCapReached = stream.ReadValueS32();
MonsterMinionSpawngroup = stream.ReadSerializedData<MonsterMinionSpawnGroup>(); //1212
ChampionSpawnGroupCount = stream.ReadValueS32(); //1220
MonsterChampionSpawngroup = stream.ReadSerializedData<MonsterChampionSpawnGroup>(); //1236
Name = stream.ReadString(128, true); //1244
DoesNotDropNecroCorpse = stream.ReadValueS32(); //1344
Pad = stream.ReadValueS32(); //1344
snoAIStateAttackerCapReached = stream.ReadValueS32();
stream.Close();
@ -195,8 +195,8 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
public List<MonsterMinionSpawnItem> SpawnItems = new List<MonsterMinionSpawnItem>();
public void Read(MpqFileStream stream)
{
this.Weight = stream.ReadValueF32();
this.SpawnItemCount = stream.ReadValueS32();
Weight = stream.ReadValueF32();
SpawnItemCount = stream.ReadValueS32();
stream.Position += 8;
SpawnItems = stream.ReadSerializedData<MonsterMinionSpawnItem>();
}
@ -209,8 +209,8 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
public List<MonsterChampionSpawnItem> SpawnItems = new List<MonsterChampionSpawnItem>();
public void Read(MpqFileStream stream)
{
this.Weight = stream.ReadValueF32();
this.SpawnItemCount = stream.ReadValueS32();
Weight = stream.ReadValueF32();
SpawnItemCount = stream.ReadValueS32();
stream.Position += 8;
SpawnItems = stream.ReadSerializedData<MonsterChampionSpawnItem>();
}
@ -226,11 +226,11 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
public void Read(MpqFileStream stream)
{
this.SNOSpawn = stream.ReadValueS32();
this.SpawnCountMin = stream.ReadValueS32();
this.SpawnCountMax = stream.ReadValueS32();
this.SpawnSpreadMin = stream.ReadValueS32();
this.SpawnSpreadMax = stream.ReadValueS32();
SNOSpawn = stream.ReadValueS32();
SpawnCountMin = stream.ReadValueS32();
SpawnCountMax = stream.ReadValueS32();
SpawnSpreadMin = stream.ReadValueS32();
SpawnSpreadMax = stream.ReadValueS32();
}
}
@ -241,8 +241,8 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
public void Read(MpqFileStream stream)
{
this.SnoActor = stream.ReadValueS32();
this.SpawnCount = stream.ReadValueS32();
SnoActor = stream.ReadValueS32();
SpawnCount = stream.ReadValueS32();
}
}
@ -311,9 +311,9 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
public HealthDropInfo(MpqFileStream stream)
{
this.DropChance = stream.ReadValueF32();
this.GBID = stream.ReadValueS32();
this.HealthDropStyle = stream.ReadValueS32();
DropChance = stream.ReadValueF32();
GBID = stream.ReadValueS32();
HealthDropStyle = stream.ReadValueS32();
}
}

View File

@ -18,7 +18,7 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
{
var stream = file.Open();
this.Header = new Header(stream);
Header = new Header(stream);
stream.Close();

View File

@ -38,23 +38,23 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
public Observer(MpqFile file)
{
var stream = file.Open();
this.Header = new Header(stream);
this.I0 = stream.ReadValueS32();
this.F0 = stream.ReadValueF32();
this.Angle0 = stream.ReadValueF32();
this.F1 = stream.ReadValueF32();
this.Velocity = stream.ReadValueF32();
this.F8 = stream.ReadValueF32();
this.Angle1 = stream.ReadValueF32();
this.Angle2 = stream.ReadValueF32();
this.F2 = stream.ReadValueF32();
this.V0 = new Vector3D(stream.ReadValueF32(), stream.ReadValueF32(), stream.ReadValueF32());
this.V1 = new Vector3D(stream.ReadValueF32(), stream.ReadValueF32(), stream.ReadValueF32());
this.F3 = stream.ReadValueF32();
this.F4 = stream.ReadValueF32();
this.F5 = stream.ReadValueF32();
this.F6 = stream.ReadValueF32();
this.F7 = stream.ReadValueF32();
Header = new Header(stream);
I0 = stream.ReadValueS32();
F0 = stream.ReadValueF32();
Angle0 = stream.ReadValueF32();
F1 = stream.ReadValueF32();
Velocity = stream.ReadValueF32();
F8 = stream.ReadValueF32();
Angle1 = stream.ReadValueF32();
Angle2 = stream.ReadValueF32();
F2 = stream.ReadValueF32();
V0 = new Vector3D(stream.ReadValueF32(), stream.ReadValueF32(), stream.ReadValueF32());
V1 = new Vector3D(stream.ReadValueF32(), stream.ReadValueF32(), stream.ReadValueF32());
F3 = stream.ReadValueF32();
F4 = stream.ReadValueF32();
F5 = stream.ReadValueF32();
F6 = stream.ReadValueF32();
F7 = stream.ReadValueF32();
stream.Close();
}
}

View File

@ -21,13 +21,13 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
public PhysMesh(MpqFile file)
{
var stream = file.Open();
this.Header = new Header(stream); //0
Header = new Header(stream); //0
//+16
this.I0 = stream.ReadValueS32(); //28
this.CollisionMeshCount = stream.ReadValueS32(); //32
this.CollisionMeshes = stream.ReadSerializedData<CollisionMesh>(); //36
I0 = stream.ReadValueS32(); //28
CollisionMeshCount = stream.ReadValueS32(); //32
CollisionMeshes = stream.ReadSerializedData<CollisionMesh>(); //36
stream.Position += 12;
this.I1 = stream.ReadValueS32(); //26
I1 = stream.ReadValueS32(); //26
stream.Close();
}
}
@ -53,21 +53,21 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
{
//64
stream.Position += (4 * 6);
this.F0 = new Float3(stream); //88
this.F1 = new Float3(stream); //100
this.F2 = new Float3(stream); //112
this.DominoNodeCount = stream.ReadValueS32(); //124
this.VerticeCount = stream.ReadValueS32(); //128
this.DominoTriangleCount = stream.ReadValueS32(); //132
this.DominoEdgeCount = stream.ReadValueS32(); //136
F0 = new Float3(stream); //88
F1 = new Float3(stream); //100
F2 = new Float3(stream); //112
DominoNodeCount = stream.ReadValueS32(); //124
VerticeCount = stream.ReadValueS32(); //128
DominoTriangleCount = stream.ReadValueS32(); //132
DominoEdgeCount = stream.ReadValueS32(); //136
stream.Position += 4;
this.Vertices = stream.ReadSerializedData<Float4>(); //96 - 160
this.DominoTriangles = stream.ReadSerializedData<MeshTriangle>(); //104 - 168
this.DominoNodes = stream.ReadSerializedData<MeshNode>(); //112 - 176
Vertices = stream.ReadSerializedData<Float4>(); //96 - 160
DominoTriangles = stream.ReadSerializedData<MeshTriangle>(); //104 - 168
DominoNodes = stream.ReadSerializedData<MeshNode>(); //112 - 176
//stream.Position += 4 * 2;
this.I6 = stream.ReadValueS32(); //120 - 184
this.I7 = stream.ReadValueS32(); //124 - 188
I6 = stream.ReadValueS32(); //120 - 184
I7 = stream.ReadValueS32(); //124 - 188
//176
}
}

View File

@ -27,7 +27,7 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
public Power(MpqFile file)
{
var stream = file.Open();
this.Header = new Header(stream);
Header = new Header(stream);
LuaName = stream.ReadString(64, true); //28
stream.Position += 4; //
Powerdef = new PowerDef(stream); //108

View File

@ -25,12 +25,12 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
public QuestRange(MpqFile file)
{
var stream = file.Open();
this.Header = new Header(stream); //0
this.Pull = stream.ReadValueS32(); //12 + 16 = 28
this.I1 = stream.ReadValueS32(); //12 + 16 = 28
this.I2 = stream.ReadValueS32(); //12 + 16 = 28
this.I3 = stream.ReadValueS32(); //12 + 16 = 28
this.I4 = stream.ReadValueS32(); //12 + 16 = 28
Header = new Header(stream); //0
Pull = stream.ReadValueS32(); //12 + 16 = 28
I1 = stream.ReadValueS32(); //12 + 16 = 28
I2 = stream.ReadValueS32(); //12 + 16 = 28
I3 = stream.ReadValueS32(); //12 + 16 = 28
I4 = stream.ReadValueS32(); //12 + 16 = 28
Enitys = new QuestTimeEntity[20];
for (int i = 0; stream.Position < stream.Length; i++)
{
@ -59,8 +59,8 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
public QuestTime(MpqFileStream stream)
{
this.SNOQuest = stream.ReadValueS32();
this.StepID = stream.ReadValueS32();
SNOQuest = stream.ReadValueS32();
StepID = stream.ReadValueS32();
}
}

View File

@ -14,7 +14,7 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
public Recipe(MpqFile file)
{
var stream = file.Open();
this.Header = new Header(stream);
Header = new Header(stream);
ItemSpecifierData = new ItemSpecifierData(stream);
stream.Close();
}

View File

@ -58,9 +58,9 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
public Rope(MpqFile file)
{
var stream = file.Open();
this.Header = new Header(stream);
this.I0 = stream.ReadValueS32();
this.F0 = stream.ReadValueF32();
Header = new Header(stream);
I0 = stream.ReadValueS32();
F0 = stream.ReadValueF32();
stream.Close();
}

View File

@ -34,41 +34,41 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
public Scene(MpqFile file)
{
var stream = file.Open();
this.Header = new Header(stream);
Header = new Header(stream);
///+16
Int0 = stream.ReadValueS32(); //12 - 28
this.AABBBounds = new AABB(stream); //16 - 32
this.AABBMarketSetBounds = new AABB(stream); //40 - 56
this.NavMesh = new NavMeshDef(stream); //64 - 80
this.Exclusions = stream.ReadSerializedInts(); //104 - 120
AABBBounds = new AABB(stream); //16 - 32
AABBMarketSetBounds = new AABB(stream); //40 - 56
NavMesh = new NavMeshDef(stream); //64 - 80
Exclusions = stream.ReadSerializedInts(); //104 - 120
stream.Position += (14 * 4);
this.Inclusions = stream.ReadSerializedInts(); //168 - 184
Inclusions = stream.ReadSerializedInts(); //168 - 184
stream.Position += (14 * 4);
this.MarkerSets = stream.ReadSerializedInts(); //232 - 248
MarkerSets = stream.ReadSerializedInts(); //232 - 248
stream.Position += (14 * 4);
this.LookLink = stream.ReadString(64, true); //296 - 312
LookLink = stream.ReadString(64, true); //296 - 312
//stream.Position += (14 * 4;
this.MsgTriggeredEvent = stream.ReadSerializedData<MsgTriggeredEvent>(); //360 - 376
this.Int1 = stream.ReadValueS32(); //368 - 384
MsgTriggeredEvent = stream.ReadSerializedData<MsgTriggeredEvent>(); //360 - 376
Int1 = stream.ReadValueS32(); //368 - 384
stream.Position += (3 * 4);
this.NavZone = new NavZoneDef(stream); //384 - 400
this.SNOAppearance = stream.ReadValueS32(); //520 - 536
NavZone = new NavZoneDef(stream); //384 - 400
SNOAppearance = stream.ReadValueS32(); //520 - 536
stream.Position += 4;
this.SNOPhysMesh = stream.ReadValueS32(); //528 - 544
SNOPhysMesh = stream.ReadValueS32(); //528 - 544
stream.Close();
this.NoSpawn = false;
NoSpawn = false;
int NoSpawnSquares = 0;
foreach (var zone in this.NavMesh.Squares)
foreach (var zone in NavMesh.Squares)
{
if (!((zone.Flags & DiIiS_NA.Core.MPQ.FileFormats.Scene.NavCellFlags.NoSpawn) == 0))
if (!((zone.Flags & NavCellFlags.NoSpawn) == 0))
{
NoSpawnSquares++;
}
}
if ((this.NavMesh.Squares.Count - NoSpawnSquares) < (this.NavMesh.Squares.Count / 10)) this.NoSpawn = true;
if ((NavMesh.Squares.Count - NoSpawnSquares) < (NavMesh.Squares.Count / 10)) NoSpawn = true;
}
public class NavMeshDef
@ -85,12 +85,12 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
public NavMeshDef(MpqFileStream stream)
{
this.SquaresCountX = stream.ReadValueS32();
this.SquaresCountY = stream.ReadValueS32();
this.Int0 = stream.ReadValueS32();
this.NavMeshSquareCount = stream.ReadValueS32();
this.Float0 = stream.ReadValueF32();
this.Squares = stream.ReadSerializedData<NavMeshSquare>();
SquaresCountX = stream.ReadValueS32();
SquaresCountY = stream.ReadValueS32();
Int0 = stream.ReadValueS32();
NavMeshSquareCount = stream.ReadValueS32();
Float0 = stream.ReadValueF32();
Squares = stream.ReadSerializedData<NavMeshSquare>();
if (SquaresCountX <= 64 && SquaresCountY <= 64)
@ -118,7 +118,7 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
// Loop thru each NavmeshSquare in the array, and fills the grid
for (int i = 0; i < NavMeshSquareCount; i++)
{
WalkGrid[i % SquaresCountX, i / SquaresCountY] = (byte)(Squares[i].Flags & Scene.NavCellFlags.AllowWalk);
WalkGrid[i % SquaresCountX, i / SquaresCountY] = (byte)(Squares[i].Flags & NavCellFlags.AllowWalk);
// Set the grid to 0x1 if its walkable, left as 0 if not. - DarkLotus
}
@ -145,29 +145,29 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
public NavZoneDef(MpqFileStream stream)
{
this.NavCellCount = stream.ReadValueS32();
NavCellCount = stream.ReadValueS32();
stream.Position += (3 * 4);
this.NavCells = stream.ReadSerializedData<NavCell>();
NavCells = stream.ReadSerializedData<NavCell>();
this.NeighbourCount = stream.ReadValueS32();
NeighbourCount = stream.ReadValueS32();
stream.Position += (3 * 4);
this.NavCellNeighbours = stream.ReadSerializedData<NavCellLookup>();
NavCellNeighbours = stream.ReadSerializedData<NavCellLookup>();
this.Float0 = stream.ReadValueF32();
this.Float1 = stream.ReadValueF32();
this.Int2 = stream.ReadValueS32();
this.V0 = new Vector2D(stream);
Float0 = stream.ReadValueF32();
Float1 = stream.ReadValueF32();
Int2 = stream.ReadValueS32();
V0 = new Vector2D(stream);
stream.Position += (3 * 4);
this.GridSquares = stream.ReadSerializedData<NavGridSquare>();
GridSquares = stream.ReadSerializedData<NavGridSquare>();
this.Int3 = stream.ReadValueS32();
Int3 = stream.ReadValueS32();
stream.Position += (3 * 4);
this.CellLookups = stream.ReadSerializedData<NavCellLookup>();
CellLookups = stream.ReadSerializedData<NavCellLookup>();
this.BorderDataCount = stream.ReadValueS32();
BorderDataCount = stream.ReadValueS32();
stream.Position += (3 * 4);
this.BorderData = stream.ReadSerializedData<NavCellBorderData>();
BorderData = stream.ReadSerializedData<NavCellBorderData>();
}
}
@ -178,8 +178,8 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
public void Read(MpqFileStream stream)
{
this.Z = stream.ReadValueF32();
this.Flags = (NavCellFlags)stream.ReadValueS32();
Z = stream.ReadValueF32();
Flags = (NavCellFlags)stream.ReadValueS32();
}
}
@ -193,11 +193,11 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
public RectangleF Bounds { get { return new RectangleF(Min.X, Min.Y, Max.X - Min.X, Max.Y - Min.Y); } }
public void Read(MpqFileStream stream)
{
this.Min = new Vector3D(stream.ReadValueF32(), stream.ReadValueF32(), stream.ReadValueF32());
this.Max = new Vector3D(stream.ReadValueF32(), stream.ReadValueF32(), stream.ReadValueF32());
this.Flags = (NavCellFlags)stream.ReadValueS16();
this.NeighbourCount = stream.ReadValueS16();
this.NeighborsIndex = stream.ReadValueS32();
Min = new Vector3D(stream.ReadValueF32(), stream.ReadValueF32(), stream.ReadValueF32());
Max = new Vector3D(stream.ReadValueF32(), stream.ReadValueF32(), stream.ReadValueF32());
Flags = (NavCellFlags)stream.ReadValueS16();
NeighbourCount = stream.ReadValueS16();
NeighborsIndex = stream.ReadValueS32();
}
}
@ -232,8 +232,8 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
public void Read(MpqFileStream stream)
{
this.Flags = stream.ReadValueS16();
this.WCell = stream.ReadValueS16();
Flags = stream.ReadValueS16();
WCell = stream.ReadValueS16();
}
}

View File

@ -18,11 +18,11 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
public SceneGroup(MpqFile file)
{
var stream = file.Open();
this.Header = new Header(stream);
this.I0 = stream.ReadValueS32();
this.Items = stream.ReadSerializedData<SceneGroupItem>();
Header = new Header(stream);
I0 = stream.ReadValueS32();
Items = stream.ReadSerializedData<SceneGroupItem>();
stream.Position += 8;
this.I1 = stream.ReadValueS32();
I1 = stream.ReadValueS32();
stream.Close();
}
}
@ -35,9 +35,9 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
public void Read(MpqFileStream stream)
{
this.SNOScene = stream.ReadValueS32();
this.I0 = stream.ReadValueS32();
this.LabelGBId = stream.ReadValueS32();
SNOScene = stream.ReadValueS32();
I0 = stream.ReadValueS32();
LabelGBId = stream.ReadValueS32();
}
}
}

View File

@ -17,11 +17,11 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
public SkillKit(MpqFile file)
{
var stream = file.Open();
this.Header = new Header(stream);
Header = new Header(stream);
stream.Position += 12;
this.TraitEntries = stream.ReadSerializedData<TraitEntry>();
TraitEntries = stream.ReadSerializedData<TraitEntry>();
stream.Position += 8;
this.ActiveSkillEntries = stream.ReadSerializedData<ActiveSkillEntry>();
ActiveSkillEntries = stream.ReadSerializedData<ActiveSkillEntry>();
stream.Close();
}
@ -35,10 +35,10 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
public int I0 { get; private set; }
public void Read(MpqFileStream stream)
{
this.SNOPower = stream.ReadValueS32();
this.Category = stream.ReadValueS32();
this.ReqLevel = stream.ReadValueS32();
this.I0 = stream.ReadValueS32();
SNOPower = stream.ReadValueS32();
Category = stream.ReadValueS32();
ReqLevel = stream.ReadValueS32();
I0 = stream.ReadValueS32();
}
}
@ -59,18 +59,18 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
public void Read(MpqFileStream stream)
{
this.SNOPower = stream.ReadValueS32();
this.Category = (ActiveSkillCategory)stream.ReadValueS32();
this.SkillGroup = stream.ReadValueS32();
this.ReqLevel = stream.ReadValueS32();
this.RuneNone_ReqLevel = stream.ReadValueS32();
this.RuneA_ReqLevel = stream.ReadValueS32();
this.RuneB_ReqLevel = stream.ReadValueS32();
this.RuneC_ReqLevel = stream.ReadValueS32();
this.RuneD_ReqLevel = stream.ReadValueS32();
this.RuneE_ReqLevel = stream.ReadValueS32();
this.I0 = stream.ReadValueS32();
this.I1 = new int[5];
SNOPower = stream.ReadValueS32();
Category = (ActiveSkillCategory)stream.ReadValueS32();
SkillGroup = stream.ReadValueS32();
ReqLevel = stream.ReadValueS32();
RuneNone_ReqLevel = stream.ReadValueS32();
RuneA_ReqLevel = stream.ReadValueS32();
RuneB_ReqLevel = stream.ReadValueS32();
RuneC_ReqLevel = stream.ReadValueS32();
RuneD_ReqLevel = stream.ReadValueS32();
RuneE_ReqLevel = stream.ReadValueS32();
I0 = stream.ReadValueS32();
I1 = new int[5];
for (int i = 0; i < I1.Length; i++)
I1[i] = stream.ReadValueS32();
}

View File

@ -24,15 +24,15 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
public Tutorial(MpqFile file)
{
var stream = file.Open();
this.Header = new Header(stream);
this.Flags = stream.ReadValueS32();
this.Label = stream.ReadValueS32();
this.TimeBeforeFading = stream.ReadValueS32();
this.RecurTime = stream.ReadValueS32();
this.OccurrencesUntilLearned = stream.ReadValueS32();
this.ArrowPosition = stream.ReadValueS32();
this.Offset = new Vector2D(stream);
this.Pad = stream.ReadValueS32();
Header = new Header(stream);
Flags = stream.ReadValueS32();
Label = stream.ReadValueS32();
TimeBeforeFading = stream.ReadValueS32();
RecurTime = stream.ReadValueS32();
OccurrencesUntilLearned = stream.ReadValueS32();
ArrowPosition = stream.ReadValueS32();
Offset = new Vector2D(stream);
Pad = stream.ReadValueS32();
stream.Close();
}
}

View File

@ -20,13 +20,13 @@ namespace DiIiS_NA.Core.MPQ.FileFormats.Types
public Header(MpqFileStream stream)
{
this.DeadBeef = stream.ReadValueS32();
this.SnoType = stream.ReadValueS32();
this.Unknown1 = stream.ReadValueS32();
this.Unknown2 = stream.ReadValueS32();
this.SNOId = stream.ReadValueS32();
this.Unknown3 = stream.ReadValueS32();
this.Unknown4 = stream.ReadValueS32();
DeadBeef = stream.ReadValueS32();
SnoType = stream.ReadValueS32();
Unknown1 = stream.ReadValueS32();
Unknown2 = stream.ReadValueS32();
SNOId = stream.ReadValueS32();
Unknown3 = stream.ReadValueS32();
Unknown4 = stream.ReadValueS32();
}
}
@ -66,15 +66,15 @@ namespace DiIiS_NA.Core.MPQ.FileFormats.Types
public ScriptFormula(MpqFileStream stream)
{
this.I0 = stream.ReadValueS32();
this.I1 = stream.ReadValueS32();
this.I2 = stream.ReadValueS32();
this.I3 = stream.ReadValueS32();
this.I4 = stream.ReadValueS32();
this.NameSize = stream.ReadValueS32();
this.I5 = stream.ReadValueS32();
this.OpcodeSize = stream.ReadValueS32();
this.OpCodeName = stream.ReadStringZ(Encoding.ASCII);
I0 = stream.ReadValueS32();
I1 = stream.ReadValueS32();
I2 = stream.ReadValueS32();
I3 = stream.ReadValueS32();
I4 = stream.ReadValueS32();
NameSize = stream.ReadValueS32();
I5 = stream.ReadValueS32();
OpcodeSize = stream.ReadValueS32();
OpCodeName = stream.ReadStringZ(Encoding.ASCII);
switch (NameSize % 4)
{
@ -91,7 +91,7 @@ namespace DiIiS_NA.Core.MPQ.FileFormats.Types
break;
}
this.OpCodeArray = new byte[OpcodeSize];
OpCodeArray = new byte[OpcodeSize];
stream.Read(OpCodeArray, 0, OpcodeSize);
}
@ -125,7 +125,7 @@ namespace DiIiS_NA.Core.MPQ.FileFormats.Types
public HardPointLink(MpqFileStream stream)
{
this.Name = stream.ReadString(64, true);
Name = stream.ReadString(64, true);
I0 = stream.ReadValueS32();
}
}
@ -271,8 +271,8 @@ namespace DiIiS_NA.Core.MPQ.FileFormats.Types
HardPointLinks = new HardPointLink[2];
HardPointLinks[0] = new HardPointLink(stream);
HardPointLinks[1] = new HardPointLink(stream);
this.LookLink = stream.ReadString(64, true);
this.ConstraintLink = stream.ReadString(64, true);
LookLink = stream.ReadString(64, true);
ConstraintLink = stream.ReadString(64, true);
AnimTag = stream.ReadValueS32();
Alpha = stream.ReadValueF32();
MsgPassMethod = stream.ReadValueS32();

View File

@ -45,7 +45,7 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
{
var stream = file.Open();
this.Header = new Header(stream);
Header = new Header(stream);
stream.Close();

View File

@ -43,14 +43,14 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
{
var stream = file.Open();
this.Header = new Header(stream);
Header = new Header(stream);
this.DynamicWorld = (stream.ReadValueS32() != 0);
DynamicWorld = (stream.ReadValueS32() != 0);
stream.Position += 8;
this.ServerData = stream.ReadSerializedData<ServerData>(); //16
this.MarkerSets = stream.ReadSerializedInts(); //40
ServerData = stream.ReadSerializedData<ServerData>(); //16
MarkerSets = stream.ReadSerializedInts(); //40
this.Environment = new Environment(stream); //96 - 56
Environment = new Environment(stream); //96 - 56
// - 56
DeformationScale = stream.ReadValueF32(); //172
Flags = stream.ReadValueS32(); //176
@ -78,8 +78,8 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
public void Read(MpqFileStream stream)
{
this.SceneChunks = stream.ReadSerializedData<SceneChunk>();
this.ChunkCount = stream.ReadValueS32();
SceneChunks = stream.ReadSerializedData<SceneChunk>();
ChunkCount = stream.ReadValueS32();
stream.Position += (3 * 4);
}
@ -103,9 +103,9 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
public void Read(MpqFileStream stream)
{
this.SNOHandle = new SNOHandle(stream);
this.PRTransform = new PRTransform(stream);
this.SceneSpecification = new SceneSpecification(stream);
SNOHandle = new SNOHandle(stream);
PRTransform = new PRTransform(stream);
SceneSpecification = new SceneSpecification(stream);
}
}
@ -162,14 +162,14 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
Tiles = stream.ReadSerializedData<TileInfo>();
stream.Position += (14 * 4);
this.CommandCount = stream.ReadValueS32();
this.Commands = stream.ReadSerializedData<DRLGCommand>();
CommandCount = stream.ReadValueS32();
Commands = stream.ReadSerializedData<DRLGCommand>();
stream.Position += (3 * 4);
this.ParentIndices = stream.ReadSerializedInts();
ParentIndices = stream.ReadSerializedInts();
stream.Position += (2 * 4);
this.TagMap = stream.ReadSerializedItem<TagMap>();
TagMap = stream.ReadSerializedItem<TagMap>();
stream.Position += (2 * 4);
}
}
@ -219,7 +219,7 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
TileType = stream.ReadValueS32();
SNOScene = stream.ReadValueS32();
Probability = stream.ReadValueS32();
this.TagMap = stream.ReadSerializedItem<TagMap>();
TagMap = stream.ReadSerializedItem<TagMap>();
stream.Position += (2 * 4);
CustomTileInfo = new CustomTileInfo(stream);
@ -249,9 +249,9 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
public void Read(MpqFileStream stream)
{
this.Name = stream.ReadString(128, true);
Name = stream.ReadString(128, true);
CommandType = stream.ReadValueS32();
this.TagMap = stream.ReadSerializedItem<TagMap>();
TagMap = stream.ReadSerializedItem<TagMap>();
stream.Position += (3 * 4);
}
}
@ -338,9 +338,9 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
public SceneClusterSet(MpqFileStream stream)
{
this.ClusterCount = stream.ReadValueS32();
ClusterCount = stream.ReadValueS32();
stream.Position += (4 * 3);
this.SceneClusters = stream.ReadSerializedData<SceneCluster>();
SceneClusters = stream.ReadSerializedData<SceneCluster>();
}
}
@ -371,13 +371,13 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
public void Read(MpqFileStream stream)
{
this.Name = stream.ReadString(128, true);
this.ClusterId = stream.ReadValueS32();
this.GroupCount = stream.ReadValueS32();
Name = stream.ReadString(128, true);
ClusterId = stream.ReadValueS32();
GroupCount = stream.ReadValueS32();
stream.Position += (2 * 4);
this.SubSceneGroups = stream.ReadSerializedData<SubSceneGroup>();
SubSceneGroups = stream.ReadSerializedData<SubSceneGroup>();
this.Default = new SubSceneGroup(stream);
Default = new SubSceneGroup(stream);
}
}
@ -394,15 +394,15 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
public SubSceneGroup(MpqFileStream stream)
{
this.Read(stream);
Read(stream);
}
public void Read(MpqFileStream stream)
{
this.I0 = stream.ReadValueS32();
this.SubSceneCount = stream.ReadValueS32();
I0 = stream.ReadValueS32();
SubSceneCount = stream.ReadValueS32();
stream.Position += (2 * 4);
this.Entries = stream.ReadSerializedData<SubSceneEntry>();
Entries = stream.ReadSerializedData<SubSceneEntry>();
}
}
@ -429,11 +429,11 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
public void Read(MpqFileStream stream)
{
this.SNOScene = stream.ReadValueS32();
this.Probability = stream.ReadValueS32();
SNOScene = stream.ReadValueS32();
Probability = stream.ReadValueS32();
stream.Position += (3 * 4);
this.LabelCount = stream.ReadValueS32();
this.Labels = stream.ReadSerializedData<SubSceneLabel>();
LabelCount = stream.ReadValueS32();
Labels = stream.ReadSerializedData<SubSceneLabel>();
}
}
@ -468,7 +468,7 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
{
Rulecount = stream.ReadValueS32();
stream.Position += (3 * 4);
this.LabelRules = stream.ReadSerializedData<LabelRule>();
LabelRules = stream.ReadSerializedData<LabelRule>();
}
}
@ -489,12 +489,12 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
public void Read(MpqFileStream stream)
{
this.Name = stream.ReadString(128, true);
Name = stream.ReadString(128, true);
LabelCondition = new LabelCondition(stream);
NumToChoose = stream.ReadValueS32();
LabelCount = stream.ReadValueS32();
stream.Position += (2 * 4);
this.Entries = stream.ReadSerializedData<LabelEntry>();
Entries = stream.ReadSerializedData<LabelEntry>();
}
}
@ -515,7 +515,7 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
public void Read(MpqFileStream stream)
{
this.GBIdLabel = stream.ReadValueS32();
GBIdLabel = stream.ReadValueS32();
Int0 = stream.ReadValueS32();
Weight = stream.ReadValueF32();
ApplyCountMin = stream.ReadValueS32();
@ -633,13 +633,13 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
public void Read(MpqFileStream stream)
{
//stream.Position += 8;
this.DRLGParams = stream.ReadSerializedData<DRLGParams>();
DRLGParams = stream.ReadSerializedData<DRLGParams>();
stream.Position += 8;
this.SceneParams = stream.ReadSerializedItem<SceneParams>();
SceneParams = stream.ReadSerializedItem<SceneParams>();
//stream.Position += 8;
LabelRuleSet = new LabelRuleSet(stream);
this.Int1 = stream.ReadValueS32();
this.SceneClusterSet = new SceneClusterSet(stream);
Int1 = stream.ReadValueS32();
SceneClusterSet = new SceneClusterSet(stream);
for (int i = 0; i < SNONavMeshFunctions.Length; i++)
{
SNONavMeshFunctions[i] = stream.ReadValueS32();

View File

@ -908,13 +908,13 @@ namespace DiIiS_NA.D3_GameServer.GSSystem.GameSystem
AdditionalTargetCounter++;
foreach (var player in QuestManager.Game.Players.Values)
{
List<GameServer.GSSystem.MapSystem.Scene> Scenes = new List<GameServer.GSSystem.MapSystem.Scene>();
List<GameServer.GSSystem.MapSystem.Scene> scenes = new List<GameServer.GSSystem.MapSystem.Scene>();
int monsterCount = 0;
foreach (var scene in QuestManager.Game.GetWorld(world).Scenes.Values)
if (!scene.SceneSNO.Name.ToLower().Contains("filler"))
if (scene.Specification.SNOLevelAreas[0] == LevelArea)
{
Scenes.Add(scene);
scenes.Add(scene);
foreach (var act in scene.Actors)
if (act is Monster)
monsterCount++;
@ -934,7 +934,7 @@ namespace DiIiS_NA.D3_GameServer.GSSystem.GameSystem
{
while (monsterCount < AdditionalTargetCounter + 20)
{
GameServer.Core.Types.Math.Vector3D scenePoint = Scenes.PickRandom().Position;
GameServer.Core.Types.Math.Vector3D scenePoint = scenes.PickRandom().Position;
GameServer.Core.Types.Math.Vector3D point = null;
while (true)
{

View File

@ -226,7 +226,7 @@ namespace DiIiS_NA.GameServer.GSSystem.QuestSystem
});
#endregion
#region Rescue Cain
Game.QuestManager.Quests.Add(72095, new Quest { RewardXp = 3630, RewardGold = 190, Completed = false, Saveable = true, NextQuest = 72221, Steps = new Dictionary<int, QuestStep> { } });
Game.QuestManager.Quests.Add(72095, new Quest { RewardXp = 3630, RewardGold = 190, Completed = false, Saveable = true, NextQuest = 72221});
Game.QuestManager.Quests[72095].Steps.Add(-1, new QuestStep
{
@ -543,7 +543,7 @@ namespace DiIiS_NA.GameServer.GSSystem.QuestSystem
});
#endregion
#region Shattered Crown
Game.QuestManager.Quests.Add(72221, new Quest { RewardXp = 900, RewardGold = 195, Completed = false, Saveable = true, NextQuest = 72061, Steps = new Dictionary<int, QuestStep> { } });
Game.QuestManager.Quests.Add(72221, new Quest { RewardXp = 900, RewardGold = 195, Completed = false, Saveable = true, NextQuest = 72061});
Game.QuestManager.Quests[72221].Steps.Add(-1, new QuestStep
{
@ -770,7 +770,7 @@ namespace DiIiS_NA.GameServer.GSSystem.QuestSystem
});
#endregion
#region Reign of Black King
Game.QuestManager.Quests.Add(72061, new Quest { RewardXp = 5625, RewardGold = 810, Completed = false, Saveable = true, NextQuest = 117779, Steps = new Dictionary<int, QuestStep> { } });
Game.QuestManager.Quests.Add(72061, new Quest { RewardXp = 5625, RewardGold = 810, Completed = false, Saveable = true, NextQuest = 117779});
Game.QuestManager.Quests[72061].Steps.Add(-1, new QuestStep
{
@ -1137,7 +1137,7 @@ namespace DiIiS_NA.GameServer.GSSystem.QuestSystem
});
#endregion
#region Tyrael Sword
Game.QuestManager.Quests.Add(117779, new Quest { RewardXp = 4125, RewardGold = 630, Completed = false, Saveable = true, NextQuest = 72738, Steps = new Dictionary<int, QuestStep> { } });
Game.QuestManager.Quests.Add(117779, new Quest { RewardXp = 4125, RewardGold = 630, Completed = false, Saveable = true, NextQuest = 72738});
Game.QuestManager.Quests[117779].Steps.Add(-1, new QuestStep
{
@ -1253,7 +1253,7 @@ namespace DiIiS_NA.GameServer.GSSystem.QuestSystem
});
#endregion
#region Broken Blade
Game.QuestManager.Quests.Add(72738, new Quest { RewardXp = 6205, RewardGold = 1065, Completed = false, Saveable = true, NextQuest = 73236, Steps = new Dictionary<int, QuestStep> { } });
Game.QuestManager.Quests.Add(72738, new Quest { RewardXp = 6205, RewardGold = 1065, Completed = false, Saveable = true, NextQuest = 73236});
Game.QuestManager.Quests[72738].Steps.Add(-1, new QuestStep
{
@ -1590,7 +1590,7 @@ namespace DiIiS_NA.GameServer.GSSystem.QuestSystem
});
#endregion
#region Doom of Vortham
Game.QuestManager.Quests.Add(73236, new Quest { RewardXp = 4950, RewardGold = 670, Completed = false, Saveable = true, NextQuest = 72546, Steps = new Dictionary<int, QuestStep> { } });
Game.QuestManager.Quests.Add(73236, new Quest { RewardXp = 4950, RewardGold = 670, Completed = false, Saveable = true, NextQuest = 72546});
Game.QuestManager.Quests[73236].Steps.Add(-1, new QuestStep
{
@ -1778,7 +1778,7 @@ namespace DiIiS_NA.GameServer.GSSystem.QuestSystem
});
#endregion
#region To the Black Cult
Game.QuestManager.Quests.Add(72546, new Quest { RewardXp = 8275, RewardGold = 455, Completed = false, Saveable = true, NextQuest = 72801, Steps = new Dictionary<int, QuestStep> { } });
Game.QuestManager.Quests.Add(72546, new Quest { RewardXp = 8275, RewardGold = 455, Completed = false, Saveable = true, NextQuest = 72801});
Game.QuestManager.Quests[72546].Steps.Add(-1, new QuestStep
{
@ -2008,7 +2008,7 @@ namespace DiIiS_NA.GameServer.GSSystem.QuestSystem
});
#endregion
#region Captived Angel
Game.QuestManager.Quests.Add(72801, new Quest { RewardXp = 10925, RewardGold = 1465, Completed = false, Saveable = true, NextQuest = 136656, Steps = new Dictionary<int, QuestStep> { } });
Game.QuestManager.Quests.Add(72801, new Quest { RewardXp = 10925, RewardGold = 1465, Completed = false, Saveable = true, NextQuest = 136656});
Game.QuestManager.Quests[72801].Steps.Add(-1, new QuestStep
{
@ -2202,7 +2202,7 @@ namespace DiIiS_NA.GameServer.GSSystem.QuestSystem
});
#endregion
#region Return to New Tristram
Game.QuestManager.Quests.Add(136656, new Quest { RewardXp = 0, RewardGold = 0, Completed = false, Saveable = true, NextQuest = -1, Steps = new Dictionary<int, QuestStep> { } });
Game.QuestManager.Quests.Add(136656, new Quest { RewardXp = 0, RewardGold = 0, Completed = false, Saveable = true, NextQuest = -1});
Game.QuestManager.Quests[136656].Steps.Add(-1, new QuestStep
{

View File

@ -33,7 +33,7 @@ namespace DiIiS_NA.GameServer.GSSystem.QuestSystem
public class Quest
{
public bool Completed;
public Dictionary<int, QuestStep> Steps;
public Dictionary<int, QuestStep> Steps = new();
public int NextQuest;
public int RewardXp;
public int RewardGold;

View File

@ -6,87 +6,5 @@ namespace DiIiS_NA
{
public static class Extensions
{
/// <summary>
/// Transforms a timespan to a readable text.
/// E.g.:
/// 1 day, 2 hours, 3 minutes and 4 seconds
/// 5 hours, 6 minutes and 7 seconds
///
/// If over certain threshold (millennium or more) it will only return the number of days.
/// </summary>
/// <param name="span">The timespan to be converted</param>
/// <returns>The readable text</returns>
public static string ToText(this TimeSpan span)
{
List<string> parts = new();
// if days are divided by 365, we have years, otherwise we have months or days
if (span.Days / 365 > 0)
{
// if days are divided by 365, we have years
parts.Add($"{((double)span.Days / 365):F} year{(span.Days / 365 > 1 ? "s" : "")}");
// get months from the remaining days
int months = span.Days % 365 / 30;
if (months > 0)
parts.Add($"{months} month{(months > 1 ? "s" : "")}");
// get remaining days
int days = span.Days % 365 % 30;
if (days > 0)
parts.Add($"{days} day{(days > 1 ? "s" : "")}");
}
else if (span.Days / 30 > 0)
{
// if days are divided by 30, we have months
parts.Add($"{((double)span.Days / 30):F} month{(span.Days / 30 > 1 ? "s" : "")}");
// get remaining days
int days = span.Days % 30;
if (days > 0)
parts.Add($"{days} day{(days > 1 ? "s" : "")}");
}
else if (span.Days > 0)
// if days are not divided by 365 or 30, we have days
parts.Add( $"{span.Days} day{(span.Days > 1 ? "s" : "")}");
if (span.Hours > 0)
parts.Add($"{span.Hours} hour{(span.Hours > 1 ? "s" : "")}");
if (span.Minutes > 0)
parts.Add($"{span.Minutes} minute{(span.Minutes > 1 ? "s" : "")}");
if (span.Seconds > 0)
parts.Add($"{span.Seconds} second{(span.Seconds > 1 ? "s" : "")}");
var result = parts.ToArray();
return string.Join(", ", result[..^1]) + (result.Length > 1 ? " and " : "") + parts[^1];
}
public static string ToSmallText(this TimeSpan span)
{
List<string> parts = new();
if (span.Days / 365 > 0)
{
parts.Add($"{((double)span.Days / 365):F}y");
int months = span.Days % 365 / 30;
if (months > 0)
parts.Add($"{months}m");
int days = span.Days % 365 % 30;
if (days > 0)
parts.Add($"{days}d");
}
else if (span.Days / 30 > 0)
{
parts.Add($"{((double)span.Days / 30):F}m");
int days = span.Days % 30;
if (days > 0)
parts.Add($"{days}d");
}
else if (span.Days > 0)
parts.Add($"{span.Days}d");
if (span.Hours > 0)
parts.Add($"{span.Hours}h");
if (span.Minutes > 0)
parts.Add($"{span.Minutes}m");
if (span.Seconds > 0)
parts.Add($"{span.Seconds}s");
return string.Join(" ", parts);
}
}
}