Ejemplo n.º 1
0
        private static bool HandleExchangeRedemption(Session Session, Item Item, RoomInstance Instance, ItemEventType Event, int RequestData, uint Opcode)
        {
            switch (Event)
            {
                case ItemEventType.Interact:

                    int ItemValue = 0;
                    int.TryParse(Item.Flags, out ItemValue);

                    using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient())
                    {
                        if (ItemValue != 0)
                        {
                            Session.CharacterInfo.UpdateCreditsBalance(MySqlClient, ItemValue);
                            Session.SendData(CreditsBalanceComposer.Compose(Session.CharacterInfo.CreditsBalance));
                        }

                        Item.RemovePermanently(MySqlClient);
                    }

                    Instance.TakeItem(Item.Id);
                    Instance.RegenerateRelativeHeightmap();
                    break;
            }

            return true;
        }
Ejemplo n.º 2
0
        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;
        }
Ejemplo n.º 3
0
        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;
        }
Ejemplo n.º 4
0
        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;
        }
Ejemplo n.º 5
0
        private static bool HandleRental(Session Session, Item Item, RoomInstance Instance, ItemEventType Event, int RequestData, uint Opcode)
        {
            switch (Event)
            {
                case ItemEventType.Placed:
                case ItemEventType.InstanceLoaded:

                    if (Item.PendingExpiration)
                    {
                        int DesiredTicks = (int)((double)(Math.Ceiling(Item.ExpireTimeLeft * 2)));

                        if (DesiredTicks <= 0)
                        {
                            goto case ItemEventType.UpdateTick;
                        }

                        Item.RequestUpdate(DesiredTicks);
                        return true;
                    }

                    break;

                case ItemEventType.UpdateTick:

                    if (Item.PendingExpiration)
                    {
                        using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient())
                        {
                            Item.RemovePermanently(MySqlClient);
                            Instance.TakeItem(Item.Id);
                            Instance.RegenerateRelativeHeightmap();
                        }

                        return true;
                    }

                    break;
            }

            return HandleGenericSwitch(Session, Item, Instance, Event, RequestData, 0);
        }