port(m1): wave 6f — Unity primitive operators (362->304)

CS0019 operator gaps on value-type shims:
- Vector2: ==/!=, Vector2*Vector2, Equals/GetHashCode.
- Vector4: *float, +/-, ==/!=, Equals/GetHashCode.
- Color: ==/!= (Color==Color32 via existing implicit conv), Equals/GetHashCode.
- Rect: ==/!=; Matrix4x4: *, GetColumn/GetRow/indexer.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
gamer147
2026-06-06 00:08:11 -04:00
parent 8c9fe7a1b9
commit e5e05deadb
3 changed files with 22 additions and 1 deletions

View File

@@ -11,6 +11,14 @@ namespace UnityEngine
{
public static Vector4 zero => default;
public static Vector4 one => new Vector4(1f, 1f, 1f, 1f);
public static Vector4 operator *(Vector4 a, float s) => new Vector4(a.x * s, a.y * s, a.z * s, a.w * s);
public static Vector4 operator *(float s, Vector4 a) => new Vector4(a.x * s, a.y * s, a.z * s, a.w * s);
public static Vector4 operator +(Vector4 a, Vector4 b) => new Vector4(a.x + b.x, a.y + b.y, a.z + b.z, a.w + b.w);
public static Vector4 operator -(Vector4 a, Vector4 b) => new Vector4(a.x - b.x, a.y - b.y, a.z - b.z, a.w - b.w);
public static bool operator ==(Vector4 a, Vector4 b) => a.x == b.x && a.y == b.y && a.z == b.z && a.w == b.w;
public static bool operator !=(Vector4 a, Vector4 b) => !(a == b);
public override bool Equals(object o) => o is Vector4 v && this == v;
public override int GetHashCode() => x.GetHashCode() ^ (y.GetHashCode() << 2) ^ (z.GetHashCode() << 4) ^ (w.GetHashCode() << 6);
public Vector4(float x, float y, float z) { this.x = x; this.y = y; this.z = z; this.w = 0f; }
public Vector4(float x, float y) { this.x = x; this.y = y; this.z = 0f; this.w = 0f; }
// UnityEngine implicitly promotes/truncates between Vector2/3/4.