mirror of
				https://github.com/MaddyThorson/StrawberryBF.git
				synced 2025-10-31 01:01:32 +08:00 
			
		
		
		
	Vector operators. Rect constructor. Scene condition getters
This commit is contained in:
		| @ -166,6 +166,14 @@ namespace Strawberry | |||||||
| 			return false; | 			return false; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
|  | 		public bool Check<T>(Point point, delegate bool(T) condition) where T : Component, IHasHitbox | ||||||
|  | 		{ | ||||||
|  | 			for (T c in componentTracker[typeof(T)]) | ||||||
|  | 				if (c.Hitbox.Check(point) && condition(c)) | ||||||
|  | 					return true; | ||||||
|  | 			return false; | ||||||
|  | 		} | ||||||
|  |  | ||||||
| 		public bool Check<T>(Rect rect) where T : Component, IHasHitbox | 		public bool Check<T>(Rect rect) where T : Component, IHasHitbox | ||||||
| 		{ | 		{ | ||||||
| 			for (T c in componentTracker[typeof(T)]) | 			for (T c in componentTracker[typeof(T)]) | ||||||
| @ -174,6 +182,14 @@ namespace Strawberry | |||||||
| 			return false; | 			return false; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
|  | 		public bool Check<T>(Rect rect, delegate bool(T) condition) where T : Component, IHasHitbox | ||||||
|  | 		{ | ||||||
|  | 			for (T c in componentTracker[typeof(T)]) | ||||||
|  | 				if (c.Hitbox.Check(rect) && condition(c)) | ||||||
|  | 					return true; | ||||||
|  | 			return false; | ||||||
|  | 		} | ||||||
|  |  | ||||||
| 		public T First<T>() where T : Component | 		public T First<T>() where T : Component | ||||||
| 		{ | 		{ | ||||||
| 			for (T c in componentTracker[typeof(T)]) | 			for (T c in componentTracker[typeof(T)]) | ||||||
|  | |||||||
| @ -22,6 +22,14 @@ namespace Strawberry | |||||||
| 			Height = height; | 			Height = height; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
|  | 		public this(Point pos, int width, int height) | ||||||
|  | 		{ | ||||||
|  | 			X = pos.X; | ||||||
|  | 			Y = pos.Y; | ||||||
|  | 			Width = width; | ||||||
|  | 			Height = height; | ||||||
|  | 		} | ||||||
|  |  | ||||||
| 		public this(JSON json) | 		public this(JSON json) | ||||||
| 			: this(json["x"], json["y"], json["width"], json["height"]) | 			: this(json["x"], json["y"], json["width"], json["height"]) | ||||||
| 		{ | 		{ | ||||||
|  | |||||||
| @ -146,6 +146,18 @@ namespace Strawberry | |||||||
| 			return .(a.X - b.X, a.Y - b.Y); | 			return .(a.X - b.X, a.Y - b.Y); | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
|  | 		[Inline, Commutable] | ||||||
|  | 		static public Vector operator*(Vector a, int b) | ||||||
|  | 		{ | ||||||
|  | 			return .(a.X * b, a.Y * b); | ||||||
|  | 		} | ||||||
|  |  | ||||||
|  | 		[Inline, Commutable] | ||||||
|  | 		static public Vector operator/(Vector a, int b) | ||||||
|  | 		{ | ||||||
|  | 			return .(a.X / b, a.Y / b); | ||||||
|  | 		} | ||||||
|  |  | ||||||
| 		[Inline, Commutable] | 		[Inline, Commutable] | ||||||
| 		static public Vector operator*(Vector a, float b) | 		static public Vector operator*(Vector a, float b) | ||||||
| 		{ | 		{ | ||||||
| @ -158,6 +170,12 @@ namespace Strawberry | |||||||
| 			return .(a.X / b, a.Y / b); | 			return .(a.X / b, a.Y / b); | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
|  | 		[Inline, Commutable] | ||||||
|  | 		static public Vector operator*(Vector a, Facings f) | ||||||
|  | 		{ | ||||||
|  | 			return .(a.X * (int)f, a.Y); | ||||||
|  | 		} | ||||||
|  |  | ||||||
| 		[Inline] | 		[Inline] | ||||||
| 		static public Vector operator*(Vector a, Mat3x2 b) | 		static public Vector operator*(Vector a, Mat3x2 b) | ||||||
| 		{ | 		{ | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user