mirror of
				https://github.com/MaddyThorson/StrawberryBF.git
				synced 2025-11-04 01:41:33 +08:00 
			
		
		
		
	Facings enum. StateMachine fixes
This commit is contained in:
		@ -78,7 +78,7 @@ namespace Strawberry
 | 
			
		||||
		private bool CallEnter()
 | 
			
		||||
		{
 | 
			
		||||
			let s = states[state];
 | 
			
		||||
			if (s != null)
 | 
			
		||||
			if (s != null && s.Enter != null)
 | 
			
		||||
			{
 | 
			
		||||
				inStateCall = true;
 | 
			
		||||
				let set = s.Enter();
 | 
			
		||||
@ -92,7 +92,7 @@ namespace Strawberry
 | 
			
		||||
		private bool CallUpdate()
 | 
			
		||||
		{
 | 
			
		||||
			let s = states[state];
 | 
			
		||||
			if (s != null)
 | 
			
		||||
			if (s != null && s.Update != null)
 | 
			
		||||
			{
 | 
			
		||||
				inStateCall = true;
 | 
			
		||||
				let set = s.Update();
 | 
			
		||||
@ -106,7 +106,7 @@ namespace Strawberry
 | 
			
		||||
		private bool CallExit()
 | 
			
		||||
		{
 | 
			
		||||
			let s = states[state];
 | 
			
		||||
			if (s != null)
 | 
			
		||||
			if (s != null && s.Exit != null)
 | 
			
		||||
			{
 | 
			
		||||
				inStateCall = true;
 | 
			
		||||
				let set = s.Exit();
 | 
			
		||||
 | 
			
		||||
@ -9,6 +9,44 @@ namespace Strawberry
 | 
			
		||||
		case Left;
 | 
			
		||||
		case Up;
 | 
			
		||||
 | 
			
		||||
		public int X
 | 
			
		||||
		{
 | 
			
		||||
			get
 | 
			
		||||
			{
 | 
			
		||||
				switch (this)
 | 
			
		||||
				{
 | 
			
		||||
				case .Left:
 | 
			
		||||
					return -1;
 | 
			
		||||
				case .Right:
 | 
			
		||||
					return 1;
 | 
			
		||||
				case .Up:
 | 
			
		||||
				case .Down:
 | 
			
		||||
				default:
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				return 0;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		public int Y
 | 
			
		||||
		{
 | 
			
		||||
			get
 | 
			
		||||
			{
 | 
			
		||||
				switch (this)
 | 
			
		||||
				{
 | 
			
		||||
				case .Up:
 | 
			
		||||
					return -1;
 | 
			
		||||
				case .Down:
 | 
			
		||||
					return 1;
 | 
			
		||||
				case .Left:
 | 
			
		||||
				case .Right:
 | 
			
		||||
				default:
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				return 0;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		public Cardinals Opposite()
 | 
			
		||||
		{
 | 
			
		||||
			switch (this)
 | 
			
		||||
@ -54,6 +92,14 @@ namespace Strawberry
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		static public implicit operator Cardinals(Facings f)
 | 
			
		||||
		{
 | 
			
		||||
			if (f == Facings.Right)
 | 
			
		||||
				return Cardinals.Right;
 | 
			
		||||
			else
 | 
			
		||||
				return Cardinals.Left;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		static public implicit operator Point(Cardinals c)
 | 
			
		||||
		{
 | 
			
		||||
			switch (c)
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										32
									
								
								src/Struct/Facings.bf
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								src/Struct/Facings.bf
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,32 @@
 | 
			
		||||
namespace Strawberry
 | 
			
		||||
{
 | 
			
		||||
	public enum Facings
 | 
			
		||||
	{
 | 
			
		||||
		case Right = 1;
 | 
			
		||||
		case Left = -1;
 | 
			
		||||
 | 
			
		||||
		public Facings Opposite()
 | 
			
		||||
		{
 | 
			
		||||
			if (this == .Right)
 | 
			
		||||
				return .Left;
 | 
			
		||||
			else
 | 
			
		||||
				return .Right;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		static public Facings FromInt(int i, Facings ifZero = .Right)
 | 
			
		||||
		{
 | 
			
		||||
			if (i == 0)
 | 
			
		||||
				return ifZero;
 | 
			
		||||
			else
 | 
			
		||||
				return i;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		static public implicit operator Facings(int i)
 | 
			
		||||
		{
 | 
			
		||||
			if (i < 0)
 | 
			
		||||
				return .Left;
 | 
			
		||||
			else
 | 
			
		||||
				return .Right;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user