예제 #1
0
        private void OnTick(object sender, EventArgs args)
        {
            // Remove old overflows
            if (OverflowDictionary.Count > 0)
            {
                foreach (var entry in OverflowDictionary.ToArray().Where(entry => Environment.TickCount - entry.Value > 5000))
                {
                    OverflowDictionary.Remove(entry.Key);
                }
            }

            if (ModAPI.Input.GetButton("InstantBuild"))
            {
                var ray = Camera.main.ScreenPointToRay(new Vector3(Screen.width / 2f, Screen.height / 2f, 0f));
                ray.origin += Camera.main.transform.forward * 1f;
                var raycastHits = Physics.RaycastAll(ray, 100f);
                if (raycastHits.Length > 0)
                {
                    foreach (var structure in raycastHits.Select(raycastHit => raycastHit.collider.GetComponent <Craft_Structure>()).Where(structure => structure != null))
                    {
                        AddBlueprintToQueue(structure);
                    }
                }
            }

            if (CurrentQueue.Count > 0 && Environment.TickCount - _lastAction > 1f / ActionsPerSecond * 1000)
            {
                _lastAction = Environment.TickCount;
                InstantlyFinishBlueprint(CurrentQueue[0]);
                CurrentQueue.RemoveAt(0);
            }
        }
예제 #2
0
        internal void RemoveFromQueue(int p_Index)
        {
            lock (CurrentQueue)
            {
                if (p_Index < 0 || p_Index >= CurrentQueue.Count)
                {
                    return;
                }

                CurrentQueue.RemoveAt(p_Index);
            }
        }
예제 #3
0
        internal void RemoveSongFromQueue(Int64 p_QueueID)
        {
            lock (CurrentQueue)
            {
                var s_SongIndex = CurrentQueue.FindIndex(p_Item => p_Item.QueueID == p_QueueID);

                if (s_SongIndex == -1)
                {
                    return;
                }

                CurrentQueue.RemoveAt(s_SongIndex);
            }
        }
예제 #4
0
        internal void MoveSong(Int64 p_QueueID, int p_Index)
        {
            lock (CurrentQueue)
            {
                var s_SongIndex = CurrentQueue.FindIndex(p_Item => p_Item.QueueID == p_QueueID);

                if (s_SongIndex == -1)
                {
                    return;
                }

                var s_SongData = CurrentQueue[s_SongIndex];
                CurrentQueue.RemoveAt(s_SongIndex);

                AddToQueue(s_SongData, p_Index);
            }
        }