private static bool HandleFixedSwitchSwitch(Session Session, Item Item, RoomInstance Instance, ItemEventType Event, int RequestData, uint Opcode) { switch (Event) { case ItemEventType.Interact: if (!Instance.CheckUserRights(Session)) { break; } List<Vector2> SwitchTiles = Instance.CalculateAffectedTiles(Item, Item.RoomPosition.GetVector2(), Item.RoomRotation); RoomActor Actor = Instance.GetActorByReferenceId(Session.CharacterId); foreach (uint RefId in Item.TemporaryInteractionReferenceIds.Values) { RoomActor InteractingActor = Instance.GetActor(RefId); } int CurrentState = 0; int.TryParse(Item.Flags, out CurrentState); if (CurrentState >= (Item.Definition.BehaviorData - 1)) { CurrentState = 0; Item.Flags = CurrentState.ToString(); Item.DisplayFlags = CurrentState.ToString(); } else { int NewState = CurrentState + 1; Item.Flags = NewState.ToString(); Item.DisplayFlags = NewState.ToString(); } RoomManager.MarkWriteback(Item, true); Item.BroadcastStateUpdate(Instance); Instance.WiredManager.HandleToggleState(Actor, Item); Instance.RegenerateRelativeHeightmap(); break; } return true; }
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; }