public RuntimeTerraEntity(AssembledEntity entity, TerraDBService db)
        {
            entity.TerraPosition3D.InstanceId = entity.TerraEntity.InstanceId;
            Position = new TerraPosition3DComponent(db, entity.TerraPosition3D);
            Entity   = entity.TerraEntity;

            Entity.OnLabelAdded   += (labelEntity, label) => OnLabelAdded?.Invoke(this, label);
            Entity.OnLabelRemoved += (labelEntity, label) => OnLabelRemoved?.Invoke(this, label);

            EntityTypeData = TerraGameResources.Instance.TerraEntityPrefabConfig.GetEntityConfig(this);
            DB             = db;
        }
Beispiel #2
0
        public TerraEntityTypeData GetEntityConfig(ITerraEntityType type)
        {
            TerraEntityTypeData config = null;

            foreach (TerraEntityTypeSO go in DataConfig)
            {
                if (go.Data.EntityID == type.EntityID)
                {
                    config = go.Data;
                    break;
                }
            }

            return(config);
        }
        public void LoadEntitesOfType(TerraEntityTypeData type, Action <RuntimeTerraEntity[]> onComplete, Action <Exception> onError)
        {
            AssembledEntitySerializer serializer = new AssembledEntitySerializer();

            //TerraEntity[] entities = _db.Get<TerraEntitySerializer, TerraEntity>(TerraEntity.Serializer);

            AssembledEntity[] entities = _db.Get <AssembledEntitySerializer, AssembledEntity>(
                serializer,
                "",
                $"SELECT {GetColumnSelectors(AssembledEntitySerializer.TerraEntitySerializer)},{GetColumnSelectors(AssembledEntitySerializer.TerraPosition3DSerializer)} " +
                $"FROM {AssembledEntitySerializer.TerraEntitySerializer.Table} " +
                $"LEFT OUTER JOIN {AssembledEntitySerializer.TerraPosition3DSerializer.Table} " +
                $"ON {AssembledEntitySerializer.TerraEntitySerializer.Table}.{TerraEntitySerializer.COLUMN_INSTNACE_ID} = {AssembledEntitySerializer.TerraPosition3DSerializer.Table}.{TerraEntitySerializer.COLUMN_INSTNACE_ID} " +
                $"WHERE {TerraEntitySerializer.TABLE}.{TerraEntitySerializer.COLUMN_ENTITY_ID} = '{type.EntityID}'");

            RuntimeTerraEntity[] runtimeEntities = new RuntimeTerraEntity[entities.Length];

            for (int i = 0; i < entities.Length; i++)
            {
                runtimeEntities[i] = new RuntimeTerraEntity(entities[i], _db);
            }

            onComplete(runtimeEntities);
        }