mirror of
				https://github.com/MaddyThorson/StrawberryBF.git
				synced 2025-11-04 01:41:33 +08:00 
			
		
		
		
	Big restructuring - sample game is currently broken
This commit is contained in:
		@ -7,8 +7,8 @@ namespace Strawberry.Sample
 | 
			
		||||
		public this()
 | 
			
		||||
		{
 | 
			
		||||
			Add(new Player(.(50, 50)));
 | 
			
		||||
			Add(new Solid(.(0, 168), .(0, 0, 320, 12)));
 | 
			
		||||
			Add(new JumpThru(.(200, 132), 48));
 | 
			
		||||
			Add(new OldSolid(.(0, 168), .(0, 0, 320, 12)));
 | 
			
		||||
			Add(new OldJumpThru(.(200, 132), 48));
 | 
			
		||||
			Add(new MovingJumpThru(.(136, 100), 32, .(124, 140), 2f));
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@ -1,6 +1,6 @@
 | 
			
		||||
namespace Strawberry.Sample
 | 
			
		||||
{
 | 
			
		||||
	public class MovingJumpThru	: JumpThru
 | 
			
		||||
	public class MovingJumpThru	: OldJumpThru
 | 
			
		||||
	{
 | 
			
		||||
		private Point moveFrom;
 | 
			
		||||
		private Point moveTo;
 | 
			
		||||
 | 
			
		||||
@ -2,56 +2,49 @@ using System;
 | 
			
		||||
 | 
			
		||||
namespace Strawberry.Sample
 | 
			
		||||
{
 | 
			
		||||
	[Reflect]
 | 
			
		||||
	public class Actor : Entity
 | 
			
		||||
	public class Physics : Component, IHasHitbox, IUpdate
 | 
			
		||||
	{
 | 
			
		||||
		public Hitbox Hitbox { get; private set; }
 | 
			
		||||
		public Vector Speed;
 | 
			
		||||
 | 
			
		||||
		private Vector remainder;
 | 
			
		||||
 | 
			
		||||
		// The amount that geometry has pushed or carried this Actor since the last frame
 | 
			
		||||
		public Point MovedByGeometry { get; private set; }
 | 
			
		||||
 | 
			
		||||
		public this(Point position)
 | 
			
		||||
			: base(position)
 | 
			
		||||
		public this(Hitbox hitbox)
 | 
			
		||||
		{
 | 
			
		||||
 | 
			
		||||
			Hitbox = hitbox;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		public Level Level => SceneAs<Level>();
 | 
			
		||||
		public Level Level => Entity.SceneAs<Level>();
 | 
			
		||||
 | 
			
		||||
		public bool Check(Level level)
 | 
			
		||||
		{
 | 
			
		||||
			return level.SolidGrid != null && Check(level.SolidGrid);
 | 
			
		||||
			return level.SolidGrid != null && Hitbox.Check(level.SolidGrid);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		public bool Check(Level level, Point offset)
 | 
			
		||||
		{
 | 
			
		||||
			return level.SolidGrid != null && Check(level.SolidGrid, offset);
 | 
			
		||||
			return level.SolidGrid != null && Hitbox.Check(level.SolidGrid, offset);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		public bool GroundCheck(int distance = 1)
 | 
			
		||||
		{
 | 
			
		||||
			return Check<Solid>(.(0, distance)) || Check(Level, .(0, distance)) || CheckOutside<JumpThru>(.(0, distance));
 | 
			
		||||
			return Hitbox.Check<Solid>(.(0, distance)) || Check(Level, .(0, distance)) || Hitbox.CheckOutside<JumpThru>(.(0, distance));
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		public virtual bool IsRiding(Solid solid)
 | 
			
		||||
		{
 | 
			
		||||
			return Check(solid, .(0, 1));
 | 
			
		||||
			return Hitbox.Check(solid, .(0, 1));
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		public virtual bool IsRiding(JumpThru jumpThru)
 | 
			
		||||
		{
 | 
			
		||||
			return CheckOutside(jumpThru, .(0, 1));
 | 
			
		||||
			return Hitbox.CheckOutside(jumpThru, .(0, 1));
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		public virtual void Squish(Collision collision)
 | 
			
		||||
		public void Update()
 | 
			
		||||
		{
 | 
			
		||||
			RemoveSelf();
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		public override void Update()
 | 
			
		||||
		{
 | 
			
		||||
			base.Update();
 | 
			
		||||
			MovedByGeometry = Point.Zero;
 | 
			
		||||
			MoveX(Speed.X * Time.Delta);
 | 
			
		||||
			MoveY(Speed.Y * Time.Delta);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		public bool MoveX(float amount, delegate void(Collision) onCollide = null)
 | 
			
		||||
@ -83,130 +76,85 @@ namespace Strawberry.Sample
 | 
			
		||||
		[Inline]
 | 
			
		||||
		public void MoveToX(float x)
 | 
			
		||||
		{
 | 
			
		||||
			MoveX(x - (X + remainder.X), null);
 | 
			
		||||
			MoveX(x - (Entity.X + remainder.X), null);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		[Inline]
 | 
			
		||||
		public void MoveToY(float y)
 | 
			
		||||
		{
 | 
			
		||||
			MoveY(y - (Y + remainder.Y), null);
 | 
			
		||||
			MoveY(y - (Entity.Y + remainder.Y), null);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		public bool MoveExactX(int amount, delegate void(Collision) onCollide = null, Geometry pusher = null, Geometry carrier = null)
 | 
			
		||||
		public bool MoveExactX(int amount, delegate void(Collision) onCollide = null)
 | 
			
		||||
		{
 | 
			
		||||
			int move = amount;
 | 
			
		||||
			int sign = Math.Sign(amount);
 | 
			
		||||
			bool byGeometry = carrier != null || pusher != null;
 | 
			
		||||
 | 
			
		||||
			while (move != 0)
 | 
			
		||||
			{
 | 
			
		||||
				let hit = First<Solid>(.(sign, 0));
 | 
			
		||||
				if (hit != null)
 | 
			
		||||
				if (Check(Level, .(sign, 0)) || Hitbox.Check<Solid>(.(sign, 0)))
 | 
			
		||||
				{
 | 
			
		||||
					let c = Collision(
 | 
			
		||||
						Cardinals.FromPoint(Point.Right * sign),
 | 
			
		||||
						Math.Abs(amount),
 | 
			
		||||
						Math.Abs(amount - move),
 | 
			
		||||
						hit,
 | 
			
		||||
						pusher
 | 
			
		||||
						Math.Abs(amount - move)
 | 
			
		||||
					);
 | 
			
		||||
 | 
			
		||||
					onCollide?.Invoke(c);
 | 
			
		||||
					return true;
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				if (Check(Level, .(sign, 0)))
 | 
			
		||||
				{
 | 
			
		||||
					let c = Collision(
 | 
			
		||||
						Cardinals.FromPoint(Point.Right * sign),
 | 
			
		||||
						Math.Abs(amount),
 | 
			
		||||
						Math.Abs(amount - move),
 | 
			
		||||
						null,
 | 
			
		||||
						pusher
 | 
			
		||||
					);
 | 
			
		||||
 | 
			
		||||
					onCollide?.Invoke(c);
 | 
			
		||||
					return true;
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				X += sign;
 | 
			
		||||
				if (byGeometry)
 | 
			
		||||
					MovedByGeometry.X += sign;
 | 
			
		||||
				Entity.X += sign;
 | 
			
		||||
				move -= sign;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			return false;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		public bool MoveExactY(int amount, delegate void(Collision) onCollide = null, Geometry pusher = null, Geometry carrier = null)
 | 
			
		||||
		public bool MoveExactY(int amount, delegate void(Collision) onCollide = null)
 | 
			
		||||
		{
 | 
			
		||||
			int move = amount;
 | 
			
		||||
			int sign = Math.Sign(amount);
 | 
			
		||||
			bool byGeometry = carrier != null || pusher != null;
 | 
			
		||||
 | 
			
		||||
			while (move != 0)
 | 
			
		||||
			{
 | 
			
		||||
				Geometry hit = First<Solid>(.(0, sign));
 | 
			
		||||
				if (hit == null && sign == 1)
 | 
			
		||||
					hit = FirstOutside<JumpThru>(.(0, sign));
 | 
			
		||||
 | 
			
		||||
				if (hit != null)
 | 
			
		||||
				if (Check(Level, .(0, sign)) || Hitbox.Check<Solid>(.(0, sign)) || Hitbox.CheckOutside<JumpThru>(.(0, sign)))
 | 
			
		||||
				{
 | 
			
		||||
					let c = Collision(
 | 
			
		||||
						Cardinals.FromPoint(Point.Down * sign),
 | 
			
		||||
						Math.Abs(amount),
 | 
			
		||||
						Math.Abs(amount - move),
 | 
			
		||||
						hit,
 | 
			
		||||
						pusher
 | 
			
		||||
						Math.Abs(amount - move)
 | 
			
		||||
					);
 | 
			
		||||
 | 
			
		||||
					onCollide?.Invoke(c);
 | 
			
		||||
					return true;
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				if (Check(Level, .(0, sign)))
 | 
			
		||||
				{
 | 
			
		||||
					let c = Collision(
 | 
			
		||||
						Cardinals.FromPoint(Point.Down * sign),
 | 
			
		||||
						Math.Abs(amount),
 | 
			
		||||
						Math.Abs(amount - move),
 | 
			
		||||
						null,
 | 
			
		||||
						pusher
 | 
			
		||||
					);
 | 
			
		||||
 | 
			
		||||
					onCollide?.Invoke(c);
 | 
			
		||||
					return true;
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				Y += sign;
 | 
			
		||||
				if (byGeometry)
 | 
			
		||||
					MovedByGeometry.Y += sign;
 | 
			
		||||
				Entity.Y += sign;
 | 
			
		||||
				move -= sign;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			return false;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		[Inline]
 | 
			
		||||
		public void ZeroRemainderX()
 | 
			
		||||
		{
 | 
			
		||||
			remainder.X = 0;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		[Inline]
 | 
			
		||||
		public void ZeroRemainderY()
 | 
			
		||||
		{
 | 
			
		||||
			remainder.Y = 0;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		[Inline]
 | 
			
		||||
		public void ZeroRemainders()
 | 
			
		||||
		{
 | 
			
		||||
			remainder = Vector.Zero;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		private void MoveByGeometry(Point amount)
 | 
			
		||||
		{
 | 
			
		||||
			MovedByGeometry += amount;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		public bool CornerCorrection(Cardinals direction, int maxAmount, int lookAhead = 1, int onlySign = 0)
 | 
			
		||||
		{
 | 
			
		||||
			Point dir = direction;
 | 
			
		||||
@ -215,10 +163,10 @@ namespace Strawberry.Sample
 | 
			
		||||
			perp.Y = Math.Abs(perp.Y);
 | 
			
		||||
 | 
			
		||||
			delegate bool(Point) checker;
 | 
			
		||||
 			if (dir == Point.Down)
 | 
			
		||||
				checker = scope:: (p) => !Check(Level, p) && !Check<Solid>(p) && !CheckOutside<JumpThru>(p);
 | 
			
		||||
			if (dir == Point.Down)
 | 
			
		||||
				checker = scope:: (p) => !Check(Level, p) && !Hitbox.Check<Solid>(p) && !Hitbox.CheckOutside<JumpThru>(p);
 | 
			
		||||
			else
 | 
			
		||||
				checker = scope:: (p) => !Check(Level, p) && !Check<Solid>(p);
 | 
			
		||||
				checker = scope:: (p) => !Check(Level, p) && !Hitbox.Check<Solid>(p);
 | 
			
		||||
 | 
			
		||||
			for (int i = 1; i <= maxAmount; i++)
 | 
			
		||||
			{
 | 
			
		||||
@ -230,7 +178,7 @@ namespace Strawberry.Sample
 | 
			
		||||
					let offset = dir * lookAhead + perp * i * j;
 | 
			
		||||
					if (checker(offset))
 | 
			
		||||
					{
 | 
			
		||||
						Position += offset;
 | 
			
		||||
						Entity.Position += offset;
 | 
			
		||||
						return true;
 | 
			
		||||
					}	
 | 
			
		||||
				}
 | 
			
		||||
@ -2,7 +2,7 @@ using System;
 | 
			
		||||
 | 
			
		||||
namespace Strawberry.Sample
 | 
			
		||||
{
 | 
			
		||||
	public class Player	: Actor
 | 
			
		||||
	public class Player	: Component, IUpdate
 | 
			
		||||
	{
 | 
			
		||||
		public Vector Speed;
 | 
			
		||||
 | 
			
		||||
@ -18,10 +18,8 @@ namespace Strawberry.Sample
 | 
			
		||||
			Add(tVarJump = new Timer());
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		public override void Update()
 | 
			
		||||
		public void Update()
 | 
			
		||||
		{
 | 
			
		||||
			base.Update();
 | 
			
		||||
 | 
			
		||||
			const float coyoteTime = 0.1f;		// Time after leaving a ledge when you can still jump
 | 
			
		||||
			const float varJumpTime = 0.2f;		// Time after jumping that you can hold the jump button to continue gaining upward speed
 | 
			
		||||
			const float jumpSpeed = -160;
 | 
			
		||||
 | 
			
		||||
@ -6,16 +6,12 @@ namespace Strawberry.Sample
 | 
			
		||||
		public Cardinals Direction;
 | 
			
		||||
		public int Magnitude;
 | 
			
		||||
		public int Completed;
 | 
			
		||||
		public Geometry Stopper;
 | 
			
		||||
		public Geometry Pusher;
 | 
			
		||||
 | 
			
		||||
		public this(Cardinals direction, int magnitude, int completed, Geometry stopper, Geometry pusher)
 | 
			
		||||
		public this(Cardinals direction, int magnitude, int completed)
 | 
			
		||||
		{
 | 
			
		||||
			Direction = direction;
 | 
			
		||||
			Magnitude = magnitude;
 | 
			
		||||
			Completed = completed;
 | 
			
		||||
			Stopper = stopper;
 | 
			
		||||
			Pusher = pusher;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -1,83 +0,0 @@
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections;
 | 
			
		||||
 | 
			
		||||
namespace Strawberry.Sample
 | 
			
		||||
{
 | 
			
		||||
	public abstract class Geometry : Entity
 | 
			
		||||
	{
 | 
			
		||||
		private Vector remainder;
 | 
			
		||||
 | 
			
		||||
		public this(Point position)
 | 
			
		||||
			: base(position)
 | 
			
		||||
		{
 | 
			
		||||
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		public void MoveX(float amount)
 | 
			
		||||
		{
 | 
			
		||||
			remainder.X += amount;
 | 
			
		||||
			let move = (int)Math.Round(remainder.X);
 | 
			
		||||
			if (move != 0)
 | 
			
		||||
			{
 | 
			
		||||
				remainder.X -= move;
 | 
			
		||||
				MoveExactX(move);
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		public void MoveY(float amount)
 | 
			
		||||
		{
 | 
			
		||||
			remainder.Y += amount;
 | 
			
		||||
			let move = (int)Math.Round(remainder.Y);
 | 
			
		||||
			if (move != 0)
 | 
			
		||||
			{
 | 
			
		||||
				remainder.Y -= move;
 | 
			
		||||
				MoveExactY(move);
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		[Inline]
 | 
			
		||||
		public void Move(Vector amount)
 | 
			
		||||
		{
 | 
			
		||||
			MoveX(amount.X);
 | 
			
		||||
			MoveY(amount.Y);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		[Inline]
 | 
			
		||||
		public void MoveToX(float x)
 | 
			
		||||
		{
 | 
			
		||||
			MoveX(x - (X + remainder.X));
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		[Inline]
 | 
			
		||||
		public void MoveToY(float y)
 | 
			
		||||
		{
 | 
			
		||||
			MoveY(y - (Y + remainder.Y));
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		[Inline]
 | 
			
		||||
		public void MoveTo(Vector target)
 | 
			
		||||
		{
 | 
			
		||||
			MoveToX(target.X);
 | 
			
		||||
			MoveToY(target.Y);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		public abstract void MoveExactX(int amount);
 | 
			
		||||
		public abstract void MoveExactY(int amount);
 | 
			
		||||
		public abstract List<Actor> GetRiders(List<Actor> into);
 | 
			
		||||
 | 
			
		||||
		public void ZeroRemainderX()
 | 
			
		||||
		{
 | 
			
		||||
			remainder.X = 0;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		public void ZeroRemainderY()
 | 
			
		||||
		{
 | 
			
		||||
			remainder.Y = 0;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		public void ZeroRemainders()
 | 
			
		||||
		{
 | 
			
		||||
			remainder = Vector.Zero;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
@ -1,80 +1,14 @@
 | 
			
		||||
using System.Collections;
 | 
			
		||||
using System;
 | 
			
		||||
 | 
			
		||||
namespace Strawberry.Sample
 | 
			
		||||
{
 | 
			
		||||
	public class JumpThru : Geometry
 | 
			
		||||
	public class JumpThru : Component, IHasHitbox
 | 
			
		||||
	{
 | 
			
		||||
		public this(Point position, int width)
 | 
			
		||||
			: base(position)
 | 
			
		||||
		public Hitbox Hitbox { get; private set; }
 | 
			
		||||
 | 
			
		||||
		public this(Hitbox hitbox)
 | 
			
		||||
		{
 | 
			
		||||
			Hitbox = Rect(0, 0, width, 2);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		public this(JSON json)
 | 
			
		||||
			: this(.(json), json["width"])
 | 
			
		||||
		{
 | 
			
		||||
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		public override void MoveExactX(int amount)
 | 
			
		||||
		{
 | 
			
		||||
			if (Collidable)
 | 
			
		||||
			{
 | 
			
		||||
				let riders = GetRiders(scope List<Actor>());
 | 
			
		||||
	
 | 
			
		||||
				X += amount;
 | 
			
		||||
				for (var a in riders)
 | 
			
		||||
					a.MoveExactX(amount, null, null, this);
 | 
			
		||||
			}
 | 
			
		||||
			else
 | 
			
		||||
				X += amount;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		public override void MoveExactY(int amount)
 | 
			
		||||
		{
 | 
			
		||||
			if (Collidable)
 | 
			
		||||
			{
 | 
			
		||||
				let riders = GetRiders(scope List<Actor>());
 | 
			
		||||
 | 
			
		||||
				if (amount < 0)
 | 
			
		||||
				{
 | 
			
		||||
					for (var a in Scene.All<Actor>(scope List<Actor>()))
 | 
			
		||||
					{
 | 
			
		||||
						if (riders.Contains(a) || CheckOutside(a, Point.UnitY * amount))
 | 
			
		||||
						{
 | 
			
		||||
							let move = (Top + amount) - a.Bottom;
 | 
			
		||||
							a.MoveExactY(move, null, null, this);
 | 
			
		||||
						}
 | 
			
		||||
					}
 | 
			
		||||
					Y += amount;
 | 
			
		||||
				}
 | 
			
		||||
				else
 | 
			
		||||
				{
 | 
			
		||||
					Collidable = false;
 | 
			
		||||
 | 
			
		||||
					for (var a in riders)
 | 
			
		||||
						a.MoveExactY(amount, null, null, this);
 | 
			
		||||
 | 
			
		||||
					Collidable = true;
 | 
			
		||||
					Y += amount;
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			else
 | 
			
		||||
				Y += amount;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		public override List<Actor> GetRiders(List<Actor> into)
 | 
			
		||||
		{
 | 
			
		||||
			for (var a in Scene.All<Actor>(scope List<Actor>()))
 | 
			
		||||
				if (a.IsRiding(this))
 | 
			
		||||
					into.Add(a);
 | 
			
		||||
			return into;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		public override void Draw()
 | 
			
		||||
		{
 | 
			
		||||
			DrawHitbox(.LightGray);
 | 
			
		||||
			Hitbox = hitbox;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -2,93 +2,13 @@ using System.Collections;
 | 
			
		||||
 | 
			
		||||
namespace Strawberry.Sample
 | 
			
		||||
{
 | 
			
		||||
	public class Solid : Geometry
 | 
			
		||||
	public class Solid : Component, IHasHitbox
 | 
			
		||||
	{
 | 
			
		||||
		public this(Point position, Rect hitbox)
 | 
			
		||||
			: base(position)
 | 
			
		||||
		public Hitbox Hitbox { get; private set; }
 | 
			
		||||
 | 
			
		||||
		public this(Hitbox hitbox)
 | 
			
		||||
		{
 | 
			
		||||
			Hitbox = hitbox;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		public override List<Actor> GetRiders(List<Actor> into)
 | 
			
		||||
		{
 | 
			
		||||
			for (var a in Scene.All<Actor>(scope List<Actor>()))
 | 
			
		||||
				if (a.IsRiding(this))
 | 
			
		||||
					into.Add(a);
 | 
			
		||||
			return into;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		public override void MoveExactX(int amount)
 | 
			
		||||
		{
 | 
			
		||||
			if (Collidable)
 | 
			
		||||
			{
 | 
			
		||||
				let riders = GetRiders(scope List<Actor>());
 | 
			
		||||
 | 
			
		||||
				X += amount;
 | 
			
		||||
				Collidable = false;
 | 
			
		||||
 | 
			
		||||
				for (Actor a in Scene.All<Actor>(scope List<Actor>()))
 | 
			
		||||
				{
 | 
			
		||||
					if (Check(a))
 | 
			
		||||
					{
 | 
			
		||||
						//Push
 | 
			
		||||
						int move;
 | 
			
		||||
						if (amount > 0)
 | 
			
		||||
							move = Right - a.Left;
 | 
			
		||||
						else
 | 
			
		||||
							move = Left - a.Right;
 | 
			
		||||
						a.MoveExactX(move, scope => a.Squish, this);
 | 
			
		||||
					}
 | 
			
		||||
					else if (riders.Contains(a))
 | 
			
		||||
					{
 | 
			
		||||
						//Carry
 | 
			
		||||
						a.MoveExactX(amount, null, null, this);
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				Collidable = true;
 | 
			
		||||
			}
 | 
			
		||||
			else
 | 
			
		||||
				X += amount;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		public override void MoveExactY(int amount)
 | 
			
		||||
		{
 | 
			
		||||
			if (Collidable)
 | 
			
		||||
			{
 | 
			
		||||
				let riders = GetRiders(scope List<Actor>());
 | 
			
		||||
 | 
			
		||||
				Y += amount;
 | 
			
		||||
				Collidable = false;
 | 
			
		||||
 | 
			
		||||
				for (Actor a in Scene.All<Actor>(scope List<Actor>()))
 | 
			
		||||
				{
 | 
			
		||||
					if (Check(a))
 | 
			
		||||
					{
 | 
			
		||||
						//Push
 | 
			
		||||
						int move;
 | 
			
		||||
						if (amount > 0)
 | 
			
		||||
							move = Bottom - a.Top;
 | 
			
		||||
						else
 | 
			
		||||
							move = Top - a.Bottom;
 | 
			
		||||
						a.MoveExactY(move, scope => a.Squish, this);
 | 
			
		||||
					}
 | 
			
		||||
					else if (riders.Contains(a))
 | 
			
		||||
					{
 | 
			
		||||
						//Carry
 | 
			
		||||
						a.MoveExactY(amount, null, null, this);
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				Collidable = true;
 | 
			
		||||
			}
 | 
			
		||||
			else
 | 
			
		||||
				Y += amount;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		public override void Draw()
 | 
			
		||||
		{
 | 
			
		||||
			DrawHitbox(.White);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user