示例#1
0
        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);
        }
示例#2
0
        private static bool HandleRoller(Session Session, Item Item, RoomInstance Instance, ItemEventType Event, int RequestData)
        {
            switch (Event)
            {
            case ItemEventType.UpdateTick:

                List <RoomActor> ActorsToMove = Instance.GetActorsOnPosition(Item.RoomPosition.GetVector2());
                List <Item>      ItemsToMove  = new List <Item>();

                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);
        }
示例#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);
        }
示例#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>();
                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)
                        {
                            continue;
                        }

                        if (Item.RoomPosition.X == item.RoomPosition.X && Item.RoomPosition.Y == item.RoomPosition.Y)
                        {
                            Vector2 NewPosition       = new Vector2(Item.SquareInFront.X, Item.SquareInFront.Y);
                            int     NewRotation       = item.RoomRotation;
                            Vector3 FinalizedPosition = Instance.SetFloorItem(Session, item, NewPosition, NewRotation);
                            Vector3 oldpos            = item.RoomPosition;

                            if (FinalizedPosition != null)
                            {
                                item.MoveToRoom(null, Instance.RoomId, FinalizedPosition, NewRotation, string.Empty);
                                RoomManager.MarkWriteback(item, false);

                                Instance.RegenerateRelativeHeightmap();
                                Instance.BroadcastMessage(RoomItemUpdatedComposer.Compose(item));

                                ItemEventDispatcher.InvokeItemEventHandler(Session, item, Instance, ItemEventType.Moved, 0);
                                Instance.BroadcastMessage(RollerEventComposer.Compose(oldpos, FinalizedPosition, Item.Id, 0, item.Id));
                            }
                        }
                    }
                }


                goto case ItemEventType.InstanceLoaded;

            case ItemEventType.InstanceLoaded:
            case ItemEventType.Placed:

                Item.RequestUpdate(4);
                break;
            }

            return(true);
        }