public bool OnCycle()
        {
            if (this.SetItems.Count == 0 || !Requested)
            {
                return(false);
            }

            long Now = QuasarEnvironment.Now();

            if (_next < Now)
            {
                foreach (Item Item in this.SetItems.Values.ToList())
                {
                    if (Item == null)
                    {
                        continue;
                    }

                    if (!Instance.GetRoomItemHandler().GetFloor.Contains(Item))
                    {
                        Item n = null;
                        SetItems.TryRemove(Item.Id, out n);
                        continue;
                    }

                    Item.Interactor.OnWiredTrigger(Item);
                }

                Requested = false;

                this._next     = 0;
                this.TickCount = Delay;
            }
            return(true);
        }
        public bool Execute(params object[] Params)
        {
            if (this._next == 0 || this._next < QuasarEnvironment.Now())
            {
                this._next = QuasarEnvironment.Now() + this.Delay;
            }


            this.Requested = true;
            this.TickCount = Delay;
            return(true);
        }
Пример #3
0
        public bool Execute(params object[] Params)
        {
            if (this.SetItems.Count == 0)
            {
                return(false);
            }

            if (this._next == 0 || this._next < QuasarEnvironment.Now())
            {
                this._next = QuasarEnvironment.Now() + this.Delay;
            }

            if (!Requested)
            {
                this.TickCount = this.Delay;
                this.Requested = true;
            }
            return(true);
        }
Пример #4
0
        public bool OnCycle()
        {
            if (Instance == null || !Requested || _next == 0)
            {
                return(false);
            }

            long Now = QuasarEnvironment.Now();

            if (_next < Now)
            {
                foreach (Item Item in this.SetItems.Values.ToList())
                {
                    if (Item == null)
                    {
                        continue;
                    }

                    if (!Instance.GetRoomItemHandler().GetFloor.Contains(Item))
                    {
                        continue;
                    }

                    Item toRemove = null;

                    if (Instance.GetWired().OtherBoxHasItem(this, Item.Id))
                    {
                        this.SetItems.TryRemove(Item.Id, out toRemove);
                    }

                    Point Point = Instance.GetGameMap().GetChaseMovement(Item);

                    Instance.GetWired().onUserFurniCollision(Instance, Item);

                    if (!Instance.GetGameMap().ItemCanMove(Item, Point))
                    {
                        continue;
                    }

                    if (Instance.GetGameMap().CanRollItemHere(Point.X, Point.Y) && !Instance.GetGameMap().SquareHasUsers(Point.X, Point.Y))
                    {
                        Double  NewZ        = Item.GetZ;
                        Boolean CanBePlaced = true;

                        List <Item> Items = Instance.GetGameMap().GetCoordinatedItems(Point);
                        foreach (Item IItem in Items.ToList())
                        {
                            if (IItem == null || IItem.Id == Item.Id)
                            {
                                continue;
                            }

                            if (!IItem.GetBaseItem().Walkable)
                            {
                                _next       = 0;
                                CanBePlaced = false;
                                break;
                            }

                            if (IItem.TotalHeight > NewZ)
                            {
                                NewZ = IItem.TotalHeight;
                            }

                            if (CanBePlaced == true && !IItem.GetBaseItem().Stackable)
                            {
                                CanBePlaced = false;
                            }
                        }

                        if (CanBePlaced && Point != Item.Coordinate)
                        {
                            Instance.SendMessage(new SlideObjectBundleComposer(Item.GetX, Item.GetY, Item.GetZ, Point.X,
                                                                               Point.Y, NewZ, 0, 0, Item.Id));
                            Instance.GetRoomItemHandler().SetFloorItem(Item, Point.X, Point.Y, NewZ);
                        }
                    }
                }

                _next = 0;
                return(true);
            }
            return(false);
        }