private void RemoveEffectByEntityId(uint entityId) { if (this.effectsByEntityId != null && this.effectsByEntityId.ContainsKey(entityId)) { BuildingHoloEffect buildingHoloEffect = this.effectsByEntityId[entityId]; buildingHoloEffect.Cleanup(); this.effectsByEntityId.Remove(entityId); } }
public void TransferEffects(Entity oldBuilding, Entity newBuilding) { if (this.effectsByEntityId != null && this.effectsByEntityId.ContainsKey(oldBuilding.ID) && !this.effectsByEntityId.ContainsKey(newBuilding.ID)) { BuildingHoloEffect buildingHoloEffect = this.effectsByEntityId[oldBuilding.ID]; buildingHoloEffect.TransferEffect(newBuilding); this.effectsByEntityId.Remove(oldBuilding.ID); this.effectsByEntityId.Add(newBuilding.ID, buildingHoloEffect); if (buildingHoloEffect.WaitingForBuildingView) { Service.EventManager.RegisterObserver(this, EventId.BuildingViewReady, EventPriority.Default); } } }
private void CreateEffect(Entity building, string unitUid, bool isStarship, bool isNavCenter) { if (this.effectsByEntityId == null) { this.effectsByEntityId = new Dictionary <uint, BuildingHoloEffect>(); } if (!this.effectsByEntityId.ContainsKey(building.ID)) { BuildingHoloEffect buildingHoloEffect = new BuildingHoloEffect(building, unitUid, isStarship, isNavCenter); this.effectsByEntityId.Add(building.ID, buildingHoloEffect); } else { BuildingHoloEffect buildingHoloEffect = this.effectsByEntityId[building.ID]; buildingHoloEffect.CreateMobilizationHolo(unitUid, isStarship, isNavCenter); } }
public EatResponse OnEvent(EventId id, object cookie) { switch (id) { case EventId.StarshipMobilized: case EventId.HeroMobilized: this.OnUnitMobilized((ContractEventData)cookie); break; case EventId.StarshipMobilizedFromPrize: { Entity entity = Service.BuildingLookupController.FleetCommandNodeList.Head.Entity; this.CreateEffect(entity, (string)cookie, true, false); break; } case EventId.HeroMobilizedFromPrize: { Entity entity2 = Service.BuildingLookupController.TacticalCommandNodeList.Head.Entity; this.CreateEffect(entity2, (string)cookie, false, false); break; } default: { switch (id) { case EventId.BuildingViewReady: { EntityViewParams entityViewParams = (EntityViewParams)cookie; if (this.effectsByEntityId != null && this.effectsByEntityId.ContainsKey(entityViewParams.Entity.ID)) { BuildingHoloEffect buildingHoloEffect = this.effectsByEntityId[entityViewParams.Entity.ID]; if (buildingHoloEffect.WaitingForBuildingView) { buildingHoloEffect.UpdateEffect(); } } if (this.effectsByEntityId != null && entityViewParams.Entity.Has <NavigationCenterComponent>()) { this.AddNavigationCenterHolo(entityViewParams.Entity); } return(EatResponse.NotEaten); } case EventId.BuildingViewFailed: { IL_2D: if (id == EventId.BuildingConstructed) { goto IL_101; } if (id != EventId.BuildingReplaced) { switch (id) { case EventId.WorldLoadComplete: { IState currentState = Service.GameStateMachine.CurrentState; if (currentState is ApplicationLoadState || currentState is HomeState || currentState is WarBoardState) { this.AddAllEffects(false); } return(EatResponse.NotEaten); } case EventId.WorldInTransitionComplete: case EventId.WorldOutTransitionComplete: IL_56: if (id == EventId.ContractStarted || id == EventId.ContractContinued) { this.OnContractStarted((ContractEventData)cookie); return(EatResponse.NotEaten); } if (id != EventId.ContractCanceled) { return(EatResponse.NotEaten); } this.OnContractCanceled((ContractEventData)cookie); return(EatResponse.NotEaten); case EventId.WorldReset: this.RemoveAllEffects(); return(EatResponse.NotEaten); } goto IL_56; } SmartEntity smartEntity = cookie as SmartEntity; if (smartEntity.NavigationCenterComp != null) { this.AddNavigationCenterHolo(smartEntity); } return(EatResponse.NotEaten); } case EventId.BuildingCancelled: goto IL_101; } goto IL_2D; IL_101: ContractEventData contractEventData = (ContractEventData)cookie; if (contractEventData.BuildingVO.Type == BuildingType.NavigationCenter) { this.AddNavigationCenterHolo(); } break; } } return(EatResponse.NotEaten); }
public EatResponse OnEvent(EventId id, object cookie) { if (id <= EventId.BuildingReplaced) { if (id <= EventId.BuildingCancelled) { if (id != EventId.BuildingViewReady) { if (id != EventId.BuildingCancelled) { return(EatResponse.NotEaten); } } else { EntityViewParams entityViewParams = (EntityViewParams)cookie; if (this.effectsByEntityId != null && this.effectsByEntityId.ContainsKey(entityViewParams.Entity.ID)) { BuildingHoloEffect buildingHoloEffect = this.effectsByEntityId[entityViewParams.Entity.ID]; if (buildingHoloEffect.WaitingForBuildingView) { buildingHoloEffect.UpdateEffect(); } } if (this.effectsByEntityId != null && entityViewParams.Entity.Has <NavigationCenterComponent>()) { this.AddNavigationCenterHolo(entityViewParams.Entity); return(EatResponse.NotEaten); } return(EatResponse.NotEaten); } } else { switch (id) { case EventId.StarshipMobilized: case EventId.HeroMobilized: this.OnUnitMobilized((ContractEventData)cookie); return(EatResponse.NotEaten); case EventId.StarshipMobilizedFromPrize: { Entity entity = Service.Get <BuildingLookupController>().FleetCommandNodeList.Head.Entity; this.CreateEffect(entity, (string)cookie, true, false); return(EatResponse.NotEaten); } case EventId.HeroMobilizedFromPrize: { Entity entity2 = Service.Get <BuildingLookupController>().TacticalCommandNodeList.Head.Entity; this.CreateEffect(entity2, (string)cookie, false, false); return(EatResponse.NotEaten); } default: if (id != EventId.BuildingConstructed) { if (id != EventId.BuildingReplaced) { return(EatResponse.NotEaten); } Entity entity3 = cookie as Entity; if (entity3.Has <NavigationCenterComponent>()) { this.AddNavigationCenterHolo(entity3); return(EatResponse.NotEaten); } return(EatResponse.NotEaten); } break; } } ContractEventData contractEventData = (ContractEventData)cookie; if (contractEventData.BuildingVO.Type == BuildingType.NavigationCenter) { this.AddNavigationCenterHolo(); } } else if (id <= EventId.WorldReset) { if (id != EventId.WorldLoadComplete) { if (id == EventId.WorldReset) { this.RemoveAllEffects(); } } else { IState currentState = Service.Get <GameStateMachine>().CurrentState; if (currentState is ApplicationLoadState || currentState is HomeState || currentState is WarBoardState) { this.AddAllEffects(false); } } } else if (id != EventId.ContractStarted && id != EventId.ContractContinued) { if (id == EventId.ContractCanceled) { this.OnContractCanceled((ContractEventData)cookie); } } else { this.OnContractStarted((ContractEventData)cookie); } return(EatResponse.NotEaten); }