Skip to content

Instantly share code, notes, and snippets.

@scottstamp
Last active February 28, 2022 07:25
Show Gist options
  • Save scottstamp/88b6dc37b59899e139d8b58e9bef0a5d to your computer and use it in GitHub Desktop.
Save scottstamp/88b6dc37b59899e139d8b58e9bef0a5d to your computer and use it in GitHub Desktop.
/// @name Roller Queue
/// @group Utility
/// @scripter 1.0.0-beta
OnEntitySlide(x => {
var roller = FloorItems.At(Self.Location.XY).NamedLike("Roller").FirstOrDefault();
if (roller != null) {
switch ((Directions)roller.Direction) {
case Directions.North:
if (x.PreviousTile == Self.Location.Subtract(0, 1))
Move(Self.Location.Subtract(0, 2));
break;
case Directions.East:
if (x.PreviousTile == Self.Location.Add(1, 0))
Move(Self.Location.Add(2, 0));
break;
case Directions.South:
if (x.PreviousTile == Self.Location.Add(0, 1))
Move(Self.Location.Add(0, 2));
break;
case Directions.West:
if (x.PreviousTile == Self.Location.Subtract(1, 0))
Move(Self.Location.Subtract(2, 0));
break;
}
}
});
OnEntityUpdated(x => {
var roller = FloorItems.At(Self.Location.XY).NamedLike("Roller").FirstOrDefault();
if (roller != null) {
switch ((Directions)roller.Direction) {
case Directions.North:
if ((x.Entity.CurrentUpdate.MovingTo ?? default) == Self.Location.Subtract(0, 2))
Move(Self.Location.Subtract(0, 1));
break;
case Directions.East:
if ((x.Entity.CurrentUpdate.MovingTo ?? default) == Self.Location.Add(2, 0))
Move(Self.Location.Add(1, 0));
break;
case Directions.South:
if ((x.Entity.CurrentUpdate.MovingTo ?? default) == Self.Location.Add(0, 2))
Move(Self.Location.Add(0, 1));
break;
case Directions.West:
if ((x.Entity.CurrentUpdate.MovingTo ?? default) == Self.Location.Subtract(2, 0))
Move(Self.Location.Subtract(1, 0));
break;
}
}
});
while (Run) {
var roller = FloorItems.At(Self.Location.XY).NamedLike("Roller").FirstOrDefault();
if (roller != null) {
switch ((Directions)roller.Direction) {
case Directions.North:
if (!Users.Any(x => x.Location == Self.Location.Subtract(0, 1))) {
Move(Self.Location.Subtract(0, 1));
Delay(750);
}
break;
case Directions.East:
if (!Users.Any(x => x.Location == Self.Location.Add(1, 0))) {
Move(Self.Location.Add(1, 0));
Delay(750);
}
break;
case Directions.South:
if (!Users.Any(x => x.Location == Self.Location.Add(0, 1))) {
Move(Self.Location.Add(0, 1));
Delay(750);
}
break;
case Directions.West:
if (!Users.Any(x => x.Location == Self.Location.Subtract(1, 0))) {
Move(Self.Location.Subtract(1, 0));
Delay(750);
}
break;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment