コード例 #1
0
 void IEcsWorldDebugListener.OnEntityDestroyed(EcsEntity entity)
 {
     if (!EntityGameObjects.TryGetValue(entity.GetInternalId(), out var go))
     {
         throw new Exception("Unity visualization not exists, looks like a bug");
     }
     UpdateEntityName(entity, false);
     go.SetActive(false);
 }
コード例 #2
0
 void IEcsWorldDebugListener.OnEntityCreated(EcsEntity entity)
 {
     if (!EntityGameObjects.TryGetValue(entity.GetInternalId(), out var go))
     {
         go = new GameObject();
         go.transform.SetParent(_entitiesRoot, false);
         go.hideFlags = HideFlags.NotEditable;
         var unityEntity = go.AddComponent <EcsEntityObserver> ();
         unityEntity.World  = _world;
         unityEntity.Entity = entity;
         EntityGameObjects[entity.GetInternalId()] = go;
         UpdateEntityName(entity, false);
     }
     else
     {
         // need to update cached entity generation.
         go.GetComponent <EcsEntityObserver> ().Entity = entity;
     }
     go.SetActive(true);
 }
コード例 #3
0
        /// <summary>
        /// Process supplied <see cref="SelltowerRequest"/>.
        /// </summary>
        /// <param name="request">Request to process.</param>
        public void SellTower(SelltowerRequest request)
        {
            foreach (int i in this.towerFilter)
            {
                ref EcsEntity towerEntity = ref this.towerFilter.GetEntity(i);
                if (request.TowerId != (short)towerEntity.GetInternalId())
                {
                    continue;
                }

                // Perform changes
                ref GameComponent   game   = ref this.gameFilter.Get1(0);
コード例 #4
0
        void UpdateEntityName(EcsEntity entity, bool requestComponents)
        {
            var entityId   = entity.GetInternalId();
            var entityName = entityId.ToString("D8");

            if (entity.IsAlive() && requestComponents)
            {
                var count = entity.GetComponentTypes(ref _componentTypesCache);
                for (var i = 0; i < count; i++)
                {
                    entityName = $"{entityName}:{EditorHelpers.GetCleanGenericTypeName (_componentTypesCache[i])}";
                    _componentTypesCache[i] = null;
                }
            }
            EntityGameObjects[entityId].name = entityName;
        }