using System; using System.Collections.Generic; using System.Linq; using System.Text; using SnowLight.Game.Sessions; using SnowLight.Game.Rooms; using SnowLight.Communication.Outgoing; using SnowLight.Specialized; namespace SnowLight.Game.Items.DefaultBehaviorHandlers { public static class RollerHandler { public static void Register() { ItemEventDispatcher.RegisterEventHandler(ItemBehavior.Roller, new ItemEventHandler(HandleRoller)); } private static bool HandleRoller(Session Session, Item Item, RoomInstance Instance, ItemEventType Event, int RequestData) { switch (Event) { case ItemEventType.UpdateTick: List ActorsToMove = Instance.GetActorsOnPosition(Item.RoomPosition.GetVector2()); List ItemsToMove = new List(); if (ActorsToMove != null) { foreach (RoomActor Actor in ActorsToMove) { if (Actor.IsMoving) { continue; } if (Instance.IsValidStep(Actor.Position.GetVector2(), Item.SquareInFront, true)) { Actor.PositionToSet = Item.SquareInFront; Instance.BroadcastMessage(RollerEventComposer.Compose(Actor.Position, new Vector3( Actor.PositionToSet.X, Actor.PositionToSet.Y, Instance.GetUserStepHeight(Actor.PositionToSet)), Item.Id, Actor.Id, 0)); } } } goto case ItemEventType.InstanceLoaded; case ItemEventType.InstanceLoaded: case ItemEventType.Placed: Item.RequestUpdate(4); break; } return true; } } }