mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-15 03:30:53 +01:00
* RSI WiP * More work but we're doing bsdiff now * RSI loading seems to mostly work. * Vector2u deserialization test. * Add in packages again. * This is the part where I realize I need a path manipulation library. * The start of a path class but it's late so I'm going to bed. * HIGHLY theoretical ResourcePath code. Partially tested but not really. * Allow x86 for unit tests I guess jesus christ. Thanks Microsoft for still not shipping x64 VS in 2018. * Resource paths work & are tested. * I missed a doc spot. * ResourcePaths implemented on the server. * Client works with resource paths. TIME FOR A REFACTOR. * Some work but this might be a stupid idea so I migh throw it in the trash. * Resources refactored completely. They now only get the requested resourcepath. They're in charge of opening files to load. * RSI Loader WORKS. * Update AudioResource for new loading support. * Fix package references. * Fix more references. * Gonna work now?
82 lines
2.4 KiB
C#
82 lines
2.4 KiB
C#
using Newtonsoft.Json;
|
|
using System;
|
|
using System.Runtime.InteropServices;
|
|
|
|
namespace SS14.Shared.Maths
|
|
{
|
|
[JsonObject(memberSerialization: MemberSerialization.Fields)]
|
|
[Serializable]
|
|
[StructLayout(LayoutKind.Sequential)]
|
|
public struct Vector2u : IEquatable<Vector2u>
|
|
{
|
|
/// <summary>
|
|
/// The X component of the Vector2i.
|
|
/// </summary>
|
|
public readonly uint X;
|
|
|
|
/// <summary>
|
|
/// The Y component of the Vector2i.
|
|
/// </summary>
|
|
public readonly uint Y;
|
|
|
|
/// <summary>
|
|
/// Construct a vector from its coordinates.
|
|
/// </summary>
|
|
/// <param name="x">X coordinate</param>
|
|
/// <param name="y">Y coordinate</param>
|
|
public Vector2u(uint x, uint y)
|
|
{
|
|
X = x;
|
|
Y = y;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Compare a vector to another vector and check if they are equal.
|
|
/// </summary>
|
|
/// <param name="other">Other vector to check.</param>
|
|
/// <returns>True if the two vectors are equal.</returns>
|
|
public bool Equals(Vector2u other)
|
|
{
|
|
return X == other.X && Y == other.Y;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Compare a vector to an object and check if they are equal.
|
|
/// </summary>
|
|
/// <param name="obj">Other object to check.</param>
|
|
/// <returns>True if Object and vector are equal.</returns>
|
|
public override bool Equals(object obj)
|
|
{
|
|
if (ReferenceEquals(null, obj)) return false;
|
|
return obj is Vector2u vec && Equals(vec);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Returns the hash code for this instance.
|
|
/// </summary>
|
|
/// <returns>A unique hash code for this instance.</returns>
|
|
public override int GetHashCode()
|
|
{
|
|
unchecked
|
|
{
|
|
return ((int)X * 397) ^ (int)Y;
|
|
}
|
|
}
|
|
|
|
public static Vector2u operator / (Vector2u vector, uint divider)
|
|
{
|
|
return new Vector2u(vector.X / divider, vector.Y / divider);
|
|
}
|
|
|
|
public static implicit operator Vector2(Vector2u vector)
|
|
{
|
|
return new Vector2(vector.X, vector.Y);
|
|
}
|
|
|
|
public static explicit operator Vector2u(Vector2 vector)
|
|
{
|
|
return new Vector2u((uint)vector.X, (uint)vector.Y);
|
|
}
|
|
}
|
|
}
|