private bool IsTroopValid(TroopComponent component) { if (component.Entity.Get <TeamComponent>().TeamType != this.teamMatchType) { return(false); } if (this.any) { return(true); } ITroopDeployableVO troopType = component.TroopType; if (troopType.Lvl >= this.level) { switch (this.matchType) { case ConditionMatchType.Uid: return(troopType.Uid == this.unitMatchId); case ConditionMatchType.Id: return(troopType.UpgradeGroup == this.unitMatchId); case ConditionMatchType.Type: return(troopType.Type == StringUtils.ParseEnum <TroopType>(this.unitMatchId)); } } return(false); }
public void OnTroopSpawned(SmartEntity troopEntity) { if (troopEntity != null && troopEntity.TroopComp != null) { ITroopDeployableVO troopType = troopEntity.TroopComp.TroopType; TroopAbilityVO abilityVO = troopEntity.TroopComp.AbilityVO; if (abilityVO != null) { if (this.deployedTroops == null) { this.deployedTroops = new Dictionary <uint, DeployedTroop>(); } if (this.deployedTroops.Count == 0) { this.EnsureEvents(true); } DeployedTroop deployedTroop = new DeployedTroop(troopType.Uid, troopEntity); this.deployedTroops.Add(troopEntity.ID, deployedTroop); if (abilityVO.Auto) { if (abilityVO.CooldownOnSpawn) { this.StartCoolDown(deployedTroop, abilityVO); return; } this.QueueAutoActivateAbility(troopEntity.ID); } } } }
public bool RestartPathing(SmartEntity troopEntity, out bool found, bool ignoreWall) { ShooterComponent shooterComp = troopEntity.ShooterComp; IShooterVO shooterVO = shooterComp.ShooterVO; TroopComponent troopComp = troopEntity.TroopComp; TeamComponent teamComp = troopEntity.TeamComp; ITroopDeployableVO troopType = troopComp.TroopType; uint maxAttackRange = this.GetMaxAttackRange(troopEntity, shooterComp.Target); PathTroopParams troopParams = new PathTroopParams { TroopWidth = troopEntity.SizeComp.Width, DPS = shooterVO.DPS, MinRange = shooterVO.MinAttackRange, MaxRange = maxAttackRange, MaxSpeed = troopComp.SpeedVO.MaxSpeed, PathSearchWidth = troopType.PathSearchWidth, IsMelee = shooterComp.IsMelee, IsOverWall = shooterVO.OverWalls, IsHealer = troopType.IsHealer, SupportRange = troopType.SupportFollowDistance, ProjectileType = shooterVO.ProjectileType, CrushesWalls = troopType.CrushesWalls, IsTargetShield = GameUtils.IsEntityShieldGenerator(troopEntity.ShooterComp.Target), TargetInRangeModifier = troopType.TargetInRangeModifier }; PathBoardParams boardParams = new PathBoardParams { IgnoreWall = (teamComp.IsDefender() || ignoreWall), Destructible = teamComp.CanDestructBuildings() }; return(this.StartPathing(troopEntity, shooterComp.Target, troopEntity.TransformComp, true, out found, -1, troopParams, boardParams, true, false)); }
private void ActivateAbilityViewEffects(DeployedTroop deployedTroop, TroopAbilityVO ability) { SmartEntity entity = deployedTroop.Entity; GameObjectViewComponent gameObjectViewComp = entity.GameObjectViewComp; if (gameObjectViewComp == null) { return; } if (ability.AltGunLocators != null && ability.AltGunLocators.Length != 0) { gameObjectViewComp.SwitchGunLocators(true); } GameObject mainGameObject = gameObjectViewComp.MainGameObject; mainGameObject.transform.localScale = Vector3.one * ability.PersistentScaling; if (!string.IsNullOrEmpty(ability.PersistentEffect)) { ITroopDeployableVO troopType = entity.TroopComp.TroopType; TransformComponent transformComp = entity.TransformComp; deployedTroop.LightSaberHitFx = new LightSaberHitEffect(ability.ProjectileType.SplashRadius, transformComp.CenterGridX(), transformComp.CenterGridZ(), mainGameObject.transform, ability.PersistentEffect, troopType.Faction); } if (deployedTroop.WeaponTrail != null && deployedTroop.WeaponTrailActivateLifetime > 0f) { deployedTroop.WeaponTrail.ChangeLifeTime(deployedTroop.WeaponTrailActivateLifetime); } }
public TroopComponent(TroopTypeVO troopType) : base(troopType.AssetName, troopType) { this.TroopType = troopType; this.TroopShooterVO = troopType; this.OriginalTroopShooterVO = troopType; this.AudioVO = troopType; if (!string.IsNullOrEmpty(troopType.Ability)) { this.AbilityVO = Service.StaticDataController.Get <TroopAbilityVO>(troopType.Ability); } base.SetVOData(troopType); this.TargetCount = 0; this.UpdateWallAttackerTroop = false; this.IsAbilityModeActive = false; }
public void StartMoving(SmartEntity entity) { ITroopDeployableVO troopType = entity.TroopComp.TroopType; entity.StateComp.CurState = EntityState.Moving; entity.StateComp.IsRunning = false; entity.PathingComp.MaxSpeed = entity.TroopComp.SpeedVO.MaxSpeed; if (troopType.RunSpeed > 0) { entity.StateComp.ForceUpdateAnimation = true; if (entity.PathingComp.CurrentPath.CellCount > troopType.RunThreshold && entity.ShooterComp.Target != null) { entity.StateComp.IsRunning = true; entity.PathingComp.MaxSpeed = troopType.RunSpeed; if (entity.TroopShieldComp != null) { entity.Remove <TroopShieldComponent>(); } } } }
private BuffTypeVO ShouldDeflectProjectile(ProjectileView view, float distSquared) { SmartEntity target = view.Bullet.Target; if (target == null || target.TroopComp == null || !target.TroopComp.IsAbilityModeActive) { return(null); } Bullet bullet = view.Bullet; if (bullet.IsDeflection) { return(null); } if (!bullet.ProjectileType.IsDeflectable) { return(null); } TroopComponent troopComp = target.TroopComp; ITroopDeployableVO troopType = troopComp.TroopType; float num = (float)(troopType.SizeX + troopType.SizeY) * 0.5f; num += 1.33f; float num2 = num * 0.5f * 3f; if (distSquared > num2 * num2) { return(null); } string selfBuff = troopComp.AbilityVO.SelfBuff; if (string.IsNullOrEmpty(selfBuff)) { return(null); } return(Service.Get <IDataController>().GetOptional <BuffTypeVO>(selfBuff)); }
private void ResetAttackFSM(SmartEntity troopEntity) { StaRTSLogger staRTSLogger = Service.Get <StaRTSLogger>(); StateComponent stateComp = troopEntity.StateComp; if (stateComp == null) { staRTSLogger.Error("ResetAttackFSM StateComp is null"); return; } stateComp.Reset(); TroopComponent troopComp = troopEntity.TroopComp; if (troopComp == null) { staRTSLogger.Error("ResetAttackFSM TroopComp is null"); return; } ITroopDeployableVO troopType = troopComp.TroopType; if (troopType == null) { staRTSLogger.Error("ResetAttackFSM TroopVO is null"); return; } HealthType healthType = troopType.IsHealer ? HealthType.Healing : HealthType.Damaging; ShooterComponent shooterComp = troopEntity.ShooterComp; if (shooterComp == null) { staRTSLogger.Error("ResetAttackFSM ShooterComp is null"); return; } shooterComp.Reset(); shooterComp.AttackFSM = new AttackFSM(Service.Get <BattleController>(), troopEntity, troopEntity.StateComp, shooterComp, troopEntity.TransformComp, healthType); }
public EatResponse OnEvent(EventId id, object cookie) { switch (id) { case EventId.ContractAdded: { ContractEventData contractEventData = (ContractEventData)cookie; if (contractEventData.Contract.ProductUid.Equals(this.eventData[0], StringComparison.InvariantCultureIgnoreCase)) { this.CountEvent(); } return(EatResponse.NotEaten); } case EventId.ContractBacklogUpdated: IL_18: switch (id) { case EventId.ScreenClosing: { UXFactory uXFactory = cookie as UXFactory; string text = (uXFactory != null && !(uXFactory.Root == null)) ? uXFactory.Root.name : string.Empty; if (text.Equals(this.eventData[0], StringComparison.InvariantCultureIgnoreCase)) { this.CountEvent(); } return(EatResponse.NotEaten); } case EventId.ScreenClosed: case EventId.ScreenOverlayClosing: IL_34: if (id != EventId.BuildingPurchaseSuccess) { if (id != EventId.BuildingSelected) { if (id != EventId.DroidPurchaseAnimationComplete) { if (id != EventId.EntityKilled) { if (id != EventId.TroopDeployed) { if (id == EventId.TroopDonationTrackRewardReceived) { goto IL_3C0; } if (id == EventId.SpecialAttackDeployed) { SpecialAttack specialAttack = (SpecialAttack)cookie; if (specialAttack.VO.Uid.Equals(this.eventData[0], StringComparison.InvariantCultureIgnoreCase)) { this.CountEvent(); } return(EatResponse.NotEaten); } if (id == EventId.ButtonClicked) { string text2 = (string)cookie; if (text2.Equals(this.eventData[0], StringComparison.InvariantCultureIgnoreCase)) { this.CountEvent(); } return(EatResponse.NotEaten); } if (id == EventId.ContractCompletedForStoryAction) { ContractTO contractTO = (ContractTO)cookie; if (contractTO.Uid.Equals(this.eventData[0], StringComparison.InvariantCultureIgnoreCase)) { this.CountEvent(); } return(EatResponse.NotEaten); } if (id == EventId.InventoryResourceUpdated) { string text3 = (string)cookie; if (text3.Equals(this.eventData[0], StringComparison.InvariantCultureIgnoreCase)) { this.CountEvent(); } return(EatResponse.NotEaten); } if (id != EventId.HeroDeployed && id != EventId.ChampionDeployed) { if (id != EventId.EquipmentUnlocked) { return(EatResponse.NotEaten); } goto IL_3C0; } } Entity entity = (Entity)cookie; TroopComponent troopComponent = entity.Get <TroopComponent>(); ITroopDeployableVO troopType = troopComponent.TroopType; if (troopType.Uid.Equals(this.eventData[0], StringComparison.InvariantCultureIgnoreCase)) { this.CountEvent(); } return(EatResponse.NotEaten); } Entity entity2 = (Entity)cookie; string text4 = string.Empty; string a = this.prepareArgs[1]; if (a == "troopKilled") { TroopComponent troopComponent2 = entity2.Get <TroopComponent>(); if (troopComponent2 == null) { return(EatResponse.NotEaten); } text4 = troopComponent2.TroopType.Uid; } else if (a == "buildingKilled") { BuildingComponent buildingComponent = entity2.Get <BuildingComponent>(); if (buildingComponent == null) { return(EatResponse.NotEaten); } BuildingTypeVO buildingType = buildingComponent.BuildingType; text4 = buildingType.Uid; } if (text4.Equals(this.eventData[0], StringComparison.InvariantCultureIgnoreCase)) { this.CountEvent(); } return(EatResponse.NotEaten); } IL_3C0: this.CountEvent(); return(EatResponse.NotEaten); } Entity entity3 = (Entity)cookie; BuildingComponent buildingComponent2 = entity3.Get <BuildingComponent>(); if (buildingComponent2 == null) { return(EatResponse.NotEaten); } BuildingTypeVO buildingType2 = buildingComponent2.BuildingType; if (buildingType2.Uid.Equals(this.eventData[0], StringComparison.InvariantCultureIgnoreCase)) { this.CountEvent(); } return(EatResponse.NotEaten); } else { Entity entity4 = (Entity)cookie; BuildingComponent buildingComponent3 = entity4.Get <BuildingComponent>(); if (buildingComponent3 == null) { return(EatResponse.NotEaten); } BuildingTypeVO buildingType3 = buildingComponent3.BuildingType; if (buildingType3.Uid.Equals(this.eventData[0], StringComparison.InvariantCultureIgnoreCase)) { this.CountEvent(); } return(EatResponse.NotEaten); } break; case EventId.ScreenLoaded: { UXFactory uXFactory2 = cookie as UXFactory; string name = uXFactory2.Root.name; if (name.Equals(this.eventData[0], StringComparison.InvariantCultureIgnoreCase)) { this.CountEvent(); } return(EatResponse.NotEaten); } } goto IL_34; case EventId.ContractStarted: { ContractEventData contractEventData2 = (ContractEventData)cookie; if (contractEventData2.Contract.ProductUid.Equals(this.eventData[0], StringComparison.InvariantCultureIgnoreCase)) { this.CountEvent(); } return(EatResponse.NotEaten); } } goto IL_18; }
private bool UpdateNode(SmartEntity entity, TargetingController.OnTargetingDone onTroopTargetingDone, bool updateWallBreakingTroops) { if (entity.StateComp.CurState == EntityState.Disable) { return(false); } bool flag = false; if (updateWallBreakingTroops) { return(this.UpdateWallBreakingTroops(entity, onTroopTargetingDone)); } if (!GameUtils.IsEligibleToFindTarget(entity.ShooterComp)) { return(false); } ShooterComponent shooterComp = entity.ShooterComp; if (!shooterComp.Searching && !shooterComp.ReevaluateTarget) { return(false); } bool flag2; if (shooterComp.Searching) { if (shooterComp.TargetingDelayAmount > 0) { shooterComp.TargetingDelayAmount--; return(false); } flag2 = this.FindTargetForTroopNode(entity, false); } else { flag2 = this.FindTargetForTroopNode(entity, true); } shooterComp.ReevaluateTarget = false; if (!flag2) { return(false); } if (!shooterComp.Searching) { shooterComp.AttackFSM.StopAttacking(true); } SmartEntity primaryTarget = this.shooterController.GetPrimaryTarget(entity.ShooterComp); if (primaryTarget.TransformComp == null) { return(false); } flag = false; TroopComponent troopComp = entity.TroopComp; ITroopDeployableVO troopType = troopComp.TroopType; IShooterVO shooterVO = shooterComp.ShooterVO; uint maxAttackRange = this.pathingManager.GetMaxAttackRange(entity, primaryTarget); PathTroopParams troopParams = new PathTroopParams { TroopWidth = entity.SizeComp.Width, DPS = shooterVO.DPS, MinRange = shooterVO.MinAttackRange, MaxRange = maxAttackRange, MaxSpeed = troopComp.SpeedVO.MaxSpeed, PathSearchWidth = troopType.PathSearchWidth, IsMelee = shooterComp.IsMelee, IsOverWall = shooterComp.ShooterVO.OverWalls, IsHealer = TroopController.IsEntityHealer(entity), SupportRange = troopType.SupportFollowDistance, CrushesWalls = TroopController.CanEntityCrushWalls(entity), ProjectileType = shooterVO.ProjectileType, IsTargetShield = GameUtils.IsEntityShieldGenerator(primaryTarget), TargetInRangeModifier = troopType.TargetInRangeModifier }; PathBoardParams boardParams = new PathBoardParams { IgnoreWall = TroopController.CanEntityIgnoreWalls(entity), Destructible = entity.TeamComp.CanDestructBuildings() }; bool flag3 = this.pathingManager.StartPathing(entity, primaryTarget, entity.TransformComp, true, out flag, -1, troopParams, boardParams, false, false); if (!flag3) { onTroopTargetingDone(entity); this.shooterController.StopSearch(shooterComp); return(true); } if (!flag) { GameUtils.UpdateMinimumFrameCountForNextTargeting(shooterComp); return(false); } this.RandomizeTargetingDelay(shooterComp); onTroopTargetingDone(entity); this.shooterController.StopSearch(shooterComp); this.OnPathingComplete(entity, entity.SecondaryTargetsComp, entity.StateComp, shooterComp, primaryTarget); return(true); }
public EatResponse OnEvent(EventId id, object cookie) { if (id <= EventId.ButtonClicked) { if (id <= EventId.EntityKilled) { if (id <= EventId.BuildingSelected) { if (id != EventId.BuildingPurchaseSuccess) { if (id != EventId.BuildingSelected) { return(EatResponse.NotEaten); } Entity entity = (Entity)cookie; BuildingComponent buildingComponent = entity.Get <BuildingComponent>(); if (buildingComponent == null) { return(EatResponse.NotEaten); } BuildingTypeVO buildingType = buildingComponent.BuildingType; if (buildingType.Uid.Equals(this.eventData[0], 5)) { this.CountEvent(); return(EatResponse.NotEaten); } return(EatResponse.NotEaten); } else { Entity entity2 = (Entity)cookie; BuildingComponent buildingComponent2 = entity2.Get <BuildingComponent>(); if (buildingComponent2 == null) { return(EatResponse.NotEaten); } BuildingTypeVO buildingType2 = buildingComponent2.BuildingType; if (buildingType2.Uid.Equals(this.eventData[0], 5)) { this.CountEvent(); return(EatResponse.NotEaten); } return(EatResponse.NotEaten); } } else { if (id == EventId.DroidPurchaseAnimationComplete) { goto IL_3D4; } if (id != EventId.EntityKilled) { return(EatResponse.NotEaten); } Entity entity3 = (Entity)cookie; string text = ""; string text2 = this.prepareArgs[1]; if (text2 == "troopKilled") { TroopComponent troopComponent = entity3.Get <TroopComponent>(); if (troopComponent == null) { return(EatResponse.NotEaten); } text = troopComponent.TroopType.Uid; } else if (text2 == "buildingKilled") { BuildingComponent buildingComponent3 = entity3.Get <BuildingComponent>(); if (buildingComponent3 == null) { return(EatResponse.NotEaten); } BuildingTypeVO buildingType3 = buildingComponent3.BuildingType; text = buildingType3.Uid; } if (text.Equals(this.eventData[0], 5)) { this.CountEvent(); return(EatResponse.NotEaten); } return(EatResponse.NotEaten); } } else if (id <= EventId.TroopDonationTrackRewardReceived) { if (id != EventId.TroopDeployed) { if (id != EventId.TroopDonationTrackRewardReceived) { return(EatResponse.NotEaten); } goto IL_3D4; } } else if (id != EventId.SpecialAttackDeployed) { if (id != EventId.ButtonClicked) { return(EatResponse.NotEaten); } string text3 = (string)cookie; if (text3.Equals(this.eventData[0], 5)) { this.CountEvent(); return(EatResponse.NotEaten); } return(EatResponse.NotEaten); } else { SpecialAttack specialAttack = (SpecialAttack)cookie; if (specialAttack.VO.Uid.Equals(this.eventData[0], 5)) { this.CountEvent(); return(EatResponse.NotEaten); } return(EatResponse.NotEaten); } } else if (id <= EventId.InventoryResourceUpdated) { if (id <= EventId.ContractStarted) { if (id != EventId.ContractAdded) { if (id != EventId.ContractStarted) { return(EatResponse.NotEaten); } ContractEventData contractEventData = (ContractEventData)cookie; if (contractEventData.Contract.ProductUid.Equals(this.eventData[0], 5)) { this.CountEvent(); return(EatResponse.NotEaten); } return(EatResponse.NotEaten); } else { ContractEventData contractEventData2 = (ContractEventData)cookie; if (contractEventData2.Contract.ProductUid.Equals(this.eventData[0], 5)) { this.CountEvent(); return(EatResponse.NotEaten); } return(EatResponse.NotEaten); } } else if (id != EventId.ContractCompletedForStoryAction) { if (id != EventId.InventoryResourceUpdated) { return(EatResponse.NotEaten); } string text4 = (string)cookie; if (text4.Equals(this.eventData[0], 5)) { this.CountEvent(); return(EatResponse.NotEaten); } return(EatResponse.NotEaten); } else { ContractTO contractTO = (ContractTO)cookie; if (contractTO.Uid.Equals(this.eventData[0], 5)) { this.CountEvent(); return(EatResponse.NotEaten); } return(EatResponse.NotEaten); } } else if (id <= EventId.ScreenLoaded) { if (id != EventId.ScreenClosing) { if (id != EventId.ScreenLoaded) { return(EatResponse.NotEaten); } UXFactory uXFactory = cookie as UXFactory; string name = uXFactory.Root.name; if (name.Equals(this.eventData[0], 5)) { this.CountEvent(); return(EatResponse.NotEaten); } return(EatResponse.NotEaten); } else { UXFactory uXFactory2 = cookie as UXFactory; string text5 = (uXFactory2 == null || uXFactory2.Root == null) ? string.Empty : uXFactory2.Root.name; if (text5.Equals(this.eventData[0], 5)) { this.CountEvent(); return(EatResponse.NotEaten); } return(EatResponse.NotEaten); } } else if (id != EventId.HeroDeployed && id != EventId.ChampionDeployed) { if (id != EventId.EquipmentUnlocked) { return(EatResponse.NotEaten); } goto IL_3D4; } Entity entity4 = (Entity)cookie; TroopComponent troopComponent2 = entity4.Get <TroopComponent>(); ITroopDeployableVO troopType = troopComponent2.TroopType; if (troopType.Uid.Equals(this.eventData[0], 5)) { this.CountEvent(); return(EatResponse.NotEaten); } return(EatResponse.NotEaten); IL_3D4: this.CountEvent(); return(EatResponse.NotEaten); }