Beispiel #1
0
        /// <summary>
        /// Generate
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="component"></param>
        /// <returns></returns>
        public string Generate(DatabaseEntity entity, GeneratorComponent component)
        {
            if (FormAspNetMvcCoreTemplateConfiguration.Instance.ValidateForm())
            {
                AspNetMvcCoreGenerator generator = new AspNetMvcCoreGenerator(Settings, entity);

                switch (component.Id)
                {
                case (int)eAspNetMvcCoreTemplateComponent.MODEL: { return(generator.GenerateCodeModel()); }

                case (int)eAspNetMvcCoreTemplateComponent.CONTROLLER: { return(generator.GenerateCodeController()); }

                case (int)eAspNetMvcCoreTemplateComponent.VIEW_CREATE: { return(generator.GenerateViewCreate()); }

                case (int)eAspNetMvcCoreTemplateComponent.VIEW_DELETE: { return(generator.GenerateViewDelete()); }

                case (int)eAspNetMvcCoreTemplateComponent.VIEW_DETAILS: { return(generator.GenerateViewDetails()); }

                case (int)eAspNetMvcCoreTemplateComponent.VIEW_EDIT: { return(generator.GenerateViewEdit()); }

                case (int)eAspNetMvcCoreTemplateComponent.VIEW_INDEX: { return(generator.GenerateViewIndex()); }
                }
            }

            return(string.Empty);
        }
Beispiel #2
0
        /// <summary>
        /// GenerateFileName
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="component"></param>
        /// <returns></returns>
        public string GenerateFileName(DatabaseEntity entity, GeneratorComponent component)
        {
            if (FormAspNetMvcCoreTemplateConfiguration.Instance.ValidateForm(false))
            {
                AspNetMvcCoreGenerator generator = new AspNetMvcCoreGenerator(Settings, entity);

                switch (component.Id)
                {
                case (int)eAspNetMvcCoreTemplateComponent.MODEL: { return(generator.ModelClassName + _defaultCsExtension); }

                case (int)eAspNetMvcCoreTemplateComponent.CONTROLLER: { return(generator.ControllerClassName + _defaultCsExtension); }

                case (int)eAspNetMvcCoreTemplateComponent.VIEW_CREATE: { return(Settings[AspNetMvcCoreConstants.CREATE_VIEWNAME].Value + _defaultCshtmlExtension); }

                case (int)eAspNetMvcCoreTemplateComponent.VIEW_DELETE: { return(Settings[AspNetMvcCoreConstants.DELETE_VIEWNAME].Value + _defaultCshtmlExtension); }

                case (int)eAspNetMvcCoreTemplateComponent.VIEW_DETAILS: { return(Settings[AspNetMvcCoreConstants.DETAILS_VIEWNAME].Value + _defaultCshtmlExtension); }

                case (int)eAspNetMvcCoreTemplateComponent.VIEW_EDIT: { return(Settings[AspNetMvcCoreConstants.EDIT_VIEWNAME].Value + _defaultCshtmlExtension); }

                case (int)eAspNetMvcCoreTemplateComponent.VIEW_INDEX: { return(Settings[AspNetMvcCoreConstants.INDEX_VIEWNAME].Value + _defaultCshtmlExtension); }
                }
            }

            return(string.Empty);
        }
Beispiel #3
0
        public void CollectCurrency(Entity buildingEntity)
        {
            if (buildingEntity == null)
            {
                return;
            }
            GeneratorComponent     generatorComponent     = buildingEntity.Get <GeneratorComponent>();
            BuildingComponent      buildingComponent      = buildingEntity.Get <BuildingComponent>();
            GeneratorViewComponent generatorViewComponent = buildingEntity.Get <GeneratorViewComponent>();

            if (buildingComponent == null || generatorComponent == null)
            {
                return;
            }
            Building     buildingTO = buildingComponent.BuildingTO;
            int          num        = this.CollectCurrencyFromGenerator(buildingEntity, true);
            string       contextId  = string.Empty;
            CurrencyType currency   = buildingComponent.BuildingType.Currency;

            if (currency != CurrencyType.Credits)
            {
                if (currency != CurrencyType.Materials)
                {
                    if (currency == CurrencyType.Contraband)
                    {
                        contextId = "Contraband";
                    }
                }
                else
                {
                    contextId = "Materials";
                }
            }
            else
            {
                contextId = "Credits";
            }
            if (buildingTO.AccruedCurrency < 1)
            {
                Service.UXController.HUD.ToggleContextButton(contextId, false);
            }
            if (num > 0)
            {
                this.OnCollectCurrency(buildingEntity, buildingComponent, num);
            }
            else if (num == 0)
            {
                this.HandleUnableToCollect(currency);
            }
            if (buildingTO.CurrentStorage == 0)
            {
                generatorViewComponent.ShowCollectButton(false);
            }
        }
        /// <summary>
        /// Generates the name of the file.
        /// </summary>
        /// <param name="entity">The entity.</param>
        /// <param name="component">The component identifier.</param>
        /// <returns></returns>
        public string GenerateFileName(DatabaseEntity entity, GeneratorComponent component)
        {
            if (FormBaseTemplateConfiguration.Instance.ValidateForm(false))
            {
                BaseGenerator generator = new BaseGenerator(Settings, entity);

                switch (component.Id)
                {
                case (int)eBaseTemplateComponent.DOMAIN: { return(generator.DomainClassName + _defaultFileExtension); }

                case (int)eBaseTemplateComponent.DATA_ACCESS: { return(generator.DataAccessClassName + _defaultFileExtension); }

                case (int)eBaseTemplateComponent.DATA_ACCESS_ASYNC: { return(generator.DataAccessClassName + _defaultFileExtension); }
                }
            }

            return(string.Empty);
        }
        /// <summary>
        /// Generates the specified entity.
        /// </summary>
        /// <param name="entity">The entity.</param>
        /// <param name="component">The component identifier.</param>
        /// <returns></returns>
        public string Generate(DatabaseEntity entity, GeneratorComponent component)
        {
            if (FormBaseTemplateConfiguration.Instance.ValidateForm())
            {
                BaseGenerator generator = new BaseGenerator(Settings, entity);

                switch (component.Id)
                {
                case (int)eBaseTemplateComponent.DOMAIN: { return(generator.GenerateCodeDomain()); }

                case (int)eBaseTemplateComponent.DATA_ACCESS: { return(generator.GenerateCodeDataAccess()); }

                case (int)eBaseTemplateComponent.DATA_ACCESS_ASYNC: { return(generator.GenerateCodeDataAccessAsync()); }
                }
            }

            return(string.Empty);
        }
Beispiel #6
0
        /// <summary>
        /// Saves the code to disk.
        /// </summary>
        /// <param name="plugin">The plugin.</param>
        /// <param name="component">The component.</param>
        /// <param name="project">The project.</param>
        /// <param name="tableName">Name of the table.</param>
        /// <param name="code">The code.</param>
        /// <param name="fileName">Name of the file.</param>
        /// <returns></returns>
        public static bool SaveCodeToProject(IGeneratorTemplate plugin, GeneratorComponent component, Project project, string tableName, string code, string fileName)
        {
            _logger.Trace("ProjectController.SaveCodeToDisk()");

            var targetDirectory = Path.Combine(project.SaveDirectory, "Files", tableName);

            if (!Directory.Exists(targetDirectory))
            {
                Directory.CreateDirectory(targetDirectory);
            }

            var entity = project.Entities.FirstOrDefault(e => e.Name.Equals(tableName, StringComparison.InvariantCultureIgnoreCase));

            if (entity == null)
            {
                entity      = new ProjectEntity();
                entity.Name = tableName;
                project.Entities.Add(entity);
            }

            project.Entities = project.Entities.OrderBy(e => e.Name).ToList();

            string guid = ((GuidAttribute)(plugin.GetType().Assembly.GetCustomAttributes(typeof(GuidAttribute), true)[0])).Value;

            var file = entity.Files.FirstOrDefault(f => f.Guid.Equals(guid, StringComparison.InvariantCultureIgnoreCase) && f.Plugin.Equals(plugin.GetType().ToString(), StringComparison.InvariantCultureIgnoreCase) && f.Component.Equals(component.Id));

            if (file == null)
            {
                file           = new ProjectEntityFile();
                file.Guid      = guid;
                file.Plugin    = plugin.GetType().ToString();
                file.Component = component.Id;
                file.File      = fileName;
                entity.Files.Add(file);
            }

            entity.Files = entity.Files.OrderBy(e => e.File).ToList();

            var targetLocation = Path.Combine(targetDirectory, fileName);

            File.WriteAllText(targetLocation, code, Encoding.UTF8);

            return(true);
        }
Beispiel #7
0
    public void UpdateFillState(Entity entity, BuildingTypeVO buildingVO)
    {
        SmartEntity smartEntity = (SmartEntity)entity;

        if (buildingVO.Storage <= 0 || string.IsNullOrEmpty(buildingVO.FillStateAssetName) || string.IsNullOrEmpty(buildingVO.FillStateBundleName))
        {
            return;
        }
        if (!entity.Has <GameObjectViewComponent>())
        {
            return;
        }
        int num = 0;
        IResourceFillable resourceFillable = null;

        if (buildingVO.Type == BuildingType.Resource)
        {
            GeneratorComponent generatorComponent = entity.Get <GeneratorComponent>();
            BuildingComponent  buildingComponent  = entity.Get <BuildingComponent>();
            num = buildingComponent.BuildingTO.AccruedCurrency;
            resourceFillable = generatorComponent;
        }
        else if (buildingVO.Type == BuildingType.Storage)
        {
            num = StorageSpreadUtils.CalculateAssumedCurrencyInStorage(buildingVO.Currency, entity);
            resourceFillable = entity.Get <StorageComponent>();
        }
        if (resourceFillable == null)
        {
            return;
        }
        float num2 = (float)num / (float)buildingVO.Storage;
        float currentFullnessPercentage = resourceFillable.CurrentFullnessPercentage;

        resourceFillable.CurrentFullnessPercentage  = num2;
        resourceFillable.PreviousFullnessPercentage = currentFullnessPercentage;
        this.UpdateFillStateFX(entity, buildingVO, num2, currentFullnessPercentage);
        if (smartEntity.BuildingComp.BuildingType.Type == BuildingType.Storage && smartEntity.BuildingComp.BuildingType.Currency == CurrencyType.Credits)
        {
            Service.EventManager.SendEvent(EventId.StorageDoorEvent, smartEntity);
        }
    }
        public void ForceCollectAccruedCurrencyForUpgrade(Entity buildingEntity)
        {
            if (buildingEntity == null)
            {
                return;
            }
            GeneratorComponent generatorComponent = buildingEntity.Get <GeneratorComponent>();
            BuildingComponent  buildingComponent  = buildingEntity.Get <BuildingComponent>();

            if (buildingComponent == null || generatorComponent == null)
            {
                return;
            }
            int num = this.CollectCurrencyFromGenerator(buildingEntity, false);

            if (num > 0)
            {
                this.OnCollectCurrency(buildingEntity, buildingComponent, num);
            }
        }
        /// <summary>
        /// Generates the name of the file.
        /// </summary>
        /// <param name="entity">The entity.</param>
        /// <param name="component">The component identifier.</param>
        /// <returns></returns>
        public string GenerateFileName(DatabaseEntity entity, GeneratorComponent component)
        {
            if (FormBaseTemplateConfiguration.Instance.ValidateForm(false))
            {
                BaseGenerator generator = new BaseGenerator(Settings, entity);

                switch (component.Id)
                {
                case (int)eBaseTemplateComponent.SAVE: { return(generator.SaveStoredProcedureName + _defaultFileExtension); }

                case (int)eBaseTemplateComponent.GET_BY_ID: { return(generator.GetByIdStoredProcedureName + _defaultFileExtension); }

                case (int)eBaseTemplateComponent.LIST_ALL: { return(generator.ListAllStoredProcedureName + _defaultFileExtension); }

                case (int)eBaseTemplateComponent.DELETE: { return(generator.DeleteStoredProcedureName + _defaultFileExtension); }
                }
            }

            return(string.Empty);
        }
        /// <summary>
        /// Generates the specified entity.
        /// </summary>
        /// <param name="entity">The entity.</param>
        /// <param name="component">The component identifier.</param>
        /// <returns></returns>
        public string Generate(DatabaseEntity entity, GeneratorComponent component)
        {
            if (FormBaseTemplateConfiguration.Instance.ValidateForm())
            {
                BaseGenerator generator = new BaseGenerator(Settings, entity);

                switch (component.Id)
                {
                case (int)eBaseTemplateComponent.SAVE: { return(generator.GenerateScriptSave()); }

                case (int)eBaseTemplateComponent.GET_BY_ID: { return(generator.GenerateScriptGetById()); }

                case (int)eBaseTemplateComponent.LIST_ALL: { return(generator.GenerateScriptListAll()); }

                case (int)eBaseTemplateComponent.DELETE: { return(generator.GenerateScriptDelete()); }
                }
            }

            return(string.Empty);
        }
Beispiel #11
0
        private void PrepareEntityView(SmartEntity entity, GameObject gameObject)
        {
            EntityRef entityRef = gameObject.AddComponent <EntityRef>();

            entityRef.Entity = entity;
            StaticDataController    staticDataController = Service.StaticDataController;
            GameObjectViewComponent gameObjectViewComponent;

            if (entity.GameObjectViewComp != null)
            {
                gameObjectViewComponent = entity.GameObjectViewComp;
                Vector3 position = gameObjectViewComponent.MainTransform.position;
                UnityEngine.Object.Destroy(gameObjectViewComponent.MainGameObject);
                gameObjectViewComponent.MainGameObject         = gameObject;
                gameObjectViewComponent.MainTransform.position = position;
            }
            else
            {
                float tooltipHeightOffset = 0f;
                if (entity.BuildingComp != null)
                {
                    tooltipHeightOffset = entity.BuildingComp.BuildingType.TooltipHeightOffset;
                    EffectsTypeVO effectsTypeVO = staticDataController.Get <EffectsTypeVO>("effect203");
                    AssetManager  assetManager  = Service.AssetManager;
                    assetManager.RegisterPreloadableAsset(effectsTypeVO.AssetName);
                    AssetHandle assetHandle = AssetHandle.Invalid;
                    assetManager.Load(ref assetHandle, effectsTypeVO.AssetName, new AssetSuccessDelegate(this.SparkFxSuccess), null, entity);
                }
                else if (entity.TroopComp != null)
                {
                    TroopTypeVO troopTypeVO = Service.StaticDataController.Get <TroopTypeVO>(entity.TroopComp.TroopType.Uid);
                    tooltipHeightOffset = troopTypeVO.TooltipHeightOffset;
                }
                gameObjectViewComponent = new GameObjectViewComponent(gameObject, tooltipHeightOffset);
                entity.Add(gameObjectViewComponent);
            }
            SupportComponent     supportComp     = entity.SupportComp;
            SupportViewComponent supportViewComp = entity.SupportViewComp;

            if (supportComp != null && supportViewComp == null)
            {
                SupportViewComponent component = new SupportViewComponent();
                entity.Add <SupportViewComponent>(component);
                if (Service.BuildingController.PurchasingBuilding != entity)
                {
                    Service.BuildingTooltipController.EnsureBuildingTooltip(entity);
                }
            }
            GeneratorComponent     generatorComp          = entity.GeneratorComp;
            GeneratorViewComponent generatorViewComponent = entity.GeneratorViewComp;

            if (generatorComp != null && generatorViewComponent == null)
            {
                generatorViewComponent = new GeneratorViewComponent(entity);
                entity.Add <GeneratorViewComponent>(generatorViewComponent);
            }
            TrapComponent     trapComp          = entity.TrapComp;
            TrapViewComponent trapViewComponent = entity.TrapViewComp;

            if (trapComp != null && trapViewComponent == null)
            {
                Animator  component2 = gameObjectViewComponent.MainGameObject.GetComponent <Animator>();
                Transform transform  = gameObjectViewComponent.MainGameObject.transform.Find("Contents");
                if (component2 == null)
                {
                    Service.Logger.ErrorFormat("A trap has been added that does not have a MecAnim controller. Building Uid: {0}, AssetName: {1}", new object[]
                    {
                        entity.BuildingComp.BuildingType.Uid,
                        entity.BuildingComp.BuildingType.AssetName
                    });
                }
                else if (transform == null)
                {
                    Service.Logger.ErrorFormat("A trap has been added that does not have a Contents transform. Building Uid: {0}, AssetName: {1}", new object[]
                    {
                        entity.BuildingComp.BuildingType.Uid,
                        entity.BuildingComp.BuildingType.AssetName
                    });
                }
                else
                {
                    GameObject gameObject2 = transform.gameObject;
                    if (gameObject2 == null)
                    {
                        Service.Logger.ErrorFormat("A trap has been added that does not have a Contents GameObject. Building Uid: {0}, AssetName: {1}", new object[]
                        {
                            entity.BuildingComp.BuildingType.Uid,
                            entity.BuildingComp.BuildingType.AssetName
                        });
                    }
                    trapViewComponent = new TrapViewComponent(component2);
                    if (trapComp.Type.EventType == TrapEventType.Turret)
                    {
                        Transform transform2 = gameObjectViewComponent.MainGameObject.transform;
                        Transform transform3 = transform2.Find(trapComp.Type.TurretTED.TurretAnimatorName);
                        if (transform3 == null)
                        {
                            Service.Logger.ErrorFormat("Trap {0}: Cannot find a gameobject in path {1}", new object[]
                            {
                                entity.BuildingComp.BuildingType.Uid,
                                trapComp.Type.TurretTED.TurretAnimatorName
                            });
                        }
                        else
                        {
                            Animator component3 = transform3.gameObject.GetComponent <Animator>();
                            if (component3 == null)
                            {
                                Service.Logger.ErrorFormat("Trap {0}: Cannot find an animator on gameobject in path {1}", new object[]
                                {
                                    entity.BuildingComp.BuildingType.Uid,
                                    trapComp.Type.TurretTED.TurretAnimatorName
                                });
                            }
                            else
                            {
                                trapViewComponent.TurretAnim = component3;
                            }
                        }
                    }
                    entity.Add <TrapViewComponent>(trapViewComponent);
                }
            }
            AssetMeshDataMonoBehaviour component4 = gameObjectViewComponent.MainGameObject.GetComponent <AssetMeshDataMonoBehaviour>();

            if (component4 != null && component4.OtherGameObjects != null)
            {
                for (int i = 0; i < component4.OtherGameObjects.Count; i++)
                {
                    if (component4.OtherGameObjects[i].name.Contains("center_of_mass"))
                    {
                        gameObjectViewComponent.CenterOfMass = component4.OtherGameObjects[i];
                    }
                    else if (component4.OtherGameObjects[i].name.Contains("locator_hit"))
                    {
                        gameObjectViewComponent.HitLocators.Add(component4.OtherGameObjects[i]);
                    }
                    else if (component4.OtherGameObjects[i].name.Contains("locator_vehicle"))
                    {
                        gameObjectViewComponent.VehicleLocator = component4.OtherGameObjects[i];
                    }
                    else if (component4.OtherGameObjects[i].name.Contains("locator_effect"))
                    {
                        gameObjectViewComponent.EffectLocators.Add(component4.OtherGameObjects[i]);
                    }
                }
            }
            if (entity.TroopComp != null)
            {
                TroopTypeVO troopTypeVO2 = (TroopTypeVO)entity.TroopComp.TroopType;
                if (!string.IsNullOrEmpty(troopTypeVO2.PlanetAttachmentId))
                {
                    string uid = Service.WorldTransitioner.GetMapDataLoader().GetPlanetData().Uid;
                    List <PlanetAttachmentVO> list = new List <PlanetAttachmentVO>();
                    foreach (PlanetAttachmentVO current in staticDataController.GetAll <PlanetAttachmentVO>())
                    {
                        if (current.AttachmentId == troopTypeVO2.PlanetAttachmentId && current.Planets != null && Array.IndexOf <string>(current.Planets, uid) != -1)
                        {
                            list.Add(current);
                        }
                    }
                    AssetManager assetManager2 = Service.AssetManager;
                    for (int j = 0; j < list.Count; j++)
                    {
                        if (list[j] == null)
                        {
                            Service.Logger.ErrorFormat("Attachment is null for troop {0}, asset {1}", new object[]
                            {
                                troopTypeVO2.Uid,
                                troopTypeVO2.AssetName
                            });
                        }
                        else
                        {
                            AssetHandle        assetHandle2       = AssetHandle.Invalid;
                            PlanetAttachmentTO planetAttachmentTO = new PlanetAttachmentTO();
                            planetAttachmentTO.Entity  = entity;
                            planetAttachmentTO.Locator = UnityUtils.FindGameObject(gameObjectViewComponent.MainGameObject, list[j].Locator);
                            if (planetAttachmentTO.Locator == null)
                            {
                                Service.Logger.ErrorFormat("Locator {0} not found in asset {1}, and it should be according to PlanetAttachmentData {2}", new object[]
                                {
                                    list[j].Locator,
                                    troopTypeVO2.AssetName,
                                    list[j].Uid
                                });
                                planetAttachmentTO.Locator = gameObjectViewComponent.MainGameObject;
                            }
                            assetManager2.Load(ref assetHandle2, list[j].AssetName, new AssetSuccessDelegate(this.PlanetAttachmentSuccess), null, planetAttachmentTO);
                        }
                    }
                }
            }
            FactoryComponent factoryComp = entity.FactoryComp;

            if (factoryComp != null)
            {
                EffectsTypeVO effectsTypeVO2 = staticDataController.Get <EffectsTypeVO>("effect203");
                AssetManager  assetManager3  = Service.AssetManager;
                assetManager3.RegisterPreloadableAsset(effectsTypeVO2.AssetName);
                AssetHandle assetHandle3 = AssetHandle.Invalid;
                assetManager3.Load(ref assetHandle3, effectsTypeVO2.AssetName, new AssetSuccessDelegate(this.SparkFxSuccess), null, entity);
            }
            this.SetupGunLocators(entity, component4);
            if (entity.TroopShieldHealthComp != null && entity.TroopShieldViewComp == null)
            {
                TroopTypeVO troop = Service.StaticDataController.Get <TroopTypeVO>(entity.TroopComp.TroopType.Uid);
                entity.Add <TroopShieldViewComponent>(new TroopShieldViewComponent(troop));
            }
            gameObject.SetActive(false);
            this.CheckHealthView(entity);
            this.CheckMeterShaderView(entity);
            Service.EntityRenderController.UpdateNewEntityView(entity);
        }
Beispiel #12
0
 public override object Remove(Type compCls)
 {
     if (compCls == typeof(AreaTriggerComponent))
     {
         this.AreaTriggerComp = null;
     }
     else if (compCls == typeof(ArmoryComponent))
     {
         this.ArmoryComp = null;
     }
     else if (compCls == typeof(AssetComponent))
     {
         this.AssetComp = null;
     }
     else if (compCls == typeof(AttackerComponent))
     {
         this.AttackerComp = null;
     }
     else if (compCls == typeof(BarracksComponent))
     {
         this.BarracksComp = null;
     }
     else if (compCls == typeof(BoardItemComponent))
     {
         this.BoardItemComp = null;
     }
     else if (compCls == typeof(BuildingAnimationComponent))
     {
         this.BuildingAnimationComp = null;
     }
     else if (compCls == typeof(BuildingComponent))
     {
         this.BuildingComp = null;
     }
     else if (compCls == typeof(CantinaComponent))
     {
         this.CantinaComp = null;
     }
     else if (compCls == typeof(ChampionComponent))
     {
         this.ChampionComp = null;
     }
     else if (compCls == typeof(CivilianComponent))
     {
         this.CivilianComp = null;
     }
     else if (compCls == typeof(ClearableComponent))
     {
         this.ClearableComp = null;
     }
     else if (compCls == typeof(DamageableComponent))
     {
         this.DamageableComp = null;
     }
     else if (compCls == typeof(DefenderComponent))
     {
         this.DefenderComp = null;
     }
     else if (compCls == typeof(DefenseLabComponent))
     {
         this.DefenseLabComp = null;
     }
     else if (compCls == typeof(DroidComponent))
     {
         this.DroidComp = null;
     }
     else if (compCls == typeof(DroidHutComponent))
     {
         this.DroidHutComp = null;
     }
     else if (compCls == typeof(SquadBuildingComponent))
     {
         this.SquadBuildingComp = null;
     }
     else if (compCls == typeof(NavigationCenterComponent))
     {
         this.NavigationCenterComp = null;
     }
     else if (compCls == typeof(FactoryComponent))
     {
         this.FactoryComp = null;
     }
     else if (compCls == typeof(FleetCommandComponent))
     {
         this.FleetCommandComp = null;
     }
     else if (compCls == typeof(FollowerComponent))
     {
         this.FollowerComp = null;
     }
     else if (compCls == typeof(GameObjectViewComponent))
     {
         this.GameObjectViewComp = null;
     }
     else if (compCls == typeof(GeneratorComponent))
     {
         this.GeneratorComp = null;
     }
     else if (compCls == typeof(GeneratorViewComponent))
     {
         this.GeneratorViewComp = null;
     }
     else if (compCls == typeof(HealerComponent))
     {
         this.HealerComp = null;
     }
     else if (compCls == typeof(HealthComponent))
     {
         this.HealthComp = null;
     }
     else if (compCls == typeof(TroopShieldComponent))
     {
         this.TroopShieldComp = null;
     }
     else if (compCls == typeof(TroopShieldViewComponent))
     {
         this.TroopShieldViewComp = null;
     }
     else if (compCls == typeof(TroopShieldHealthComponent))
     {
         this.TroopShieldHealthComp = null;
     }
     else if (compCls == typeof(HealthViewComponent))
     {
         this.HealthViewComp = null;
     }
     else if (compCls == typeof(HQComponent))
     {
         this.HQComp = null;
     }
     else if (compCls == typeof(KillerComponent))
     {
         this.KillerComp = null;
     }
     else if (compCls == typeof(LootComponent))
     {
         this.LootComp = null;
     }
     else if (compCls == typeof(MeterShaderComponent))
     {
         this.MeterShaderComp = null;
     }
     else if (compCls == typeof(OffenseLabComponent))
     {
         this.OffenseLabComp = null;
     }
     else if (compCls == typeof(PathingComponent))
     {
         this.PathingComp = null;
     }
     else if (compCls == typeof(SecondaryTargetsComponent))
     {
         this.SecondaryTargetsComp = null;
     }
     else if (compCls == typeof(ShieldBorderComponent))
     {
         this.ShieldBorderComp = null;
     }
     else if (compCls == typeof(ShieldGeneratorComponent))
     {
         this.ShieldGeneratorComp = null;
     }
     else if (compCls == typeof(SizeComponent))
     {
         this.SizeComp = null;
     }
     else if (compCls == typeof(ShooterComponent))
     {
         this.ShooterComp = null;
     }
     else if (compCls == typeof(StarportComponent))
     {
         this.StarportComp = null;
     }
     else if (compCls == typeof(StateComponent))
     {
         this.StateComp = null;
     }
     else if (compCls == typeof(StorageComponent))
     {
         this.StorageComp = null;
     }
     else if (compCls == typeof(SupportComponent))
     {
         this.SupportComp = null;
     }
     else if (compCls == typeof(SupportViewComponent))
     {
         this.SupportViewComp = null;
     }
     else if (compCls == typeof(TacticalCommandComponent))
     {
         this.TacticalCommandComp = null;
     }
     else if (compCls == typeof(ChampionPlatformComponent))
     {
         this.ChampionPlatformComp = null;
     }
     else if (compCls == typeof(TeamComponent))
     {
         this.TeamComp = null;
     }
     else if (compCls == typeof(TrackingComponent))
     {
         this.TrackingComp = null;
     }
     else if (compCls == typeof(TrackingGameObjectViewComponent))
     {
         this.TrackingGameObjectViewComp = null;
     }
     else if (compCls == typeof(TransformComponent))
     {
         this.TransformComp = null;
     }
     else if (compCls == typeof(TransportComponent))
     {
         this.TransportComp = null;
     }
     else if (compCls == typeof(TroopComponent))
     {
         this.TroopComp = null;
     }
     else if (compCls == typeof(TurretBuildingComponent))
     {
         this.TurretBuildingComp = null;
     }
     else if (compCls == typeof(TurretShooterComponent))
     {
         this.TurretShooterComp = null;
     }
     else if (compCls == typeof(WalkerComponent))
     {
         this.WalkerComp = null;
     }
     else if (compCls == typeof(WallComponent))
     {
         this.WallComp = null;
     }
     else if (compCls == typeof(BuffComponent))
     {
         this.BuffComp = null;
     }
     else if (compCls == typeof(TrapComponent))
     {
         this.TrapComp = null;
     }
     else if (compCls == typeof(TrapViewComponent))
     {
         this.TrapViewComp = null;
     }
     else if (compCls == typeof(HousingComponent))
     {
         this.HousingComp = null;
     }
     else if (compCls == typeof(SpawnComponent))
     {
         this.SpawnComp = null;
     }
     return(base.Remove(compCls));
 }
Beispiel #13
0
        protected override Entity AddComponentAndDispatchAddEvent(ComponentBase comp, Type compCls)
        {
            bool flag = false;

            if (comp is AreaTriggerComponent)
            {
                this.AreaTriggerComp = (AreaTriggerComponent)comp;
                flag = true;
            }
            if (comp is ArmoryComponent)
            {
                this.ArmoryComp = (ArmoryComponent)comp;
                flag            = true;
            }
            if (comp is AssetComponent)
            {
                this.AssetComp = (AssetComponent)comp;
                flag           = true;
            }
            if (comp is AttackerComponent)
            {
                this.AttackerComp = (AttackerComponent)comp;
                flag = true;
            }
            if (comp is BarracksComponent)
            {
                this.BarracksComp = (BarracksComponent)comp;
                flag = true;
            }
            if (comp is BoardItemComponent)
            {
                this.BoardItemComp = (BoardItemComponent)comp;
                flag = true;
            }
            if (comp is BuildingAnimationComponent)
            {
                this.BuildingAnimationComp = (BuildingAnimationComponent)comp;
                flag = true;
            }
            if (comp is BuildingComponent)
            {
                this.BuildingComp = (BuildingComponent)comp;
                flag = true;
            }
            if (comp is ChampionComponent)
            {
                this.ChampionComp = (ChampionComponent)comp;
                flag = true;
            }
            if (comp is CivilianComponent)
            {
                this.CivilianComp = (CivilianComponent)comp;
                flag = true;
            }
            if (comp is ClearableComponent)
            {
                this.ClearableComp = (ClearableComponent)comp;
                flag = true;
            }
            if (comp is DamageableComponent)
            {
                this.DamageableComp = (DamageableComponent)comp;
                flag = true;
            }
            if (comp is DefenderComponent)
            {
                this.DefenderComp = (DefenderComponent)comp;
                flag = true;
            }
            if (comp is DefenseLabComponent)
            {
                this.DefenseLabComp = (DefenseLabComponent)comp;
                flag = true;
            }
            if (comp is DroidComponent)
            {
                this.DroidComp = (DroidComponent)comp;
                flag           = true;
            }
            if (comp is DroidHutComponent)
            {
                this.DroidHutComp = (DroidHutComponent)comp;
                flag = true;
            }
            if (comp is SquadBuildingComponent)
            {
                this.SquadBuildingComp = (SquadBuildingComponent)comp;
                flag = true;
            }
            if (comp is NavigationCenterComponent)
            {
                this.NavigationCenterComp = (NavigationCenterComponent)comp;
                flag = true;
            }
            if (comp is FactoryComponent)
            {
                this.FactoryComp = (FactoryComponent)comp;
                flag             = true;
            }
            if (comp is CantinaComponent)
            {
                this.CantinaComp = (CantinaComponent)comp;
                flag             = true;
            }
            if (comp is FleetCommandComponent)
            {
                this.FleetCommandComp = (FleetCommandComponent)comp;
                flag = true;
            }
            if (comp is FollowerComponent)
            {
                this.FollowerComp = (FollowerComponent)comp;
                flag = true;
            }
            if (comp is GameObjectViewComponent)
            {
                this.GameObjectViewComp = (GameObjectViewComponent)comp;
                flag = true;
            }
            if (comp is GeneratorComponent)
            {
                this.GeneratorComp = (GeneratorComponent)comp;
                flag = true;
            }
            if (comp is GeneratorViewComponent)
            {
                this.GeneratorViewComp = (GeneratorViewComponent)comp;
                flag = true;
            }
            if (comp is HealerComponent)
            {
                this.HealerComp = (HealerComponent)comp;
                flag            = true;
            }
            if (comp is TroopShieldComponent)
            {
                this.TroopShieldComp = (TroopShieldComponent)comp;
                flag = true;
            }
            if (comp is TroopShieldViewComponent)
            {
                this.TroopShieldViewComp = (TroopShieldViewComponent)comp;
                flag = true;
            }
            if (comp is TroopShieldHealthComponent)
            {
                this.TroopShieldHealthComp = (TroopShieldHealthComponent)comp;
                flag = true;
            }
            if (comp is HealthComponent)
            {
                this.HealthComp = (HealthComponent)comp;
                flag            = true;
            }
            if (comp is HealthViewComponent)
            {
                this.HealthViewComp = (HealthViewComponent)comp;
                flag = true;
            }
            if (comp is HQComponent)
            {
                this.HQComp = (HQComponent)comp;
                flag        = true;
            }
            if (comp is KillerComponent)
            {
                this.KillerComp = (KillerComponent)comp;
                flag            = true;
            }
            if (comp is LootComponent)
            {
                this.LootComp = (LootComponent)comp;
                flag          = true;
            }
            if (comp is MeterShaderComponent)
            {
                this.MeterShaderComp = (MeterShaderComponent)comp;
                flag = true;
            }
            if (comp is OffenseLabComponent)
            {
                this.OffenseLabComp = (OffenseLabComponent)comp;
                flag = true;
            }
            if (comp is PathingComponent)
            {
                this.PathingComp = (PathingComponent)comp;
                flag             = true;
            }
            if (comp is SecondaryTargetsComponent)
            {
                this.SecondaryTargetsComp = (SecondaryTargetsComponent)comp;
                flag = true;
            }
            if (comp is ShieldBorderComponent)
            {
                this.ShieldBorderComp = (ShieldBorderComponent)comp;
                flag = true;
            }
            if (comp is ShieldGeneratorComponent)
            {
                this.ShieldGeneratorComp = (ShieldGeneratorComponent)comp;
                flag = true;
            }
            if (comp is SizeComponent)
            {
                this.SizeComp = (SizeComponent)comp;
                flag          = true;
            }
            if (comp is ShooterComponent)
            {
                this.ShooterComp = (ShooterComponent)comp;
                flag             = true;
            }
            if (comp is StarportComponent)
            {
                this.StarportComp = (StarportComponent)comp;
                flag = true;
            }
            if (comp is StateComponent)
            {
                this.StateComp = (StateComponent)comp;
                flag           = true;
            }
            if (comp is StorageComponent)
            {
                this.StorageComp = (StorageComponent)comp;
                flag             = true;
            }
            if (comp is SupportComponent)
            {
                this.SupportComp = (SupportComponent)comp;
                flag             = true;
            }
            if (comp is SupportViewComponent)
            {
                this.SupportViewComp = (SupportViewComponent)comp;
                flag = true;
            }
            if (comp is TacticalCommandComponent)
            {
                this.TacticalCommandComp = (TacticalCommandComponent)comp;
                flag = true;
            }
            if (comp is ChampionPlatformComponent)
            {
                this.ChampionPlatformComp = (ChampionPlatformComponent)comp;
                flag = true;
            }
            if (comp is TeamComponent)
            {
                this.TeamComp = (TeamComponent)comp;
                flag          = true;
            }
            if (comp is TrackingComponent)
            {
                this.TrackingComp = (TrackingComponent)comp;
                flag = true;
            }
            if (comp is TrackingGameObjectViewComponent)
            {
                this.TrackingGameObjectViewComp = (TrackingGameObjectViewComponent)comp;
                flag = true;
            }
            if (comp is TransformComponent)
            {
                this.TransformComp = (TransformComponent)comp;
                flag = true;
            }
            if (comp is TransportComponent)
            {
                this.TransportComp = (TransportComponent)comp;
                flag = true;
            }
            if (comp is TroopComponent)
            {
                this.TroopComp = (TroopComponent)comp;
                flag           = true;
            }
            if (comp is TurretBuildingComponent)
            {
                this.TurretBuildingComp = (TurretBuildingComponent)comp;
                flag = true;
            }
            if (comp is TurretShooterComponent)
            {
                this.TurretShooterComp = (TurretShooterComponent)comp;
                flag = true;
            }
            if (comp is WalkerComponent)
            {
                this.WalkerComp = (WalkerComponent)comp;
                flag            = true;
            }
            if (comp is WallComponent)
            {
                this.WallComp = (WallComponent)comp;
                flag          = true;
            }
            if (comp is BuffComponent)
            {
                this.BuffComp = (BuffComponent)comp;
                flag          = true;
            }
            if (comp is TrapComponent)
            {
                this.TrapComp = (TrapComponent)comp;
                flag          = true;
            }
            if (comp is TrapViewComponent)
            {
                this.TrapViewComp = (TrapViewComponent)comp;
                flag = true;
            }
            if (comp is HousingComponent)
            {
                this.HousingComp = (HousingComponent)comp;
                flag             = true;
            }
            if (comp is ScoutTowerComponent)
            {
                this.ScoutTowerComp = (ScoutTowerComponent)comp;
                flag = true;
            }
            if (comp is SpawnComponent)
            {
                this.SpawnComp = (SpawnComponent)comp;
                flag           = true;
            }
            if (!flag && compCls != null)
            {
                Service.Logger.Error("Invalid component add: " + compCls.Name);
            }
            return(base.AddComponentAndDispatchAddEvent(comp, compCls));
        }
Beispiel #14
0
        private void PrepareEntityView(SmartEntity entity, GameObject gameObject)
        {
            EntityRef entityRef = gameObject.AddComponent <EntityRef>();

            entityRef.Entity = entity;
            IDataController         dataController = Service.Get <IDataController>();
            GameObjectViewComponent gameObjectViewComponent;

            if (entity.GameObjectViewComp != null)
            {
                gameObjectViewComponent = entity.GameObjectViewComp;
                UnityEngine.Object.Destroy(gameObjectViewComponent.MainGameObject);
                gameObjectViewComponent.MainGameObject = gameObject;
            }
            else
            {
                float tooltipHeightOffset = 0f;
                if (entity.BuildingComp != null)
                {
                    tooltipHeightOffset = entity.BuildingComp.BuildingType.TooltipHeightOffset;
                    EffectsTypeVO effectsTypeVO = dataController.Get <EffectsTypeVO>("effect203");
                    AssetManager  assetManager  = Service.Get <AssetManager>();
                    assetManager.RegisterPreloadableAsset(effectsTypeVO.AssetName);
                    AssetHandle assetHandle = AssetHandle.Invalid;
                    assetManager.Load(ref assetHandle, effectsTypeVO.AssetName, new AssetSuccessDelegate(this.SparkFxSuccess), null, entity);
                }
                else if (entity.TroopComp != null)
                {
                    TroopTypeVO troopTypeVO = Service.Get <IDataController>().Get <TroopTypeVO>(entity.TroopComp.TroopType.Uid);
                    tooltipHeightOffset = troopTypeVO.TooltipHeightOffset;
                }
                gameObjectViewComponent = new GameObjectViewComponent(gameObject, tooltipHeightOffset);
                entity.Add(gameObjectViewComponent);
            }
            SupportComponent     supportComp     = entity.SupportComp;
            SupportViewComponent supportViewComp = entity.SupportViewComp;

            if (supportComp != null && supportViewComp == null)
            {
                SupportViewComponent component = new SupportViewComponent();
                entity.Add <SupportViewComponent>(component);
                if (Service.Get <BuildingController>().PurchasingBuilding != entity)
                {
                    Service.Get <BuildingTooltipController>().EnsureBuildingTooltip(entity);
                }
            }
            GeneratorComponent     generatorComp          = entity.GeneratorComp;
            GeneratorViewComponent generatorViewComponent = entity.GeneratorViewComp;

            if (generatorComp != null && generatorViewComponent == null)
            {
                generatorViewComponent = new GeneratorViewComponent(entity);
                entity.Add <GeneratorViewComponent>(generatorViewComponent);
            }
            TrapComponent     trapComp          = entity.TrapComp;
            TrapViewComponent trapViewComponent = entity.TrapViewComp;

            if (trapComp != null && trapViewComponent == null)
            {
                Animator  component2 = gameObjectViewComponent.MainGameObject.GetComponent <Animator>();
                Transform transform  = gameObjectViewComponent.MainGameObject.transform.FindChild("Contents");
                if (component2 == null)
                {
                    Service.Get <StaRTSLogger>().ErrorFormat("A trap has been added that does not have a MecAnim controller. Building Uid: {0}, AssetName: {1}", new object[]
                    {
                        entity.BuildingComp.BuildingType.Uid,
                        entity.BuildingComp.BuildingType.AssetName
                    });
                }
                else if (transform == null)
                {
                    Service.Get <StaRTSLogger>().ErrorFormat("A trap has been added that does not have a Contents transform. Building Uid: {0}, AssetName: {1}", new object[]
                    {
                        entity.BuildingComp.BuildingType.Uid,
                        entity.BuildingComp.BuildingType.AssetName
                    });
                }
                else
                {
                    GameObject gameObject2 = transform.gameObject;
                    if (gameObject2 == null)
                    {
                        Service.Get <StaRTSLogger>().ErrorFormat("A trap has been added that does not have a Contents GameObject. Building Uid: {0}, AssetName: {1}", new object[]
                        {
                            entity.BuildingComp.BuildingType.Uid,
                            entity.BuildingComp.BuildingType.AssetName
                        });
                    }
                    trapViewComponent = new TrapViewComponent(component2);
                    if (trapComp.Type.EventType == TrapEventType.Turret)
                    {
                        Transform transform2 = gameObjectViewComponent.MainGameObject.transform;
                        Transform transform3 = transform2.FindChild(trapComp.Type.TurretTED.TurretAnimatorName);
                        if (transform3 == null)
                        {
                            Service.Get <StaRTSLogger>().ErrorFormat("Trap {0}: Cannot find a gameobject in path {1}", new object[]
                            {
                                entity.BuildingComp.BuildingType.Uid,
                                trapComp.Type.TurretTED.TurretAnimatorName
                            });
                        }
                        else
                        {
                            Animator component3 = transform3.gameObject.GetComponent <Animator>();
                            if (component3 == null)
                            {
                                Service.Get <StaRTSLogger>().ErrorFormat("Trap {0}: Cannot find an animator on gameobject in path {1}", new object[]
                                {
                                    entity.BuildingComp.BuildingType.Uid,
                                    trapComp.Type.TurretTED.TurretAnimatorName
                                });
                            }
                            else
                            {
                                trapViewComponent.TurretAnim = component3;
                            }
                        }
                    }
                    entity.Add <TrapViewComponent>(trapViewComponent);
                }
            }
            AssetMeshDataMonoBehaviour component4 = gameObjectViewComponent.MainGameObject.GetComponent <AssetMeshDataMonoBehaviour>();

            if (component4 != null && component4.OtherGameObjects != null)
            {
                for (int i = 0; i < component4.OtherGameObjects.Count; i++)
                {
                    if (component4.OtherGameObjects[i].name.Contains("center_of_mass"))
                    {
                        gameObjectViewComponent.CenterOfMass = component4.OtherGameObjects[i];
                    }
                    else if (component4.OtherGameObjects[i].name.Contains("locator_hit"))
                    {
                        gameObjectViewComponent.HitLocators.Add(component4.OtherGameObjects[i]);
                    }
                    else if (component4.OtherGameObjects[i].name.Contains("locator_vehicle"))
                    {
                        gameObjectViewComponent.VehicleLocator = component4.OtherGameObjects[i];
                    }
                    else if (component4.OtherGameObjects[i].name.Contains("locator_effect"))
                    {
                        gameObjectViewComponent.EffectLocators.Add(component4.OtherGameObjects[i]);
                    }
                }
            }
            FactoryComponent factoryComp = entity.FactoryComp;

            if (factoryComp != null)
            {
                EffectsTypeVO effectsTypeVO2 = dataController.Get <EffectsTypeVO>("effect203");
                AssetManager  assetManager2  = Service.Get <AssetManager>();
                assetManager2.RegisterPreloadableAsset(effectsTypeVO2.AssetName);
                AssetHandle assetHandle2 = AssetHandle.Invalid;
                assetManager2.Load(ref assetHandle2, effectsTypeVO2.AssetName, new AssetSuccessDelegate(this.SparkFxSuccess), null, entity);
            }
            this.SetupGunLocators(entity, component4);
            if (entity.TroopShieldHealthComp != null && entity.TroopShieldViewComp == null)
            {
                TroopTypeVO troop = Service.Get <IDataController>().Get <TroopTypeVO>(entity.TroopComp.TroopType.Uid);
                entity.Add <TroopShieldViewComponent>(new TroopShieldViewComponent(troop));
            }
            gameObject.SetActive(false);
            this.CheckHealthView(entity);
            this.CheckMeterShaderView(entity);
            Service.Get <EntityRenderController>().UpdateNewEntityView(entity);
        }