From c935f4be4ee6a0a456fd0ebb34f4e0a842a2731d Mon Sep 17 00:00:00 2001 From: Parnic Date: Thu, 15 Dec 2022 15:32:23 -0600 Subject: [PATCH] Make immutable --- src/Util/Vec2.cs | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/src/Util/Vec2.cs b/src/Util/Vec2.cs index b2a48f8..5b1c369 100644 --- a/src/Util/Vec2.cs +++ b/src/Util/Vec2.cs @@ -2,8 +2,8 @@ public struct ivec2 : IEquatable, IComparable, IComparable { - public int x = 0; - public int y = 0; + public readonly int x = 0; + public readonly int y = 0; public static readonly ivec2 ZERO = new ivec2(0, 0); public static readonly ivec2 ONE = new ivec2(1, 1); @@ -58,21 +58,7 @@ public struct ivec2 : IEquatable, IComparable, IComparable return this + dir; } - public int this[int i] - { - get => (i == 0) ? x : y; - set - { - if (i == 0) - { - x = value; - } - else - { - y = value; - } - } - } + public int this[int i] => (i == 0) ? x : y; public static ivec2 operator +(ivec2 v) => v; public static ivec2 operator -(ivec2 v) => new ivec2(-v.x, -v.y);