public bool TryCollectCurrencyOnSelection(Entity entity) { if (!(Service.Get <GameStateMachine>().CurrentState is HomeState)) { return(false); } if (Service.Get <PostBattleRepairController>().IsEntityInRepair(entity)) { return(false); } if (ContractUtils.IsBuildingConstructing(entity) || ContractUtils.IsBuildingUpgrading(entity)) { return(false); } if (!this.IsGeneratorThresholdMet(entity)) { return(false); } if (!this.CanStoreCollectionAmountFromGenerator(entity)) { BuildingComponent buildingComponent = entity.Get <BuildingComponent>(); CurrencyType currency = buildingComponent.BuildingType.Currency; this.HandleUnableToCollect(currency); return(false); } this.CollectCurrency(entity); return(true); }
public void RemoveEntity(Entity entity, bool removeSpawnProtection) { BoardItemComponent boardItemComponent = entity.Get <BoardItemComponent>(); if (boardItemComponent == null) { return; } BuildingComponent buildingComponent = entity.Get <BuildingComponent>(); this.board.RemoveChild(boardItemComponent.BoardItem, buildingComponent != null && buildingComponent.BuildingType.Type != BuildingType.Blocker, buildingComponent != null); if (buildingComponent != null) { FlagStamp flagStamp = boardItemComponent.BoardItem.FlagStamp; if (flagStamp == null) { return; } flagStamp.Clear(); if (!removeSpawnProtection) { uint num = 4u; if (buildingComponent.BuildingType.AllowDefensiveSpawn) { num |= 32u; } flagStamp.Fill(num); } this.board.AddFlagStamp(flagStamp); } Service.EventManager.SendEvent(EventId.BuildingRemovedFromBoard, entity); }
public BoardCell <Entity> MoveBuildingWithinBoard(Entity building, int boardX, int boardZ) { BoardController boardController = Service.Get <BoardController>(); BoardItemComponent boardItemComponent = building.Get <BoardItemComponent>(); BoardItem <Entity> boardItem = boardItemComponent.BoardItem; BuildingComponent buildingComponent = building.Get <BuildingComponent>(); bool checkSkirt = buildingComponent.BuildingType.Type != BuildingType.Blocker; BoardCell <Entity> boardCell = boardController.Board.MoveChild(boardItem, boardX, boardZ, building.Get <HealthComponent>(), true, checkSkirt); if (boardCell != null) { TransformComponent transformComponent = building.Get <TransformComponent>(); transformComponent.X = boardCell.X; transformComponent.Z = boardCell.Z; DamageableComponent damageableComponent = building.Get <DamageableComponent>(); if (damageableComponent != null) { damageableComponent.Init(); } Building buildingTO = building.Get <BuildingComponent>().BuildingTO; buildingTO.SyncWithTransform(transformComponent); Service.Get <EventManager>().SendEvent(EventId.BuildingMovedOnBoard, building); } else { Service.Get <StaRTSLogger>().ErrorFormat("Failed to move building {0}:{1} to ({2},{3})", new object[] { buildingComponent.BuildingTO.Key, buildingComponent.BuildingTO.Uid, boardX, boardZ }); } return(boardCell); }
public CombatEncounter GetCurrentCombatEncounter() { CombatEncounter combatEncounter = new CombatEncounter(); combatEncounter.map = new Map(); combatEncounter.map.Buildings = new List <Building>(); BoardController boardController = Service.BoardController; Board board = boardController.Board; LinkedList <BoardItem> children = board.Children; if (children != null) { foreach (BoardItem current in children) { BoardCell currentCell = current.CurrentCell; Entity data = current.Data; BuildingComponent buildingComponent = data.Get <BuildingComponent>(); if (buildingComponent != null) { Building building = new Building(); building.Key = buildingComponent.BuildingTO.Key; building.Uid = buildingComponent.BuildingType.Uid; building.X = Units.BoardToGridX(currentCell.X); building.Z = Units.BoardToGridZ(currentCell.Z); building.CurrentStorage = buildingComponent.BuildingTO.CurrentStorage; combatEncounter.map.Buildings.Add(building); } } } combatEncounter.map.Planet = Service.CurrentPlayer.Map.Planet; return(combatEncounter); }
public BuildingPart(string componentType, Vector3 location, string orientation, Town town) { componentName = componentType; this.componentType = SelectComponent(componentType, town); this.location = location; this.orientation = orientation; }
public bool CanStoreCollectionAmountFromGenerator(Entity buildingEntity) { BuildingComponent buildingComponent = buildingEntity.Get <BuildingComponent>(); Inventory inventory = Service.CurrentPlayer.Inventory; int num = 0; CurrencyType currency = buildingComponent.BuildingType.Currency; if (currency != CurrencyType.Credits) { if (currency != CurrencyType.Materials) { if (currency == CurrencyType.Contraband) { num = inventory.GetItemCapacity("contraband") - inventory.GetItemAmount("contraband"); } } else { num = inventory.GetItemCapacity("materials") - inventory.GetItemAmount("materials"); } } else { num = inventory.GetItemCapacity("credits") - inventory.GetItemAmount("credits"); } return(num > 0); }
private SmartEntity GetPrefferedBuilding(ShooterComponent shooterComp, PriorityList <SmartEntity> buildings, ref int maxWeight) { HashSet <string> hashSet = new HashSet <string>(); SmartEntity result = null; int i = 0; int count = buildings.Count; while (i < count) { ElementPriorityPair <SmartEntity> elementPriorityPair = buildings.Get(i); SmartEntity element = elementPriorityPair.Element; HealthComponent healthComp = element.HealthComp; if (healthComp != null && !healthComp.IsDead()) { BuildingComponent buildingComp = element.BuildingComp; if (buildingComp.BuildingType.Type != BuildingType.Blocker && (element.TrapComp == null || element.TrapComp.CurrentState == TrapState.Armed) && hashSet.Add(buildingComp.BuildingType.BuildingID)) { int num = this.CalculateWeight(shooterComp, null, healthComp.ArmorType, elementPriorityPair.Priority); if (num > maxWeight) { maxWeight = num; result = element; } } } i++; } return(result); }
private SupportViewComponentState GetBubbleViewComponentStateBasedOnBuilding(SmartEntity building) { SupportViewComponentState result = SupportViewComponentState.Bubble; if (building == null) { return(result); } BuildingComponent buildingComp = building.BuildingComp; if (buildingComp == null) { return(result); } BuildingTypeVO buildingType = buildingComp.BuildingType; if (buildingType.Type == BuildingType.HQ) { return(SupportViewComponentState.BubbleHQ); } if (buildingType.Type == BuildingType.Armory && this.ShouldBadgeArmoryBuilding()) { result = SupportViewComponentState.BubbleArmoryUpgrade; } if (buildingType.Type == BuildingType.TroopResearch && this.ShouldBadgeResearchBuilding()) { result = SupportViewComponentState.BubbleShardUpgrade; } return(result); }
private void SetStarportDecal(Entity entity) { BuildingComponent buildingComponent = entity.Get <BuildingComponent>(); if (buildingComponent.BuildingType.Type == BuildingType.Starport) { int lvl = buildingComponent.BuildingType.Lvl; int num = (lvl - 1) % 3; float x = StarportDecalManager.FX_STARPORT_DECAL_OFFSET[num]; Vector2 mainTextureOffset = new Vector2(x, 0f); GameObjectViewComponent gameObjectViewComponent = entity.Get <GameObjectViewComponent>(); if (gameObjectViewComponent != null) { Transform[] componentsInChildren = gameObjectViewComponent.MainGameObject.GetComponentsInChildren <Transform>(); for (int i = 0; i < componentsInChildren.Length; i++) { if (componentsInChildren[i].gameObject.name.Contains("numberMesh")) { GameObject gameObject = componentsInChildren[i].gameObject; Renderer component = gameObject.GetComponent <Renderer>(); Material material = UnityUtils.EnsureMaterialCopy(component); material.mainTextureOffset = mainTextureOffset; this.decalMaterials.Add(material); } } } } }
private void UpdateArmoryAnimation(SmartEntity entity) { IState currentState = Service.Get <GameStateMachine>().CurrentState; CurrentPlayer currentPlayer = Service.Get <CurrentPlayer>(); BuildingComponent buildingComp = entity.BuildingComp; if (!(currentState is HomeState) || buildingComp == null || buildingComp.BuildingType.Type != BuildingType.Armory) { return; } BuildingAnimationComponent buildingAnimationComp = entity.BuildingAnimationComp; if (buildingAnimationComp == null) { return; } Animation anim = buildingAnimationComp.Anim; if (!ArmoryUtils.IsAnyEquipmentActive(currentPlayer.ActiveArmory) && anim.GetClip("Idle") != null) { anim.Stop(); anim.Play("Idle"); Service.Get <ShuttleController>().DestroyArmoryShuttle(entity); return; } if (entity.StateComp.CurState == EntityState.Idle && anim.IsPlaying("Idle") && anim.GetClip("Active") != null && anim.GetClip("Intro") != null) { anim.Stop(); anim.Play("Intro"); this.EnqueueAnimation(buildingAnimationComp, "Active"); Service.Get <ShuttleController>().UpdateArmoryShuttle(entity); } }
private bool ShouldAttackAlternateTarget(ShooterComponent shooterComp, Entity alternateTarget) { if (alternateTarget == null) { return(false); } BuildingComponent buildingComponent = alternateTarget.Get <BuildingComponent>(); TransformComponent transformComponent = alternateTarget.Get <TransformComponent>(); if (buildingComponent == null || buildingComponent.BuildingType == null || transformComponent == null) { return(false); } if (buildingComponent.BuildingType.Type == BuildingType.Blocker) { return(false); } if (buildingComponent.BuildingType.Type != BuildingType.Wall) { return(true); } SmartEntity primaryTarget = this.GetPrimaryTarget(shooterComp); return(primaryTarget != null && primaryTarget.Get <TransformComponent>() != null); }
private bool IsBuildingValid(BuildingComponent component) { BuildingTypeVO buildingType = component.BuildingType; if (this.any && GameUtils.IsBuildingTypeValidForBattleConditions(component.BuildingType.Type)) { return(true); } if (buildingType.Lvl >= this.level) { ConditionMatchType conditionMatchType = this.matchType; if (conditionMatchType == ConditionMatchType.Uid) { return(buildingType.Uid == this.buildingId); } if (conditionMatchType == ConditionMatchType.Id) { return(buildingType.UpgradeGroup == this.buildingId); } if (conditionMatchType == ConditionMatchType.Type) { return(buildingType.Type == StringUtils.ParseEnum <BuildingType>(this.buildingId)); } } return(false); }
public static SmartEntity FindLeastFullStarport() { float num = 0f; int num2 = 0; SmartEntity smartEntity = null; NodeList <StarportNode> starportNodeList = Service.BuildingLookupController.StarportNodeList; for (StarportNode starportNode = starportNodeList.Head; starportNode != null; starportNode = starportNode.Next) { BuildingComponent buildingComp = starportNode.BuildingComp; SmartEntity smartEntity2 = (SmartEntity)buildingComp.Entity; if (!ContractUtils.IsBuildingConstructing(smartEntity2)) { int starportFillSize = StorageSpreadUtils.GetStarportFillSize(smartEntity2); int storage = buildingComp.BuildingType.Storage; if (smartEntity == null || (float)starportFillSize < num || ((float)starportFillSize == num && storage < num2)) { num = (float)starportFillSize; num2 = storage; smartEntity = smartEntity2; } } } return(smartEntity); }
public static void ProcessResouceGenPerkEffectsIntoStorage(List <ActivatedPerkData> allPerks) { ISupportController supportController = Service.Get <ISupportController>(); NodeList <GeneratorViewNode> nodeList = Service.Get <EntityController>().GetNodeList <GeneratorViewNode>(); for (GeneratorViewNode generatorViewNode = nodeList.Head; generatorViewNode != null; generatorViewNode = generatorViewNode.Next) { BuildingComponent buildingComp = generatorViewNode.BuildingComp; Building buildingTO = buildingComp.BuildingTO; BuildingTypeVO buildingType = buildingComp.BuildingType; Contract contract = supportController.FindCurrentContract(buildingComp.BuildingTO.Key); if (buildingType.Type == BuildingType.Resource && contract == null) { uint time = ServerTime.Time; uint lastCollectTime = buildingTO.LastCollectTime; buildingTO.LastCollectTime = time; int perkAdjustedAccruedCurrency = ResourceGenerationPerkUtils.GetPerkAdjustedAccruedCurrency(buildingType, lastCollectTime, time, allPerks); buildingTO.CurrentStorage += perkAdjustedAccruedCurrency; if (buildingTO.CurrentStorage > buildingType.Storage) { buildingTO.CurrentStorage = buildingType.Storage; } buildingTO.AccruedCurrency = buildingTO.CurrentStorage; } } }
public static bool HasCapacityForTroop(Entity entity, int size) { int num = ContractUtils.CalculateSpaceOccupiedByQueuedTroops(entity); BuildingComponent buildingComponent = entity.Get <BuildingComponent>(); return(size <= buildingComponent.BuildingType.Storage - num); }
public static bool CanCancelDeployableContract(Entity selectedBuilding) { if (!ContractUtils.IsArmyUpgrading(selectedBuilding)) { return(false); } IDataController dataController = Service.Get <IDataController>(); BuildingComponent buildingComponent = selectedBuilding.Get <BuildingComponent>(); Contract contract = Service.Get <ISupportController>().FindCurrentContract(buildingComponent.BuildingTO.Key); string productUid = contract.ProductUid; IDeployableVO optional = dataController.GetOptional <TroopTypeVO>(productUid); string text = null; if (optional != null) { text = optional.UpgradeShardUid; } else { optional = dataController.GetOptional <SpecialAttackTypeVO>(productUid); if (optional != null) { text = optional.UpgradeShardUid; } else { Service.Get <StaRTSLogger>().Error("CanCancelDeployableContract: Unsupported deployable type, not troop or special attack " + productUid); } } return(string.IsNullOrEmpty(text)); }
public static int CalculateNumTroopsQueued(Entity entity) { BuildingComponent buildingComponent = entity.Get <BuildingComponent>(); List <Contract> list = Service.Get <ISupportController>().FindAllTroopContractsForBuilding(buildingComponent.BuildingTO.Key); return(list.Count); }
public static int CalculateSpaceOccupiedByQueuedTroops(Entity entity) { int num = 0; BuildingComponent buildingComponent = entity.Get <BuildingComponent>(); List <Contract> list = Service.Get <ISupportController>().FindAllTroopContractsForBuilding(buildingComponent.BuildingTO.Key); bool flag = false; if (buildingComponent.BuildingType.Type == BuildingType.FleetCommand) { flag = true; } IDataController dataController = Service.Get <IDataController>(); for (int i = 0; i < list.Count; i++) { string productUid = list[i].ProductUid; int size; if (flag) { size = dataController.Get <SpecialAttackTypeVO>(productUid).Size; } else { size = dataController.Get <TroopTypeVO>(productUid).Size; } num += size; } return(num); }
private void HideComponent(BuildingComponent component) { MeshRenderer renderer = component.GetComponent<MeshRenderer>(); if(renderer != null) { renderer.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.ShadowsOnly; component.gameObject.layer = LayerMask.NameToLayer("IgnorePlayerRaycast"); component.IsHidden = true; } Transform [] objects1 = component.transform.GetComponentsInChildren<Transform>(); foreach(Transform t in objects1) { renderer = t.GetComponent<MeshRenderer>(); if(renderer != null && renderer.gameObject != component.gameObject) { //renderer.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.ShadowsOnly; renderer.gameObject.layer = LayerMask.NameToLayer("HiddenObjects"); } Transform [] objects2 = t.transform.GetComponentsInChildren<Transform>(); foreach(Transform t2 in objects2) { renderer = t2.GetComponent<MeshRenderer>(); if(renderer != null && renderer.gameObject != component.gameObject) { //renderer.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.ShadowsOnly; renderer.gameObject.layer = LayerMask.NameToLayer("HiddenObjects"); } } } }
public Entity ReplaceBuildingAfterTOChange(Entity building) { BuildingComponent buildingComponent = building.Get <BuildingComponent>(); Building buildingTO = buildingComponent.BuildingTO; BoardItemComponent boardItemComponent = building.Get <BoardItemComponent>(); BoardItem <Entity> boardItem = boardItemComponent.BoardItem; BoardCell <Entity> currentCell = boardItem.CurrentCell; int x = currentCell.X; int z = currentCell.Z; EntityFactory entityFactory = Service.Get <EntityFactory>(); PostBattleRepairController postBattleRepairController = Service.Get <PostBattleRepairController>(); if (postBattleRepairController.IsEntityInRepair(building)) { postBattleRepairController.RemoveExistingRepair(building); } Entity entity = entityFactory.CreateBuildingEntity(buildingTO, true, true, true); Service.Get <CurrencyEffects>().TransferEffects(building, entity); Service.Get <MobilizationEffectsManager>().TransferEffects(building, entity); string uid = buildingTO.Uid; buildingTO.Uid = buildingComponent.BuildingType.Uid; entityFactory.DestroyEntity(building, true, true); buildingTO.Uid = uid; Service.Get <WorldController>().AddBuildingHelper(entity, x, z, true); Service.Get <EventManager>().SendEvent(EventId.BuildingReplaced, entity); return(entity); }
private void FinishContract(object result, object cookie) { if (this.activeContract == null || result == null) { return; } int crystalCostToFinishContract = ContractUtils.GetCrystalCostToFinishContract(this.activeContract); if (!GameUtils.SpendCrystals(crystalCostToFinishContract)) { return; } Service.ISupportController.BuyOutCurrentBuildingContract(this.selectedBuilding, true); BuildingComponent buildingComp = this.selectedBuilding.BuildingComp; if (buildingComp != null) { BuildingTypeVO buildingType = buildingComp.BuildingType; if (buildingType != null) { int currencyAmount = -crystalCostToFinishContract; string itemType = StringUtils.ToLowerCaseUnderscoreSeperated(buildingType.Type.ToString()); string buildingID = buildingType.BuildingID; int itemCount = 1; string type = "speed_up_upgrade"; string subType = "equipment"; Service.DMOAnalyticsController.LogInAppCurrencyAction(currencyAmount, itemType, buildingID, itemCount, type, subType); } } this.CloseFromResearchScreen(); }
public void NotifyHidingComponent(BuildingComponent component, float playerY) { if(component != null && playerY < component.YMin && !component.IsHidden) { HideComponent(component); } //reveal or hide other components foreach(BuildingComponent c in Components) { //Debug.Log("Checking building revealing component " + c.name); if(playerY > c.YMin && c.IsHidden) { RevealComponent(c); } else if(playerY < c.YMin && !c.IsHidden) { HideComponent(c); } } _revealTimer = 0; _active = true; }
public SmartEntity ReplaceBuildingAfterTOChange(SmartEntity building) { BuildingComponent buildingComp = building.BuildingComp; Building buildingTO = buildingComp.BuildingTO; BoardItemComponent boardItemComp = building.BoardItemComp; BoardItem boardItem = boardItemComp.BoardItem; BoardCell currentCell = boardItem.CurrentCell; int x = currentCell.X; int z = currentCell.Z; EntityFactory entityFactory = Service.EntityFactory; PostBattleRepairController postBattleRepairController = Service.PostBattleRepairController; if (postBattleRepairController.IsEntityInRepair(building)) { postBattleRepairController.RemoveExistingRepair(building); } SmartEntity smartEntity = entityFactory.CreateBuildingEntity(buildingTO, true, true, true); Service.CurrencyEffects.TransferEffects(building, smartEntity); Service.MobilizationEffectsManager.TransferEffects(building, smartEntity); string uid = buildingTO.Uid; buildingTO.Uid = buildingComp.BuildingType.Uid; entityFactory.DestroyEntity(building, true, true); buildingTO.Uid = uid; Service.WorldController.AddBuildingHelper(smartEntity, x, z, true); Service.EventManager.SendEvent(EventId.BuildingReplaced, smartEntity); return(smartEntity); }
private BoardCell <Entity> CanConnect(Entity wall) { if (wall == null) { return(null); } BuildingComponent buildingComponent = wall.Get <BuildingComponent>(); if (buildingComponent == null) { return(null); } BuildingTypeVO buildingType = buildingComponent.BuildingType; if (buildingType == null) { return(null); } if (buildingType.Connectors == null) { return(null); } BoardItemComponent boardItemComponent = wall.Get <BoardItemComponent>(); if (boardItemComponent == null) { return(null); } return(boardItemComponent.BoardItem.CurrentCell); }
private void StashAllMovedBuildings() { List <SmartEntity> buildingListByType = Service.BuildingLookupController.GetBuildingListByType(BuildingType.Any); int i = 0; int count = buildingListByType.Count; while (i < count) { SmartEntity smartEntity = buildingListByType[i]; BuildingComponent buildingComp = smartEntity.BuildingComp; Building buildingTO = buildingComp.BuildingTO; if (buildingComp.BuildingType.Type != BuildingType.Clearable) { if (!this.IsBuildingStashed(smartEntity)) { string key = buildingTO.Key; Position position = this.lastSavedMap.GetPosition(key); if (position == null) { Service.Logger.Error("BLT: Old Building position for " + key + " not found!"); } else if (this.HasBuildingMoved(buildingTO, position)) { this.StashBuilding(smartEntity); } } } i++; } }
public void UpdateBuildingHighlightForPerks(Entity building) { if (building == null) { return; } bool flag = ContractUtils.IsBuildingUpgrading(building); bool flag2 = ContractUtils.IsBuildingConstructing(building); if (flag2 | flag) { return; } PerkManager perkManager = Service.Get <PerkManager>(); IState currentState = Service.Get <GameStateMachine>().CurrentState; BuildingComponent buildingComp = ((SmartEntity)building).BuildingComp; if ((currentState is ApplicationLoadState || currentState is HomeState || currentState is EditBaseState || currentState is BaseLayoutToolState) && buildingComp != null) { BuildingTypeVO buildingType = buildingComp.BuildingType; if (perkManager.IsPerkAppliedToBuilding(buildingType)) { this.entityShaderSwapper.HighlightForPerk(building); return; } bool flag3 = this.entityShaderSwapper.ResetToOriginal(building); if (flag3) { Service.Get <EventManager>().SendEvent(EventId.ShaderResetOnEntity, building); } } }
private void ShowScaffold(Entity building) { if (!this.viewObjects.ContainsKey(building)) { SmartEntity smartEntity = (SmartEntity)building; BuildingComponent buildingComp = smartEntity.BuildingComp; if (buildingComp == null) { return; } BuildingTypeVO buildingType = buildingComp.BuildingType; FactionType faction = buildingType.Faction; string text; if (faction != FactionType.Empire) { text = "rbl"; } else { text = "emp"; } if (text != null) { List <string> list = new List <string>(); List <object> list2 = new List <object>(); List <AssetHandle> list3 = new List <AssetHandle>(); int num = Math.Min(buildingType.SizeY, 6); for (int i = 2; i <= num; i++) { string item = string.Format("scaffold_{0}-mod_{1}", text, i); list.Add(item); list2.Add(new ScaffoldingData(building, num - i, false)); list3.Add(AssetHandle.Invalid); } int num2 = Math.Min(buildingType.SizeX, 6); for (int j = 2; j <= num2; j++) { string item2 = string.Format("scaffold_{0}-mod_{1}", text, j); list.Add(item2); list2.Add(new ScaffoldingData(building, num2 - j, true)); list3.Add(AssetHandle.Invalid); } if (list.Count > 0) { Service.AssetManager.MultiLoad(list3, list, new AssetSuccessDelegate(this.OnAssetSuccess), new AssetFailureDelegate(this.OnAssetFailure), list2, null, null); int k = 0; int count = list2.Count; while (k < count) { ScaffoldingData scaffoldingData = (ScaffoldingData)list2[k]; scaffoldingData.Handle = list3[k]; k++; } List <ScaffoldingData> value = new List <ScaffoldingData>(); this.viewObjects.Add(building, value); } } } }
public CollectButton(Entity building) { this.building = building; BuildingComponent buildingComponent = building.Get <BuildingComponent>(); this.assetName = GameUtils.GetSingleCurrencyItemAssetName(buildingComponent.BuildingType.Currency); this.visible = false; }
private void OnAssetSuccess(object asset, object cookie) { GameObject gameObject = (GameObject)asset; ScaffoldingData scaffoldingData = (ScaffoldingData)cookie; scaffoldingData.GameObj = gameObject; Entity building = scaffoldingData.Building; if (this.viewObjects.ContainsKey(building)) { int offset = scaffoldingData.Offset; bool flip = scaffoldingData.Flip; gameObject.name = string.Format("Scaffold_{0}_{1}{2}", new object[] { building.ID, flip ? "L" : "R", offset }); BuildingComponent buildingComponent = building.Get <BuildingComponent>(); BuildingTypeVO buildingType = buildingComponent.BuildingType; Transform transform = gameObject.transform; float num; float num2; if (flip) { num = (float)(-(float)offset); num2 = 0f; transform.localScale = new Vector3(-1f, 1f, 1f); transform.rotation = Quaternion.AngleAxis(-180f, Vector3.up); } else { num = 0f; num2 = (float)(-(float)offset); transform.rotation = Quaternion.AngleAxis(-90f, Vector3.up); } transform.localPosition = new Vector3((num + (float)buildingType.SizeX * 0.5f) * 3f, 0f, (num2 + (float)buildingType.SizeY * 0.5f) * 3f); List <ScaffoldingData> list = this.viewObjects[building]; list.Add(scaffoldingData); GameObjectViewComponent gameObjectViewComponent = building.Get <GameObjectViewComponent>(); if (gameObjectViewComponent != null) { this.AttachToView(gameObject, gameObjectViewComponent); return; } gameObject.SetActive(false); if (!this.waitingForView.Contains(building)) { this.waitingForView.Add(building); return; } } else { this.UnloadScaffold(scaffoldingData); } }
private bool WillCrushNearTarget(SmartEntity troop, SmartEntity target) { if (!troop.TroopComp.TroopType.CrushesWalls) { return(false); } BuildingComponent buildingComp = target.BuildingComp; return(buildingComp != null && buildingComp.BuildingType.Type == BuildingType.Wall); }
private void UpdateFillStateMeshes(GameObject fillStateInstance, Entity parentEntity, float currentFullnessPercentage) { BuildingComponent buildingComponent = parentEntity.Get <BuildingComponent>(); BuildingTypeVO buildingType = buildingComponent.BuildingType; float collectNotificationPercentage = this.GetCollectNotificationPercentage(buildingType); this.UpdateFillStateMesh(fillStateInstance, collectNotificationPercentage, currentFullnessPercentage, "fillStateMesh1"); this.UpdateFillStateMesh(fillStateInstance, 0.5f, currentFullnessPercentage, "fillStateMesh2"); this.UpdateFillStateMesh(fillStateInstance, 0.99f, currentFullnessPercentage, "fillStateMesh3"); }
private bool WillCrushNearTarget(SmartEntity troop, SmartEntity target) { if (!TroopController.CanEntityCrushWalls(troop)) { return(false); } BuildingComponent buildingComp = target.BuildingComp; return(buildingComp != null && buildingComp.BuildingType.Type == BuildingType.Wall); }
private void btnAddComponent_Click(object sender, EventArgs e) { BuildingComponent newComp = new BuildingComponent(); newComp.Name = txtCompName.Text; Boolean found = false; foreach(BuildingComponent comp in lbExistingComps.Items) { if(comp.Name.Equals(newComp.Name)) { MessageBox.Show("Component already exists."); found = true; break; } } if (!found) lbExistingComps.Items.Add(newComp); lbExistingComps.ClearSelected(); txtCompName.Clear(); }
private void btnAdd_Click(object sender, EventArgs e) { Boolean missing = false; if (String.IsNullOrEmpty(txtCompName.Text)) { MessageBox.Show("Please enter a component name."); return; } BuildingComponent comp = null; if (!chkCombineComps.Checked) missing = cboFoundInModel.SelectedIndex < 0; else { if (String.IsNullOrEmpty(txtCombinedCompName.Text)) { MessageBox.Show("Please enter a name for the combined components."); return; } if (String.IsNullOrEmpty(txtCombinedCompName.Text)) { MessageBox.Show("Please enter a category for the combined components."); return; } missing = String.IsNullOrEmpty(txtCombinedArea.Text) || String.IsNullOrEmpty(txtCombinedVolume.Text); } if (missing) { using (MissingCompDialog inputDlg = new MissingCompDialog()) { inputDlg.ShowDialog(); if (inputDlg.DialogResult == DialogResult.OK) { comp = new BuildingComponent(); comp.Name = txtCompName.Text.Trim(); comp.Description = txtCompDesc.Text.Trim(); comp.Category = inputDlg.Text; comp.Area = inputDlg.Area; comp.Volume = inputDlg.Volume; comp.Category = inputDlg.Category; Assembly assoc = new Assembly(); assoc.AssemblyName = inputDlg.CompName; assoc.Category = inputDlg.Category; assoc.Area = inputDlg.Area; assoc.Volume = inputDlg.Volume; assoc.AssemblyCode = inputDlg.Code; cboFoundInModel.Items.Add(assoc); List<Assembly> list = new List<Assembly>(); foreach (Assembly assem in cboFoundInModel.Items) list.Add(assem); if (list.Count > 0) calculateAreas_Volumes(list); } } } else { if (!chkCombineComps.Checked) { comp = new BuildingComponent(); Assembly assoc = (Assembly)cboFoundInModel.SelectedItem; comp.Name = txtCompName.Text; comp.Description = txtCompDesc.Text.Trim(); comp.Category = txtCategory.Text; comp.Area = assoc.Area; comp.Volume = assoc.Volume; } else { comp = new BuildingComponent(); comp.Name = txtCompName.Text; comp.Description = txtCompDesc.Text.Trim(); comp.Category = txtCombinedCategory.Text; comp.Area = Double.Parse(txtCombinedArea.Text); comp.Volume = Double.Parse(txtCombinedVolume.Text); } } if (comp == null) return; if (!lbComponents.Items.Contains(comp)) lbComponents.Items.Add(comp); else MessageBox.Show("Component already exists."); ClearControls(); clearComponentInfo(); txtCombinedCompName.Text = ""; txtCombinedCategory.Text = ""; txtCombinedArea.Text = ""; txtCombinedVolume.Text = ""; }
/// <summary> /// For each distinct assembly type, the total area and volume are calculated. /// Duplicates are dropped.The areas and volumes are stored for later use. /// </summary> /// <param name="assemblies">List of assemblies, possibly containing duplicates. </param> private void calculateAreas_Volumes(List<Assembly> assemblies) { areas.Clear(); volumes.Clear(); comps.Clear(); this.Assemblies.Clear(); for (int i = 0; i < assemblies.Count(); i++) { Assembly assem = assemblies[i]; String code = assem.AssemblyCode; if (areas.ContainsKey(code)) { double area = areas[assem.AssemblyCode]; areas[code] = area + assem.Area; Assemblies[code].Area = areas[code]; } else { areas.Add(code, assem.Area); BuildingComponent bComp = new BuildingComponent(); bComp.Name = assem.AssemblyName; bComp.Description = assem.Description; bComp.Category = assem.Category; Assemblies.Add(code, (Assembly)assem.Clone()); comps.Add(code, bComp); } if (volumes.ContainsKey(code)) { double volume = volumes[assem.AssemblyCode]; volumes[code] = volume + assem.Volume; Assemblies[code].Volume = volumes[code]; } else volumes.Add(code, assem.Volume); } }
private void RevealComponent(BuildingComponent component) { MeshRenderer renderer = component.GetComponent<MeshRenderer>(); if(renderer != null) { renderer.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.On; component.gameObject.layer = LayerMask.NameToLayer("BuildingComponent"); component.IsHidden = false; } Transform [] objects1 = component.transform.GetComponentsInChildren<Transform>(); foreach(Transform t in objects1) { renderer = t.GetComponent<MeshRenderer>(); if(renderer != null && renderer.gameObject != component.gameObject) { //renderer.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.On; renderer.gameObject.layer = LayerMask.NameToLayer("Default"); } Transform [] objects2 = t.transform.GetComponentsInChildren<Transform>(); foreach(Transform t2 in objects2) { renderer = t2.GetComponent<MeshRenderer>(); if(renderer != null && renderer.gameObject != component.gameObject) { //renderer.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.On; renderer.gameObject.layer = LayerMask.NameToLayer("Default"); } } } }