Rename to Vec3f

This commit is contained in:
Jelle
2022-10-18 21:16:01 +02:00
parent 66df369404
commit 9c2c54b076
13 changed files with 120 additions and 122 deletions

View File

@@ -49,7 +49,7 @@ public IEnumerable<PlacementLocation8a> GetIntersectingLocations(IReadOnlyList<P
return GetIntersectingLocations(locations, bias, c, Scalar);
}
private static IEnumerable<PlacementLocation8a> GetIntersectingLocations(IReadOnlyList<PlacementLocation8a> locations, float bias, PlacementV3f8a c, float scalar)
private static IEnumerable<PlacementLocation8a> GetIntersectingLocations(IReadOnlyList<PlacementLocation8a> locations, float bias, Vec3f c, float scalar)
{
var result = new List<PlacementLocation8a>();
foreach (var loc in locations)

View File

@@ -38,9 +38,9 @@ public class PlacementItem8a_F03
[FlatBufferItem(04)] public string Field_04 { get; set; } = string.Empty;
[FlatBufferItem(05)] public string Field_05 { get; set; } = string.Empty;
[FlatBufferItem(06)] public string Field_06 { get; set; } = string.Empty;
[FlatBufferItem(07)] public PlacementV3f8a Field_07 { get; set; } = new();
[FlatBufferItem(07)] public Vec3f Field_07 { get; set; } = new();
[FlatBufferItem(08)] public PlacementItem8a_F08 Field_08 { get; set; } = new();
[FlatBufferItem(09)] public PlacementV3f8a Field_09 { get; set; } = new();
[FlatBufferItem(09)] public Vec3f Field_09 { get; set; } = new();
}
[FlatBufferTable, TypeConverter(typeof(ExpandableObjectConverter))]

View File

@@ -176,7 +176,7 @@ public bool IntersectsSphere(float x, float y, float z, float sphereRadius)
}
}
public bool Contains(PlacementV3f8a v) => Contains(v.X, v.Y, v.Z);
public bool Contains(Vec3f v) => Contains(v.X, v.Y, v.Z);
public string LocationTypeSummary
{

View File

@@ -20,9 +20,9 @@ public class PlacementParameters8a : IHasCondition8a
[FlatBufferItem(4)] public string ConditionArg3 { get; set; } = string.Empty;
[FlatBufferItem(5)] public string ConditionArg4 { get; set; } = string.Empty;
[FlatBufferItem(6)] public string ConditionArg5 { get; set; } = string.Empty;
[FlatBufferItem(7)] public PlacementV3f8a Coordinates { get; set; } = new();
[FlatBufferItem(8)] public PlacementV3f8a Rotation { get; set; } = new();
[FlatBufferItem(9)] public PlacementV3f8a Scale { get; set; } = new();
[FlatBufferItem(7)] public Vec3f Coordinates { get; set; } = new();
[FlatBufferItem(8)] public Vec3f Rotation { get; set; } = new();
[FlatBufferItem(9)] public Vec3f Scale { get; set; } = new();
public override string ToString() => $"PlacementParameters(/* ConditionTypeID = */ {this.GetConditionTypeSummary()}, /* Condition = */ {this.GetConditionSummary()}, {Coordinates}, {Rotation}, {Scale})";
}

View File

@@ -32,25 +32,25 @@ public class PlacementSearchItem
[FlatBufferItem(05)] public int Rate { get; set; }
[FlatBufferItem(06)] public bool Field_06 { get; set; } // bool
[FlatBufferItem(07)] public bool Field_07 { get; set; } // bool
[FlatBufferItem(08)] public PlacementV3f8a Field_08 { get; set; } = new();
[FlatBufferItem(08)] public Vec3f Field_08 { get; set; } = new();
[FlatBufferItem(09)] public byte Field_09 { get; set; } // bool
[FlatBufferItem(10)] public PlacementV3f8a Field_10 { get; set; } = new();
[FlatBufferItem(10)] public Vec3f Field_10 { get; set; } = new();
[FlatBufferItem(11)] public bool Field_11 { get; set; } // bool
[FlatBufferItem(12)] public PlacementV3f8a Field_12 { get; set; } = new();
[FlatBufferItem(12)] public Vec3f Field_12 { get; set; } = new();
[FlatBufferItem(13)] public bool Field_13 { get; set; } // bool
[FlatBufferItem(14)] public PlacementV3f8a Field_14 { get; set; } = new();
[FlatBufferItem(14)] public Vec3f Field_14 { get; set; } = new();
[FlatBufferItem(15)] public bool Field_15 { get; set; } // bool
[FlatBufferItem(16)] public PlacementV3f8a Field_16 { get; set; } = new();
[FlatBufferItem(16)] public Vec3f Field_16 { get; set; } = new();
[FlatBufferItem(17)] public bool Field_17 { get; set; } // bool
[FlatBufferItem(18)] public PlacementV3f8a Field_18 { get; set; } = new();
[FlatBufferItem(18)] public Vec3f Field_18 { get; set; } = new();
[FlatBufferItem(19)] public bool Field_19 { get; set; } // bool
[FlatBufferItem(20)] public PlacementV3f8a Field_20 { get; set; } = new();
[FlatBufferItem(20)] public Vec3f Field_20 { get; set; } = new();
[FlatBufferItem(21)] public bool Field_21 { get; set; } // bool
[FlatBufferItem(22)] public PlacementV3f8a Field_22 { get; set; } = new();
[FlatBufferItem(22)] public Vec3f Field_22 { get; set; } = new();
[FlatBufferItem(23)] public bool Field_23 { get; set; } // bool
[FlatBufferItem(24)] public PlacementV3f8a Field_24 { get; set; } = new();
[FlatBufferItem(24)] public Vec3f Field_24 { get; set; } = new();
[FlatBufferItem(25)] public bool Field_25 { get; set; } // bool
[FlatBufferItem(26)] public PlacementV3f8a Field_26 { get; set; } = new();
[FlatBufferItem(26)] public Vec3f Field_26 { get; set; } = new();
public PlacementParameters8a Parameters
{

View File

@@ -22,8 +22,8 @@ public class PlacementSpawner8a : ISlotTableConsumer
[FlatBufferItem(2)] public PlacementParameters8a[] Field_02 { get; set; } = { new() };
[FlatBufferItem(3)] public string Shape { get; set; } = string.Empty; // only set by Wormhole spawners
[FlatBufferItem(4)] public float Scalar { get; set; } // how big of a radius they can spawn in?
[FlatBufferItem(5)] public PlacementV3f8a Field_05 { get; set; } = new(); // always default values
[FlatBufferItem(6)] public PlacementV3f8a Field_06 { get; set; } = new(); // always default values
[FlatBufferItem(5)] public Vec3f Field_05 { get; set; } = new(); // always default values
[FlatBufferItem(6)] public Vec3f Field_06 { get; set; } = new(); // always default values
[FlatBufferItem(7)] public int MinSpawnCount { get; set; }
[FlatBufferItem(8)] public int MaxSpawnCount { get; set; }
[FlatBufferItem(9)] public int Field_09 { get; set; } // 2 for a single tangela spawner, and 8 for a single lickitung spawner
@@ -71,7 +71,7 @@ public IEnumerable<PlacementLocation8a> GetIntersectingLocations(IReadOnlyList<P
return GetIntersectingLocations(locations, bias, c, Scalar);
}
private static IEnumerable<PlacementLocation8a> GetIntersectingLocations(IReadOnlyList<PlacementLocation8a> locations, float bias, PlacementV3f8a c, float scalar)
private static IEnumerable<PlacementLocation8a> GetIntersectingLocations(IReadOnlyList<PlacementLocation8a> locations, float bias, Vec3f c, float scalar)
{
var result = new List<PlacementLocation8a>();
foreach (var loc in locations)

View File

@@ -21,11 +21,11 @@ public class PlacementSpawnerF218a
[FlatBufferItem(3)] public ulong VarHash3 { get; set; } // ??? Is this as 01/02?
[FlatBufferItem(4)] public ulong VarHash4 { get; set; } // ??? Is this as 01/02?
[FlatBufferItem(5)] public ulong VarHash5 { get; set; } // ??? Is this as 01/02?
[FlatBufferItem(6)] public PlacementV3f8a Field_06 { get; set; } = new();
[FlatBufferItem(6)] public Vec3f Field_06 { get; set; } = new();
[FlatBufferItem(7)] public string Field_07 { get; set; } = string.Empty;
[FlatBufferItem(8)] public float Scalar { get; set; }
[FlatBufferItem(9)] public PlacementV3f8a Field_09 { get; set; } = new();
[FlatBufferItem(10)] public PlacementV3f8a Field_10 { get; set; } = new();
[FlatBufferItem(9)] public Vec3f Field_09 { get; set; } = new();
[FlatBufferItem(10)] public Vec3f Field_10 { get; set; } = new();
[FlatBufferItem(11)] public int NumVarHashes { get; set; }
public string SlotSummary

View File

@@ -43,7 +43,7 @@ public IEnumerable<PlacementLocation8a> GetIntersectingLocations(IReadOnlyList<P
return GetIntersectingLocations(locations, bias, c, 0);
}
private static IEnumerable<PlacementLocation8a> GetIntersectingLocations(IReadOnlyList<PlacementLocation8a> locations, float bias, PlacementV3f8a c, float scalar)
private static IEnumerable<PlacementLocation8a> GetIntersectingLocations(IReadOnlyList<PlacementLocation8a> locations, float bias, Vec3f c, float scalar)
{
var result = new List<PlacementLocation8a>();
foreach (var loc in locations)

View File

@@ -1,89 +0,0 @@
using System;
using System.ComponentModel;
using FlatSharp.Attributes;
// ReSharper disable UnusedAutoPropertyAccessor.Global
// ReSharper disable ClassNeverInstantiated.Global
// ReSharper disable MemberCanBePrivate.Global
// ReSharper disable UnusedType.Global
// ReSharper disable UnusedMember.Global
// ReSharper disable AutoPropertyCanBeMadeGetOnly.Global
namespace pkNX.Structures.FlatBuffers;
[FlatBufferTable, TypeConverter(typeof(ExpandableObjectConverter))]
public class PlacementV3f8a : IEquatable<PlacementV3f8a>
{
[FlatBufferItem(0)] public float X { get; set; }
[FlatBufferItem(1)] public float Y { get; set; }
[FlatBufferItem(2)] public float Z { get; set; }
public PlacementV3f8a()
{
X = 0;
Y = 0;
Z = 0;
}
public PlacementV3f8a(float x = 0, float y = 0, float z = 0)
{
X = x;
Y = y;
Z = z;
}
public bool IsOne => X is 1 && Y is 1 && Z is 1;
public bool IsZero => X is 0 && Y is 0 && Z is 0;
public float Magnitude => (float)Math.Sqrt(MagnitudeSqr);
public float MagnitudeSqr => Dot(this);
public PlacementV3f8a Normalized => this * (1 / Magnitude);
public float Dot(PlacementV3f8a other) => (X * other.X) + (Y * other.Y) + (Z * other.Z);
public PlacementV3f8a Cross(PlacementV3f8a other) => new((Y * other.Z) - (Z * other.Y), (Z * other.X) - (X * other.Z), (X * other.Y) - (Y * other.X));
public float DistanceTo(PlacementV3f8a other) => (this - other).Magnitude;
public float DistanceToSqr(PlacementV3f8a other) => (this - other).MagnitudeSqr;
public PlacementV3f8a Lerp(PlacementV3f8a other, float t) => this + ((other - this) * t);
public PlacementV3f8a Clone() => new()
{
X = X,
Y = Y,
Z = Z,
};
public override string ToString() => $"V3f({X}, {Y}, {Z})";
public string ToTriple() => $"({X}, {Y}, {Z})";
public bool Equals(PlacementV3f8a? other)
{
if (other is null) return false;
if (ReferenceEquals(this, other)) return true;
return X.Equals(other.X) && Y.Equals(other.Y) && Z.Equals(other.Z);
}
public override bool Equals(object? obj)
{
if (obj is null) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != GetType()) return false;
return Equals((PlacementV3f8a)obj);
}
public override int GetHashCode() => HashCode.Combine(X, Y, Z);
public static PlacementV3f8a operator -(PlacementV3f8a v) => new(-v.X, -v.Y, -v.Z);
public static PlacementV3f8a operator +(PlacementV3f8a l, PlacementV3f8a r) => new(l.X + r.X, l.Y + r.Y, l.Z + r.Z);
public static PlacementV3f8a operator -(PlacementV3f8a l, PlacementV3f8a r) => new(l.X - r.X, l.Y - r.Y, l.Z - r.Z);
public static PlacementV3f8a operator *(PlacementV3f8a l, PlacementV3f8a r) => new(l.X * r.X, l.Y * r.Y, l.Z * r.Z);
public static PlacementV3f8a operator /(PlacementV3f8a l, PlacementV3f8a r) => new(l.X / r.X, l.Y / r.Y, l.Z / r.Z);
public static PlacementV3f8a operator +(PlacementV3f8a l, float r) => new(l.X + r, l.Y + r, l.Z + r);
public static PlacementV3f8a operator -(PlacementV3f8a l, float r) => new(l.X - r, l.Y - r, l.Z - r);
public static PlacementV3f8a operator *(PlacementV3f8a l, float r) => new(l.X * r, l.Y * r, l.Z * r);
public static PlacementV3f8a operator /(PlacementV3f8a l, float r) => new(l.X / r, l.Y / r, l.Z / r);
public static bool operator ==(PlacementV3f8a? left, PlacementV3f8a? right) => Equals(left, right);
public static bool operator !=(PlacementV3f8a? left, PlacementV3f8a? right) => !Equals(left, right);
}

View File

@@ -27,7 +27,7 @@ public class AreaSettings8a
{
[FlatBufferItem(00)] public string Name { get; set; } = string.Empty;
[FlatBufferItem(01)] public string NameParent { get; set; } = string.Empty;
[FlatBufferItem(02)] public PlacementV3f8a Position { get; set; } = new();
[FlatBufferItem(02)] public Vec3f Position { get; set; } = new();
[FlatBufferItem(03)] public bool Flag_03 { get; set; }
[FlatBufferItem(04)] public bool Flag_04 { get; set; }
[FlatBufferItem(05)] public bool Flag_05 { get; set; }
@@ -77,8 +77,8 @@ public class AreaSettings8a
[FlatBufferItem(49)] public string SoundBank { get; set; } = string.Empty;
[FlatBufferItem(50)] public AreaSettings8a_F50 Field_50 { get; set; } = new();
[FlatBufferItem(51)] public string Archive { get; set; } = string.Empty;
[FlatBufferItem(52)] public PlacementV3f8a Field_52 { get; set; } = new();
[FlatBufferItem(53)] public PlacementV3f8a Field_53 { get; set; } = new();
[FlatBufferItem(52)] public Vec3f Field_52 { get; set; } = new();
[FlatBufferItem(53)] public Vec3f Field_53 { get; set; } = new();
[FlatBufferItem(54)] public ulong VisibleFlagHash { get; set; } //A flag from system_works
[FlatBufferItem(55)] public bool Field_55 { get; set; }

View File

@@ -75,10 +75,10 @@ public class PokeAI8a
[FlatBufferItem(24)] public PokeAI8a_F24 Field_24 { get; set; } = new();
[FlatBufferItem(25)] public float Field_25 { get; set; } = 20; // float
[FlatBufferItem(26)] public float Field_26 { get; set; } = 30; // float
[FlatBufferItem(27)] public PlacementV3f8a Field_27 { get; set; } = new(20, 50, 100);
[FlatBufferItem(28)] public PlacementV3f8a Field_28 { get; set; } = new(20, 50, 100);
[FlatBufferItem(29)] public PlacementV3f8a Field_29 { get; set; } = new(20, 50, 100);
[FlatBufferItem(30)] public PlacementV3f8a Field_30 { get; set; } = new(15, 10, 15);
[FlatBufferItem(27)] public Vec3f Field_27 { get; set; } = new(20, 50, 100);
[FlatBufferItem(28)] public Vec3f Field_28 { get; set; } = new(20, 50, 100);
[FlatBufferItem(29)] public Vec3f Field_29 { get; set; } = new(20, 50, 100);
[FlatBufferItem(30)] public Vec3f Field_30 { get; set; } = new(15, 10, 15);
[FlatBufferItem(31)] public int Field_31 { get; set; } // int
[FlatBufferItem(32)] public int Field_32 { get; set; } = -1;// int
[FlatBufferItem(33)] public int Field_33 { get; set; } // int

View File

@@ -0,0 +1,87 @@
using System;
using System.ComponentModel;
using FlatSharp.Attributes;
// ReSharper disable UnusedAutoPropertyAccessor.Global
// ReSharper disable ClassNeverInstantiated.Global
// ReSharper disable MemberCanBePrivate.Global
// ReSharper disable UnusedType.Global
// ReSharper disable UnusedMember.Global
// ReSharper disable AutoPropertyCanBeMadeGetOnly.Global
namespace pkNX.Structures.FlatBuffers;
[FlatBufferTable, TypeConverter(typeof(ExpandableObjectConverter))]
public class Vec3f : IEquatable<Vec3f>
{
[FlatBufferItem(0)] public float X { get; set; }
[FlatBufferItem(1)] public float Y { get; set; }
[FlatBufferItem(2)] public float Z { get; set; }
public static readonly Vec3f Zero = new();
public static readonly Vec3f One = new(1, 1, 1);
public Vec3f() { }
public Vec3f(float x = 0, float y = 0, float z = 0)
{
X = x;
Y = y;
Z = z;
}
public bool IsOne => X is 1 && Y is 1 && Z is 1;
public bool IsZero => X is 0 && Y is 0 && Z is 0;
public float Magnitude => MathF.Sqrt(MagnitudeSqr);
public float MagnitudeSqr => Dot(this);
public Vec3f Normalized => this * (1 / Magnitude);
public float Dot(Vec3f other) => (X * other.X) + (Y * other.Y) + (Z * other.Z);
public Vec3f Cross(Vec3f other) => new((Y * other.Z) - (Z * other.Y), (Z * other.X) - (X * other.Z), (X * other.Y) - (Y * other.X));
public float DistanceTo(Vec3f other) => (this - other).Magnitude;
public float DistanceToSqr(Vec3f other) => (this - other).MagnitudeSqr;
public Vec3f Lerp(Vec3f other, float t) => this + ((other - this) * t);
public Vec3f Clone() => new()
{
X = X,
Y = Y,
Z = Z,
};
public override string ToString() => $"V3f({X}, {Y}, {Z})";
public string ToTriple() => $"({X}, {Y}, {Z})";
public bool Equals(Vec3f? other)
{
if (other is null) return false;
if (ReferenceEquals(this, other)) return true;
return X.Equals(other.X) && Y.Equals(other.Y) && Z.Equals(other.Z);
}
public override bool Equals(object? obj)
{
if (obj is null) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != GetType()) return false;
return Equals((Vec3f)obj);
}
public override int GetHashCode() => HashCode.Combine(X, Y, Z);
public static Vec3f operator -(Vec3f v) => new(-v.X, -v.Y, -v.Z);
public static Vec3f operator +(Vec3f l, Vec3f r) => new(l.X + r.X, l.Y + r.Y, l.Z + r.Z);
public static Vec3f operator -(Vec3f l, Vec3f r) => new(l.X - r.X, l.Y - r.Y, l.Z - r.Z);
public static Vec3f operator *(Vec3f l, Vec3f r) => new(l.X * r.X, l.Y * r.Y, l.Z * r.Z);
public static Vec3f operator /(Vec3f l, Vec3f r) => new(l.X / r.X, l.Y / r.Y, l.Z / r.Z);
public static Vec3f operator +(Vec3f l, float r) => new(l.X + r, l.Y + r, l.Z + r);
public static Vec3f operator -(Vec3f l, float r) => new(l.X - r, l.Y - r, l.Z - r);
public static Vec3f operator *(Vec3f l, float r) => new(l.X * r, l.Y * r, l.Z * r);
public static Vec3f operator /(Vec3f l, float r) => new(l.X / r, l.Y / r, l.Z / r);
public static bool operator ==(Vec3f? left, Vec3f? right) => Equals(left, right);
public static bool operator !=(Vec3f? left, Vec3f? right) => !Equals(left, right);
}

View File

@@ -252,12 +252,12 @@ public class AreaDef
public readonly string NameSummary;
public readonly int Min;
public readonly int Max;
public readonly PlacementV3f8a Position;
public readonly Vec3f Position;
public readonly SpawnerType Type;
public readonly EncounterSlot8a[] Slots;
public readonly float Radius;
public AreaDef(string NameSummary, int min, int max, PlacementV3f8a position, SpawnerType type, EncounterSlot8a[] slots, float radius)
public AreaDef(string NameSummary, int min, int max, Vec3f position, SpawnerType type, EncounterSlot8a[] slots, float radius)
{
this.NameSummary = NameSummary;
Min = min;