Esempio n. 1
0
        public void NativeString512EqualsWorks(String a, String b)
        {
            NativeString512 aa = new NativeString512(a);
            NativeString512 bb = new NativeString512(b);

            Assert.AreEqual(aa.Equals(bb), a.Equals(b));
        }
Esempio n. 2
0
        public void NativeString512CompareToWorks(String a, String b)
        {
            NativeString512 aa = new NativeString512(a);
            NativeString512 bb = new NativeString512(b);

            Assert.AreEqual(aa.CompareTo(bb), a.CompareTo(b));
        }
    void Update()
    {
        if (!Application.isPlaying && !DrawInEditMode)
        {
            return;
        }

        if (_isTransitioningMode)
        {
            return;
        }

        if (Start == null || End == null)
        {
            return;
        }

        var text = new NativeString512("MyText");

        if (UseBurstJob)
        {
            new NativeDrawJob
            {
                Start      = Start.transform.position,
                End        = End.transform.position,
                Text       = text,
                Methods    = DrawMethods,
                Polyhedron = Hexagon
            }.Run();
        }
        else
        {
            ManagedDraw(Start.transform.position, End.transform.position, text, DrawMethods);
        }
    }
Esempio n. 4
0
    public void SendChatAnnouncement(CharBufView message)
    {
        var time    = (Game.Clock.ElapsedMilliseconds - m_StartTime) / 1000;
        var minutes = (int)time / 60;
        var seconds = (int)time % 60;

        var formatted_length = StringFormatter.Write(ref _buf, 0, "<color=#ffffffff>[{0}:{1:00}]</color><color=#ffa500ff> {2}</color>", minutes, seconds, message);

        unsafe
        {
            fixed(char *ptr = message.buf)
            {
                GameDebug.Assert(message.length <= NativeString512.MaxLength);
                var msg = new NativeString512();

                msg.CopyFrom(ptr, (ushort)message.length);

                var connectionEntities = m_ConnectionQuery.ToEntityArray(Allocator.TempJob);

                for (int i = 0; i < connectionEntities.Length; ++i)
                {
                    var connectionEntity = connectionEntities[i];
                    m_RpcChatQueue.Schedule(EntityManager.GetBuffer <OutgoingRpcDataStreamBufferComponent>(connectionEntity), new RpcChatMessage {
                        Message = msg
                    });
                }

                connectionEntities.Dispose();
            }
        }
    }
Esempio n. 5
0
        public void NativeString512ToNativeString4096Works(String a)
        {
            var    b = new NativeString512(a);
            var    c = new NativeString4096(ref b);
            String d = c.ToString();

            Assert.AreEqual(a, d);
        }
Esempio n. 6
0
        public void Log(LogLevel level, NativeString512 str)
        {
            if ((int)level > (int)m_Level)
            {
                return;
            }
            var msg = new LogMessage {
                level = level, msg = str
            };

            m_PendingLog.Enqueue(msg);
        }
Esempio n. 7
0
    void Update()
    {
        if (!Application.isPlaying && !DrawInEditMode)
        {
            return;
        }

        if (NativeDebugSharedData.State.IsTransitioning)
        {
            return;
        }

        if (Start == null || End == null)
        {
            return;
        }

        var text = new NativeString512("MyText");

        RefreshSceneViewOnJobTypeChanged();

        if (UseBurstJob)
        {
            _jobHandle.Complete();

            if (MultiThreaded)
            {
                _jobHandle = new DrawTestingParallelJob
                {
                    Start      = Start.transform.position,
                    End        = End.transform.position,
                    Text       = text,
                    Methods    = DrawOptions,
                    Polyhedron = Hexagon
                }.Schedule(10, 1, _jobHandle);
            }
            else
            {
                _jobHandle = new DrawTestingJob
                {
                    Start      = Start.transform.position,
                    End        = End.transform.position,
                    Text       = text,
                    Methods    = DrawOptions,
                    Polyhedron = Hexagon
                }.Schedule(_jobHandle);
            }
        }
        else
        {
            ManagedDraw(Start.transform.position, End.transform.position, text, DrawOptions);
        }
    }
    private static void ManagedDraw(Vector3 start, Vector3 end, NativeString512 text, DrawingMethods methods)
    {
        //Parallel.For(0, 100, (i, state) =>
        //{
        //    try
        //    {
        //        DrawTests(Thread.CurrentThread.ManagedThreadId, start, end, text, methods, Hexagon);
        //    }
        //    catch (Exception ex)
        //    {
        //        Debug.LogError($"Exception i={i} state={state}: {ex}");
        //    }
        //});

        DrawTests(Thread.CurrentThread.ManagedThreadId, start, end, text, methods, Hexagon);
    }
Esempio n. 9
0
 private void ManagedDraw(Vector3 start, Vector3 end, NativeString512 text, DebugTestDrawOptions methods)
 {
     if (MultiThreaded)
     {
         for (int i = 0; i < 10; i++)
         {
             Task.Run(() =>
             {
                 DrawTests(Thread.CurrentThread.ManagedThreadId, start, end, text, methods, Hexagon);
             });
         }
     }
     else
     {
         DrawTests(Thread.CurrentThread.ManagedThreadId, start, end, text, methods, Hexagon);
     }
 }
Esempio n. 10
0
        public void NativeString512ToStringWorks(String a)
        {
            NativeString512 aa = new NativeString512(a);

            Assert.AreEqual(aa.ToString(), a);
        }
Esempio n. 11
0
    private static unsafe void DrawTests(int threadIndex, float3 start, float3 end, NativeString512 text, DrawingMethods methods, NativeArray <float3> polygon)
    {
        float3 offset = Vector3.up * 0.05f + Vector3.left * 0.05f;
        float3 center = (start + (end - start) / 2);

        if (methods.Sphere)
        {
            DebugDrawer.DrawSphere(start, 0.75f, UnityColors.GhostDodgerBlue);
        }

        if (methods.RectangleWithOutline)
        {
            var size   = 0.25f;
            var points = stackalloc[]
            {
                center + offset + new float3(0, 0, 0),
                center + offset + new float3(0, size, 0),
                center + offset + new float3(0, size, size),
                center + offset + new float3(0, 0, size)
            };

            DebugDrawer.DrawSolidRectangleWithOutline(points, UnityColors.LightYellow, UnityColors.Yellow);
        }

        if (methods.Polygon)
        {
            DebugDrawer.DrawAAConvexPolygon(polygon, center + (float3)Vector3.down * 0.25f, UnityColors.GhostDodgerBlue);
        }

        if (methods.Line)
        {
            DebugDrawer.DrawLine(start + offset, end + offset);
        }

        if (methods.Ray)
        {
            DebugDrawer.DrawRay(center, Vector3.up, UnityColors.MediumBlue);
        }

        if (methods.Cone)
        {
            DebugDrawer.DrawCone(center + (float3)Vector3.up * 0.5f, Vector3.up, UnityColors.DarkKhaki, 22.5f);
        }

        if (methods.Circle)
        {
            DebugDrawer.DrawCircle(center, Vector3.up, 0.25f, UnityColors.AliceBlue);
        }

        if (methods.DottedLine)
        {
            DebugDrawer.DrawDottedLine(start, end, Color.yellow);
        }

        if (methods.WireCube)
        {
            DebugDrawer.DrawWireCube(end, Vector3.one / 2, Color.yellow);
        }

        if (methods.DottedWireCube)
        {
            DebugDrawer.DrawDottedWireCube(end, Vector3.one, Color.black);
        }

        if (methods.Label)
        {
            DebugDrawer.DrawLabel(center + (float3)Vector3.down * 0.25f, text);
        }

        if (methods.Arrow)
        {
            DebugDrawer.DrawArrow(start + (float3)Vector3.up * 0.5f, Vector3.up, Color.blue);
        }

        if (methods.Log)
        {
            DebugDrawer.Log(threadIndex, text);
        }

        if (methods.LogWarning)
        {
            DebugDrawer.LogWarning(text);
        }

        if (methods.LogError)
        {
            DebugDrawer.LogError(text);
        }

        if (methods.Point)
        {
            DebugDrawer.DrawPoint(center + (float3)Vector3.forward, UnityColors.Lavender, 0.25f);
        }
    }
}
 public VisitStatus Visit <TProperty, TContainer>(IPropertyVisitor visitor, TProperty property, ref TContainer container, ref NativeString512 value, ref ChangeTracker changeTracker) where TProperty : IProperty <TContainer, NativeString512>
 {
     Append(property, value.ToString(), (builder, v) => { builder.Append(EncodeJsonString(v.ToString())); });
     return(VisitStatus.Override);
 }