private void SpawnTransport(ContractEventData contractData) { if (!this.CountTransportRequest(contractData)) { return; } Entity entity = contractData.Entity; BuildingTypeVO buildingVO = contractData.BuildingVO; string uid; if (buildingVO.Faction == FactionType.Empire) { uid = this.TRANSPORT_SHIP_EMPIRE; } else { if (buildingVO.Faction != FactionType.Rebel) { return; } uid = this.TRANSPORT_SHIP_REBEL; } TransportTypeVO transportType = Service.StaticDataController.Get <TransportTypeVO>(uid); Entity entity2 = this.FindIdleTransport(transportType); if (entity2 == null) { return; } Entity entity3 = this.FindIdleStarport(contractData); if (entity3 == null) { return; } TransformComponent transformComponent = entity.Get <TransformComponent>(); Vector3 vector = new Vector3(Units.BoardToWorldX(transformComponent.CenterX()), 0f, Units.BoardToWorldZ(transformComponent.CenterZ())); GameObject vehicleLocator = entity.Get <GameObjectViewComponent>().VehicleLocator; if (vehicleLocator != null) { this.factoryOffset = new Vector3(0f, vehicleLocator.transform.position.y + TransportController.FACTORY_WALL_HEIGHT, 0f); } else { this.factoryOffset = new Vector3(0f, TransportController.FACTORY_WALL_HEIGHT, 0f); } vector += this.factoryOffset; transformComponent = entity3.Get <TransformComponent>(); Vector3 vector2 = new Vector3(Units.BoardToWorldX(transformComponent.CenterX()), 0f, Units.BoardToWorldZ(transformComponent.CenterZ())); vector2 += TransportController.DOCK_OFFSET; TransportComponent transportComponent = entity2.Get <TransportComponent>(); this.BuildSpline(transportComponent.Spline, TransportController.SPAWN_POSITION, vector, vector2, entity3, contractData); entity2.Get <StateComponent>().CurState = EntityState.Moving; }
/// <summary> /// Starts this bus. /// </summary> public static async Task StartAsync() { var components = TransportContainer.Instance.Components.Select(c => c.Value.Value); var inMemoryTransport = components.FirstOrDefault(c => c is InMemory); var activeNonInMemoryTransports = components.Where(c => c != inMemoryTransport && c.IsActive); // If something besides in-memory transport is active, then it will be the transport. if (activeNonInMemoryTransports.Any()) { _transportComponent = activeNonInMemoryTransports.First(); } else { // If there is no active transport, in-memory is used. Effectively, in-memory cannot // be deactivated because it would cause Rock to not function. _transportComponent = inMemoryTransport; } try { await ConfigureAndStartBusAsync(); } catch (Exception e) { // An error occured with the chosen transport. Try one more time with in-memory to see if Rock // can still start to allow UI based configuration if (_transportComponent == inMemoryTransport) { // Already tried in-memory and it is what threw the exception throw; } // Switch to in-memory var originalTransport = _transportComponent; _transportComponent = inMemoryTransport; // Start-up with in-memory await ConfigureAndStartBusAsync(); // Log that the original transport did not work ExceptionLogService.LogException(new BusException($"Could not start the message bus transport: {originalTransport.GetType().Name}", e)); } if (_transportComponent == inMemoryTransport && !inMemoryTransport.IsActive) { // Set the in memory transport as active for the UI since it is being used using (var rockContext = new RockContext()) { inMemoryTransport.SetAttributeValue(InMemory.BaseAttributeKey.Active, true.ToString()); inMemoryTransport.SaveAttributeValue(InMemory.BaseAttributeKey.Active, rockContext); } } }
public Entity CreateTransportEntity(TransportTypeVO transportType) { Entity entity = this.NewEntity(); SizeComponent component = Units.SizeCompFromGrid(transportType.SizeX, transportType.SizeY); entity.Add(component); TransportComponent component2 = new TransportComponent(transportType); entity.Add(component2); Service.Get <EntityViewManager>().LoadEntityAsset(entity); return(entity); }
public TwilioDownloader() { TransportComponent transportComponent = null; foreach (var serviceEntry in TransportContainer.Instance.Components) { transportComponent = serviceEntry.Value.Value; var entityType = EntityTypeCache.Get(transportComponent.GetType()); if (entityType != null && entityType.Guid.Equals(EntityTypeCache.Get(typeof(Rock.Communication.Transport.Twilio)).Guid)) { accountSid = transportComponent.GetAttributeValue("SID"); authToken = transportComponent.GetAttributeValue("Token"); } } }
private void ProcessGameObject(object asset, object cookie, bool isMissingAsset) { GameObject gameObject = asset as GameObject; EntityViewParams entityViewParams = cookie as EntityViewParams; SmartEntity entity = entityViewParams.Entity; BuildingComponent buildingComp = entity.BuildingComp; TroopComponent troopComp = entity.TroopComp; TransportComponent transportComp = entity.TransportComp; DroidComponent droidComp = entity.DroidComp; bool flag = buildingComp != null; bool flag2 = troopComp != null; bool flag3 = transportComp != null; bool isDroid = droidComp != null; if (flag2) { gameObject.name = "Troop " + troopComp.TroopType.Uid + " #" + entity.ID.ToString(); } else if (flag) { gameObject.name = "Building " + buildingComp.BuildingType.Uid + " #" + entity.ID.ToString(); } else if (flag3) { gameObject.name = "Transport " + transportComp.TransportType.Uid + " #" + entity.ID.ToString(); transportComp.GameObj = gameObject; transportComp.ShadowGameObject = gameObject.transform.Find("shadowMesh").gameObject; transportComp.ShadowMaterial = UnityUtils.EnsureMaterialCopy(transportComp.ShadowGameObject.GetComponent <Renderer>()); transportComp.ShadowMaterial.shader = Service.AssetManager.Shaders.GetShader("TransportShadow"); return; } if (isMissingAsset) { gameObject.name += " MISSING"; } bool createCollider = entityViewParams.CreateCollider; this.PrepareGameObject(entity, gameObject, createCollider); if (isMissingAsset || !this.LoadAddOns(entityViewParams)) { this.SendAssetReadyEvent(flag, isMissingAsset, isDroid, entityViewParams); } }
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)); }
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)); }
private void ProcessGameObject(object asset, object cookie, bool isMissingAsset) { GameObject gameObject = asset as GameObject; EntityViewParams entityViewParams = cookie as EntityViewParams; SmartEntity entity = entityViewParams.Entity; BuildingComponent buildingComp = entity.BuildingComp; TroopComponent troopComp = entity.TroopComp; TransportComponent transportComp = entity.TransportComp; DroidComponent droidComp = entity.DroidComp; bool flag = buildingComp != null; bool flag2 = troopComp != null; bool flag3 = transportComp != null; bool isDroid = droidComp != null; AssetMeshDataMonoBehaviour component = gameObject.GetComponent <AssetMeshDataMonoBehaviour>(); if (component != null && component.ShadowGameObject != null) { Vector3 position = component.ShadowGameObject.transform.position; position.y = 0.0225f; component.ShadowGameObject.transform.position = position; } Transform transform = gameObject.transform.FindChild("MASTER_MOVER"); if (transform != null) { Transform transform2 = transform.FindChild("shadowMesh"); if (transform2 != null) { Vector3 position2 = transform2.position; position2.y = 0.0225f; transform2.position = position2; } } if (flag2) { gameObject.name = "Troop " + troopComp.TroopType.Uid + " #" + entity.ID.ToString(); } else if (flag) { gameObject.name = "Building " + buildingComp.BuildingType.Uid + " #" + entity.ID.ToString(); } else if (flag3) { gameObject.name = "Transport " + transportComp.TransportType.Uid + " #" + entity.ID.ToString(); transportComp.GameObj = gameObject; transportComp.ShadowGameObject = gameObject.transform.Find("shadowMesh").gameObject; transportComp.ShadowMaterial = UnityUtils.EnsureMaterialCopy(transportComp.ShadowGameObject.GetComponent <Renderer>()); transportComp.ShadowMaterial.shader = Service.Get <AssetManager>().Shaders.GetShader("TransportShadow"); return; } if (isMissingAsset) { gameObject.name += " MISSING"; } bool createCollider = entityViewParams.CreateCollider; this.PrepareGameObject(entity, gameObject, createCollider); if (isMissingAsset || !this.LoadAddOns(entityViewParams)) { this.SendAssetReadyEvent(flag, isMissingAsset, isDroid, entityViewParams); } }