Exemplo n.º 1
0
        public GraphSettings(float2 pos, float2 size, float2 min, float2 max, float2 grid)
        {
            Assert.IsTrue(math.all(size > 0));
            Assert.IsTrue(math.all(grid >= 0));
            Assert.IsTrue(math.all(max > min));

            Pos   = pos;
            Size  = size;
            Min   = min;
            Max   = max;
            Grid  = grid;
            Range = max - min;
            Scale = size / Range;
            Rot   = quaternion.identity;
            Tr    = float4x4.TRS(new float3(pos + -min * Scale, 0), Rot, new float3(Scale, 1));

            MarkingInterval    = new int2(1);
            AxisColor          = Color.black;
            GridColor          = new Color(.25f, .25f, .25f, 1);
            GridAltColor       = new Color(.11f, .11f, .11f, 1);
            MarkingColor       = Color.white;
            UiBaseScale        = 1;
            MarkingScale       = 1;
            AxisNameScale      = 1;
            LegendScale        = 1;
            TitleScale         = 1;
            Title              = "";
            HorizontalAxisName = "";
            VerticalAxisName   = "";
        }
 public static void Append(this StringBuilder builder, FixedString64 fixedString)
 {
     foreach (var c in fixedString)
     {
         builder.Append((char)c.value);
     }
 }
    public void UpdatePlayerInfoDisplay(FixedString64 playerName, FixedString64 characterName, Entity pawnReference)
    {
        _playerName.text    = playerName.ToString();
        _characterName.text = characterName.ToString();

        _currentPlayer = pawnReference;
    }
Exemplo n.º 4
0
        public unsafe bool WriteFixedString64(FixedString64 str)
        {
            int   length = (int)*((ushort *)&str) + 2;
            byte *data   = ((byte *)&str);

            return(WriteBytes(data, length));
        }
Exemplo n.º 5
0
        public unsafe bool WritePackedFixedString64Delta(FixedString64 str, FixedString64 baseline, NetworkCompressionModel model)
        {
            ushort length = *((ushort *)&str);
            byte * data   = ((byte *)&str) + 2;

            return(WritePackedFixedStringDelta(data, length, ((byte *)&baseline) + 2, *((ushort *)&baseline), model));
        }
Exemplo n.º 6
0
        public unsafe FixedString64 ReadPackedFixedString64Delta(FixedString64 baseline, NetworkCompressionModel model)
        {
            FixedString64 str;
            byte *        data = ((byte *)&str) + 2;

            *(ushort *)&str = ReadPackedFixedStringDelta(data, str.Capacity, ((byte *)&baseline) + 2, *((ushort *)&baseline), model);
            return(str);
        }
 public EntityPrefab(EntityManager entityManager, Entity entity, FixedString64 name)
 {
     Name   = name;
     Entity = entity;
     entityManager.GetBuffer <EntityPrefabBufferElement>(EntityPrefab.AllSpawnDatas.dataEntity).Add(new EntityPrefabBufferElement {
         Value = this
     });
 }
Exemplo n.º 8
0
        public void WordStorageFixedString64Works(String value)
        {
            NumberedWords w           = new NumberedWords();
            FixedString64 fixedString = default;

            w.SetString(value);
            w.ToFixedString(ref fixedString);
            Assert.AreEqual(value, fixedString.ToString());
        }
Exemplo n.º 9
0
 public void AddCostRecord(FixedString64 queryDebugName, float poseCost, float trajectoryCost)
 {
     costRecords.Add(new DebugCostRecord()
     {
         queryDebugName = queryDebugName,
         poseCost       = poseCost,
         trajectoryCost = trajectoryCost
     });
 }
 public VA_AnimationData(FixedString64 a_name, int a_frames, int a_maxFrames, int a_fps, int a_positionMapIndex, int a_colorMapIndex = -1)
 {
     name              = a_name;
     frames            = a_frames;
     maxFrames         = a_maxFrames;
     animationMapIndex = a_positionMapIndex;
     colorMapIndex     = a_colorMapIndex;
     frameTime         = 1.0f / a_maxFrames * a_fps;
     duration          = 1.0f / a_maxFrames * (a_frames - 1);
 }
Exemplo n.º 11
0
 /// <summary>
 /// returns the first EntityPrefab that matches with the given lookFor argument.
 /// </summary>
 /// <param name="prefabs">prefabs to look through</param>
 /// <param name="lookfor">name of the prefab to look for</param>
 /// <returns></returns>
 public static EntityPrefab FindEntityPrefab(EntityPrefab[] prefabs, FixedString64 lookfor)
 {
     for (int i = 0; i < prefabs.Length; i++)
     {
         if (prefabs[i].Name == lookfor)
         {
             return(prefabs[i]);
         }
     }
     return(EntityPrefab.Null);
 }
Exemplo n.º 12
0
    void SendMessage(NetworkConnection connection, FixedString64 message)
    {
        //let the networkDriver start.
        DataStreamWriter streamWriter = networkDriver.BeginSend(NetworkPipeline.Null, connection);

        //write relevant data
        streamWriter.WriteUInt((uint)MessageType.Message);
        streamWriter.WriteFixedString64(message);
        //finish sending.
        networkDriver.EndSend(streamWriter);
    }
Exemplo n.º 13
0
 /// <summary>
 /// returns the first EntityPrefab that matches with the given lookFor argument.
 /// </summary>
 /// <param name="lookfor">name of the prefab to look for</param>
 /// <returns></returns>
 public static EntityPrefab FindEntityPrefab(FixedString64 lookfor)
 {
     for (int i = 0; i < AllSpawnDatas.buffer.Length; i++)
     {
         if (AllSpawnDatas.buffer[i].Value.Name == lookfor)
         {
             return(AllSpawnDatas.buffer[i].Value);
         }
     }
     return(EntityPrefab.Null);
 }
Exemplo n.º 14
0
        internal static QueryTraitExpression Create(ref Binary binary, FixedString64 debugName = default(FixedString64))
        {
            var constraints = new NativeList <Constraint>(Allocator.Temp);

            return(new QueryTraitExpression()
            {
                binary = MemoryRef <Binary> .Create(ref binary),
                constraints = constraints,
                debugName = debugName
            });
        }
    /// <summary>
    /// cache strings to avoid gc pressure
    /// </summary>
    /// <param name="fstr"></param>
    /// <returns></returns>
    private string _getString(ref FixedString64 fstr)
    {
        string toReturn;

        if (_strLookup.TryGetValue(fstr, out toReturn))
        {
            return(toReturn);
        }
        toReturn = fstr.ToString();
        _strLookup.Add(fstr, toReturn);
        return(toReturn);
    }
 public void ReadFromStream(Buffer buffer)
 {
     trajectory       = buffer.ReadBlittable <DebugIdentifier>();
     candidates       = buffer.ReadBlittable <DebugIdentifier>();
     samplingTime     = buffer.ReadBlittable <DebugIdentifier>();
     closestMatch     = buffer.ReadBlittable <DebugIdentifier>();
     deviationTable   = buffer.ReadBlittable <DebugIdentifier>();
     trajectoryWeight = buffer.ReadSingle();
     maxDeviation     = buffer.ReadSingle();
     deviated         = buffer.ReadBoolean();
     debugName        = buffer.ReadFixedString64();
 }
        public static int GetAnimation(ref VA_AnimationLibraryData animationsRef, FixedString64 animationName)
        {
            for (int i = 0; i < animationsRef.animations.Length; i++)
            {
                if (animationsRef.animations[i].name == animationName)
                {
                    return(i);
                }
            }

            return(-1);
        }
Exemplo n.º 18
0
    protected override void OnUpdate()
    {
        var x = Input.GetAxis("Horizontal");
        var y = Input.GetAxis("Vertical");

        Entities
        .WithAll <Player>()                //filter by player
        .ForEach((ref Movable mov          //, ref Translation translation, ref Rotation rot, in Player player
                  ) =>
        {
            //Debug.Log("in player forEach");
            mov.direction = new float3(x, 0, y);
        })
        .Schedule();                 //.Run() runs on main thread.   .Schedule() schedules

        var dt = Time.DeltaTime;

        var ecbSystem = World.GetOrCreateSystem <EndSimulationEntityCommandBufferSystem>();
        var ecb       = ecbSystem.CreateCommandBuffer().AsParallelWriter();

        var audioQueue       = AudioSystem.messageIn;
        var powerupMusicFile = new FixedString64("powerup");
        var gameMusicFile    = new FixedString64("game");

        Entities
        .WithNativeDisableContainerSafetyRestriction(audioQueue)
        .WithAll <Player>()
        .ForEach((Entity playerEntity, int entityInQueryIndex, ref Health hp, ref PowerPill pill, ref Damage dmg) =>
        {
            pill.pillTimer    -= dt;
            hp.invincibleTimer = pill.pillTimer;
            dmg.value          = 100;

            audioQueue.Enqueue(new AudioSystem.AudioMessage()
            {
                type = SystemMessageType.Audio_Music, audioFile = powerupMusicFile
            });
            if (pill.pillTimer <= 0)
            {
                audioQueue.Enqueue(new AudioSystem.AudioMessage()
                {
                    type = SystemMessageType.Audio_Music, audioFile = gameMusicFile
                });
                ecb.RemoveComponent <PowerPill>(entityInQueryIndex, playerEntity);
                dmg.value = 0;
            }
        })
        .ScheduleParallel();
        ecbSystem.AddJobHandleForProducer(this.Dependency);
    }
Exemplo n.º 19
0
        public void ReadWriteFixedString64()
        {
            var dataStream = new DataStreamWriter(300 * 4, Allocator.Temp);

            var src = new FixedString64("This is a string");

            dataStream.WriteFixedString64(src);

            //Assert.AreEqual(src.LengthInBytes+2, dataStream.Length);

            var reader = new DataStreamReader(dataStream.AsNativeArray());
            var dst    = reader.ReadFixedString64();

            Assert.AreEqual(src, dst);
        }
            internal string FormatToString(FixedString64 systemTypeName)
            {
                int type             = m_ProblematicTypeIndex;
                AtomicSafetyHandle h = m_ProblematicHandle;

                if (!IsWrite)
                {
                    int i = m_ReaderIndex;
                    return($"The system {systemTypeName} reads {TypeManager.GetType(type)} via {AtomicSafetyHandle.GetReaderName(h, i)} but that type was not assigned to the Dependency property. To ensure correct behavior of other systems, the job or a dependency must be assigned to the Dependency property before returning from the OnUpdate method.");
                }
                else
                {
                    return($"The system {systemTypeName} writes {TypeManager.GetType(type)} via {AtomicSafetyHandle.GetWriterName(h)} but that type was not assigned to the Dependency property. To ensure correct behavior of other systems, the job or a dependency must be assigned to the Dependency property before returning from the OnUpdate method.");
                }
            }
Exemplo n.º 21
0
        /**
         * Deserialize each field in an object
         */
        void ReadObjectViewIntoMap(SerializedObjectView objView, ref UnsafeHashMap <FixedString128, JsonKeyHandle> objMap)
        {
            var serializedViewEnum = objView.GetEnumerator();

            while (serializedViewEnum.MoveNext())
            {
                var           view     = serializedViewEnum.Current;
                var           typeInfo = DeserializeValueView(view.Value());
                FixedString64 fs       = default;
                fs.Append(view.Name().ToString());
                objMap.TryAdd(fs, typeInfo);
            }

            serializedViewEnum.Dispose();
        }
Exemplo n.º 22
0
    public void SendMessageToAllClients()
    {
        string messageRaw = inputField.text;

        inputField.text = "";
        FixedString64 message = messageRaw;

        for (int i = 0; i < connections.Length; i++)
        {
            if (!connections[i].IsCreated)
            {
                continue;
            }

            SendMessage(connections[i], message);
        }
    }
Exemplo n.º 23
0
        public void ReadWritePackedFixedString64Delta()
        {
            var dataStream       = new DataStreamWriter(300 * 4, Allocator.Temp);
            var compressionModel = new NetworkCompressionModel(Allocator.Temp);

            var src      = new FixedString64("This is a string");
            var baseline = new FixedString64("This is another string");

            dataStream.WritePackedFixedString64Delta(src, baseline, compressionModel);
            dataStream.Flush();

            //Assert.LessOrEqual(dataStream.Length, src.LengthInBytes+2);

            var reader = new DataStreamReader(dataStream.AsNativeArray());
            var dst    = reader.ReadPackedFixedString64Delta(baseline, compressionModel);

            Assert.AreEqual(src, dst);
        }
Exemplo n.º 24
0
    ///<summary>
    ///Send a message from one player to all the others.
    ///</summary>
    void HandleMessage(DataStreamReader streamReader)
    {
        uint          senderID = streamReader.ReadUInt();
        FixedString64 content  = streamReader.ReadFixedString64();

        foreach (PlayerInfo player in connectedPlayers)
        {
            if (player.iD == senderID)
            {
                continue;
            }
            var writer = networkDriver.BeginSend(player.connection);
            writer.WriteUInt((uint)MessageType.Message);
            writer.WriteUInt(senderID);
            writer.WriteFixedString64(content);
            networkDriver.EndSend(writer);
        }
    }
        internal int AddSystemType(long typeHash, FixedString64 debugName, UnmanagedComponentSystemDelegates delegates)
        {
            if (m_TypeHashToIndex.TryGetValue(typeHash, out int index))
            {
                if (m_DebugNames[index] != debugName)
                {
                    Debug.LogError($"Type hash {typeHash} for {debugName} collides with {m_DebugNames[index]}. Skipping this type. Rename the type to avoid the collision.");
                    return(-1);
                }

                m_Delegates[index] = delegates;
                return(index);
            }
            else
            {
                int newIndex = m_Delegates.Length;
                m_TypeHashToIndex.Add(typeHash, newIndex);
                m_DebugNames.Add(debugName);
                m_Delegates.Add(delegates);
                return(newIndex);
            }
        }
Exemplo n.º 26
0
        public Entity GetEntityByUIName(string name)
        {
            FixedString64 key    = new FixedString64(name);
            Entity        result = Entity.Null;

            var query = EntityManager.CreateEntityQuery(typeof(UIName));

            using (var entities = query.ToEntityArray(Allocator.Temp))
            {
                foreach (var e in entities)
                {
                    UIName uiName = EntityManager.GetComponentData <UIName>(e);
                    if (uiName.Name == key)
                    {
                        result = e;
                        break;
                    }
                }
            }

            query.Dispose();
            return(result);
        }
Exemplo n.º 27
0
 public unsafe GameSaveResult ReadDouble(FixedString64 key, out double value, double defaultValue)
 {
     value = defaultValue;
     return(ReadInternal <double>(key, ref value, GameSaveType.Double));
 }
Exemplo n.º 28
0
 public unsafe GameSaveResult ReadFixedString64(FixedString64 key, ref FixedString64 value)
 {
     return(ReadInternal <FixedString64>(key, ref value, GameSaveType.FixedString64));
 }
Exemplo n.º 29
0
 public unsafe GameSaveResult ReadFixedString64(FixedString64 key, out FixedString64 value, in FixedString64 defaultValue)
Exemplo n.º 30
0
 public IDefine GetDefine(FixedString64 defineName)
 {
     return(GetDefine(defineName.ToString()));
 }