private static bool HandleFixedGateSwitch(Session Session, Item Item, RoomInstance Instance, ItemEventType Event, int RequestData, uint Opcode) { switch (Event) { case ItemEventType.Interact: if (!Instance.CheckUserRights(Session)) { return true; } List<Vector2> GateTiles = Instance.CalculateAffectedTiles(Item, Item.RoomPosition.GetVector2(), Item.RoomRotation); foreach (Vector2 Tile in GateTiles) { if (Instance.GetActorsOnPosition(Tile).Count > 0) { return true; } } int CurrentState = 0; int.TryParse(Item.Flags, out CurrentState); Item.Flags = (CurrentState == 0 ? 1 : 0).ToString(); Item.DisplayFlags = Item.Flags; RoomManager.MarkWriteback(Item, true); Item.BroadcastStateUpdate(Instance); Instance.RegenerateRelativeHeightmap(); break; } return true; }
private static bool HandleRoller(Session Session, Item Item, RoomInstance Instance, ItemEventType Event, int RequestData, uint Opcode) { switch (Event) { case ItemEventType.UpdateTick: List<RoomActor> ActorsToMove = Instance.GetActorsOnPosition(Item.RoomPosition.GetVector2()); List<Item> ItemsToMove = new List<Item>(); List<Item> ItemsToUpdate = new List<Item>(); ItemsToMove.AddRange(Instance.GetItemsOnPosition(Item.RoomPosition.GetVector2())); 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)); } } } if (ItemsToMove.Count != 0) { foreach (Item item in ItemsToMove) { if (item != Item) { if (Item.RoomPosition.X == item.RoomPosition.X && Item.RoomPosition.Y == item.RoomPosition.Y) { Vector3 NewPosition = new Vector3(Item.SquareInFront.X, Item.SquareInFront.Y, Item.RoomPosition.Z); Vector2 NewPosition1 = new Vector2(Item.SquareInFront.X, Item.SquareInFront.Y); int NewRotation = item.RoomRotation; Vector3 FinalizedPosition = Instance.SetRollerFloorItem(Session, item, NewPosition1, NewRotation, Instance); Vector3 oldpos = item.RoomPosition; if (FinalizedPosition != null) { Instance.BroadcastMessage(RollerEventComposer.Compose(oldpos, FinalizedPosition, Item.Id, 0, item.Id)); ItemEventDispatcher.InvokeItemEventHandler(Session, item, Instance, ItemEventType.Moved, 0); RoomManager.MarkWriteback(item, false); item.MoveToRoom(null, Instance.RoomId, FinalizedPosition, NewRotation, string.Empty); } } } } } System.Threading.Thread.Sleep(1000); Instance.RegenerateRelativeHeightmap(); goto case ItemEventType.InstanceLoaded; case ItemEventType.InstanceLoaded: case ItemEventType.Placed: Item.RequestUpdate(18); break; } return true; }
private static bool HandleStepSwitch(Session Session, Item Item, RoomInstance Instance, ItemEventType Event, int RequestData, uint Opcode) { switch (Event) { case ItemEventType.InstanceLoaded: case ItemEventType.Moved: case ItemEventType.Placed: Item.RequestUpdate(1); break; case ItemEventType.UpdateTick: string Flags = "0"; if (Instance.GetActorsOnPosition(Item.RoomPosition.GetVector2()).Count > 0) { Flags = "1"; } if (Item.DisplayFlags != Flags) { Item.DisplayFlags = Flags; Item.BroadcastStateUpdate(Instance); } Item.RequestUpdate(1); break; } return true; }