Esempio n. 1
0
        public override void Render()
        {
            if (GameController.OnGodot && onGrid)
            {
                const int ppm          = EyeManager.PIXELSPERMETER;
                var       viewportSize = pManager.sceneTree.SceneTree.Root.Size.Convert();
                var       position     = pManager.eyeManager.ScreenToWorld(Vector2.Zero);
                var       gridstart    = pManager.eyeManager.WorldToScreen(new Vector2( //Find snap grid closest to screen origin and convert back to screen coords
                                                                               (float)(Math.Round(position.X / snapSize - 0.5f, MidpointRounding.AwayFromZero) + 0.5f) * snapSize,
                                                                               (float)(Math.Round(position.Y / snapSize - 0.5f, MidpointRounding.AwayFromZero) + 0.5f) * snapSize));
                var flip = new Godot.Vector2(1, -1);
                for (var a = gridstart.X; a < viewportSize.X; a += snapSize * 32) //Iterate through screen creating gridlines
                {
                    var from = ScreenToWorld(new Vector2(a, 0)).Convert() * ppm * flip;
                    var to   = ScreenToWorld(new Vector2(a, viewportSize.Y)).Convert() * ppm * flip;
                    pManager.DrawNode.DrawLine(from, to, new Godot.Color(0, 0, 1), 0.5f);
                }
                for (var a = gridstart.Y; a < viewportSize.Y; a += snapSize * 32)
                {
                    var from = ScreenToWorld(new Vector2(0, a)).Convert() * ppm * flip;
                    var to   = ScreenToWorld(new Vector2(viewportSize.X, a)).Convert() * ppm * flip;
                    pManager.DrawNode.DrawLine(from, to, new Godot.Color(0, 0, 1), 0.5f);
                }
            }

            // Draw grid BELOW the ghost thing.
            base.Render();
        }
Esempio n. 2
0
        private void GenerationChunk(object obj)
        {
            int threadIndex = int.Parse(Thread.CurrentThread.Name);

            ResetEvents[threadIndex].WaitOne();

            while (true)
            {
                if (QueueGeneration.Count == 0)
                {
                    Console.WriteLine($"Miss in {threadIndex} thread.");
                    IsFree[threadIndex] = true;
                    ResetEvents[threadIndex].WaitOne();
                    continue;
                }
                Godot.Vector2 position = QueueGeneration.Dequeue();

                Stopwatch stopwatch = new Stopwatch();
                stopwatch.Start();

                Chunk chunk = new Chunk(position);
                Generation(chunk);
                chunk.Render();
                Chunks.Enqueue(chunk);

                stopwatch.Stop();

                ChunkReady(threadIndex, stopwatch.ElapsedMilliseconds);

                IsFree[threadIndex] = true;
                ResetEvents[threadIndex].WaitOne();
                IsFree[threadIndex] = false;
            }
        }
Esempio n. 3
0
 private void EmptyEMB(Godot.Vector2 vector)
 {
     ClassOwner.EmptyRMB?.Invoke(vector);
 }
Esempio n. 4
0
 public static Vector2 Convert(this Godot.Vector2 vector2)
 {
     return(new Vector2(vector2.x, vector2.y));
 }
Esempio n. 5
0
 private void RMBClicked(Godot.Vector2 v)
 {
     ClassOwner.RMBClicked?.Invoke(v);
 }
Esempio n. 6
0
 private void ItemRMBSelected(int index, Godot.Vector2 v)
 {
     ClassOwner.ItemRMBSelected?.Invoke(index, v);
 }
Esempio n. 7
0
 private void ResizeRequest(Godot.Vector2 newMinSize)
 {
     ClassOwner.ResizeRequest?.Invoke(newMinSize);
 }
 public static HopperIntVector2 Convert(this GodotVector2 vector)
 => new HopperIntVector2(Maths.Round(vector.x), Maths.Round(vector.y));
Esempio n. 9
0
 private void _ScrollOffsetChanged(Godot.Vector2 v)
 {
     ClassOwner.ScrollOffsetChanged?.Invoke(v);
 }
Esempio n. 10
0
 private void PopupRequest(Godot.Vector2 v)
 {
     ClassOwner.PopupRequest?.Invoke(v);
 }
Esempio n. 11
0
 private void ConnectionToEmpty(string str, int i, Godot.Vector2 v)
 {
     ClassOwner.ConnectionToEmpty?.Invoke(str, i, v);
 }
Esempio n. 12
0
 public void GenerateChunk(Godot.Vector2 position)
 {
     QueueGeneration.Enqueue(position);
 }
Esempio n. 13
0
 protected Vector2(Godot.Vector2 v)
 {
     gVector2 = v;
 }
Esempio n. 14
0
 public Vector2(float x, float y)
 {
     gVector2 = new Godot.Vector2(x, y);
 }
Esempio n. 15
0
 private void EmptyTreeRMBSelected(Godot.Vector2 vector)
 {
     ClassOwner.EmptyTreeRMBSelected?.Invoke(vector);
 }
Esempio n. 16
0
 private void Dragged(Godot.Vector2 from, Godot.Vector2 to)
 {
     ClassOwner.Dragged?.Invoke(from, to);
 }
Esempio n. 17
0
 private void ItemRMBSelected(Godot.Vector2 vector)
 {
     ClassOwner.ItemRMBSelected?.Invoke(vector);
 }
Esempio n. 18
0
 /// <summary>
 /// Converts the given Godot vector, representing the position of an entity in the scene,
 /// to a Hopper vector, representing the position in the logic world.
 /// The vector is rescaled accordingly.
 /// </summary>
 public static HopperIntVector2 ToHopperWorldVector(this GodotVector2 vector)
 => new HopperIntVector2(Maths.Round(vector.x * TileSizeInv), Maths.Round(vector.y * TileSizeInv));