public bQueueItem(GameEntityTypeData TypeDoingTheBuilding, BuildQueueItem Item, int ItemIndex) : base(Mode.Queue) { this.TypeDoingTheBuilding = TypeDoingTheBuilding; this.Item = Item; this.ItemIndex = ItemIndex; }
private bool TryBuildNewComponent(out AiMoveDecision move) { var queue = new Queue <BuildQueueItem>(); var used = new Dictionary <int, BuildQueueItem>(); foreach (var mineV in graph.GetNotOwnedMines(state.punter)) { var queueItem = new BuildQueueItem { CurrentVertex = mineV, SourceMine = mineV, FirstEdge = null }; queue.Enqueue(queueItem); used.Add(mineV.Id, queueItem); } while (queue.Count > 0) { var current = queue.Dequeue(); foreach (var edge in current.CurrentVertex.Edges.Where(x => x.CanBeOwnedBy(state.punter, allowToUseOptions))) { var next = graph.Vertexes[edge.To]; BuildQueueItem prev; if (used.TryGetValue(next.Id, out prev)) { if (prev.SourceMine != current.SourceMine) { var bestMine = SelectBestMine(prev.SourceMine, current.SourceMine); if (bestMine == prev.SourceMine) { var edge1 = prev.FirstEdge ?? edge; move = AiMoveDecision.ClaimOrOption(edge1, state.punter, allowToUseOptions); return(true); } if (bestMine == current.SourceMine) { var edge1 = current.FirstEdge ?? edge; move = AiMoveDecision.ClaimOrOption(edge1, state.punter, allowToUseOptions); return(true); } } } else { var queueItem = new BuildQueueItem { CurrentVertex = next, SourceMine = current.SourceMine, FirstEdge = current.FirstEdge ?? edge }; queue.Enqueue(queueItem); used.Add(next.Id, queueItem); } } } move = null; return(false); }
public void BuildQueueItemShouldDeserialize() { var original = new BuildQueueItem(BuildMenuItem.ScoutShip); var restored = SerializeAndDeserialize(original); restored.Should().BeEquivalentTo(original); }
void BuildAndroid(BuildQueueItem buildQueueItem) { BuildPlayerOptions buildPlayerOptions = new BuildPlayerOptions(); // Set target Android buildPlayerOptions.target = BuildTarget.Android; // Get all scenes paths that are added to build settings buildPlayerOptions.scenes = EditorBuildSettings.scenes.Select(scene => scene.path).ToArray(); // Set Graphics API switch ((int)(buildQueueItem.BuildOptions as AndroidBuildOptions).GraphicsAPI) { case (int)CustomAndroidGraphicsAPI.OpenGLES3: PlayerSettings.SetGraphicsAPIs(BuildTarget.Android, new[] { GraphicsDeviceType.OpenGLES3 }); break; case (int)CustomAndroidGraphicsAPI.Vulkan: PlayerSettings.SetGraphicsAPIs(BuildTarget.Android, new[] { GraphicsDeviceType.Vulkan }); break; default: throw new Exception("Unknown Graphics API selected"); } // Set Scripting backend switch ((int)(buildQueueItem.BuildOptions as AndroidBuildOptions).ScriptingBackend) { case (int)CustomAndroidScriptingBackend.Mono: PlayerSettings.SetScriptingBackend(BuildTargetGroup.Android, ScriptingImplementation.Mono2x); break; case (int)CustomAndroidScriptingBackend.IL2CPP: PlayerSettings.SetScriptingBackend(BuildTargetGroup.Android, ScriptingImplementation.IL2CPP); break; default: throw new Exception("Unknown scripting backend selected"); } // Set installation path buildPlayerOptions.locationPathName = "Builds/" + Application.productName + "_" + PlayerSettings.GetScriptingBackend(BuildTargetGroup.Android) + "_" + PlayerSettings.GetGraphicsAPIs(BuildTarget.Android)[0] + ".apk"; // Build player BuildReport report = BuildPipeline.BuildPlayer(buildPlayerOptions); BuildSummary summary = report.summary; if (summary.result == BuildResult.Succeeded) { Debug.Log("Build succeeded: " + summary.totalSize + " bytes\nBuild location: " + buildPlayerOptions.locationPathName); } if (summary.result == BuildResult.Failed) { throw new Exception("Build failed"); } }
public override void OnUpdate() { WorldSide localSide = World_AIW2.Instance.GetLocalPlayerSide(); if (localSide == null) { return; } ArcenUI_ImageButtonSet elementAsType = (ArcenUI_ImageButtonSet)Element; if (Window_InGameBuildTabMenu.Instance.EntityChangedSinceLastButtonSetUpdate_Queue) { elementAsType.ClearButtons(); GameEntity entity = World_AIW2.Instance.GetEntityByID(Window_InGameBuildTabMenu.Instance.EntityID); if (entity != null) { float aspectRatioAdjustedButtonWidth = this.Element.ButtonWidth; float aspectRatioAdjustedButtonHeight = this.Element.ButtonHeight; if (ArcenUI.Instance.PixelsPerPercent_X != ArcenUI.Instance.PixelsPerPercent_Y) { aspectRatioAdjustedButtonWidth *= ArcenUI.Instance.PixelsPerPercent_Y / ArcenUI.Instance.PixelsPerPercent_X; } float runningX = 0; if (entity.BuildQueue != null) { List <BuildQueueItem> items = entity.BuildQueue.Items; for (int x = 0; x < items.Count; x++) { BuildQueueItem item = items[x]; bQueueItem newButtonController = new bQueueItem(entity.TypeData, item, x); Vector2 offset; offset.x = runningX; offset.y = 0; Vector2 size; size.x = aspectRatioAdjustedButtonWidth; size.y = aspectRatioAdjustedButtonHeight; elementAsType.AddImageButton(newButtonController, size, offset); runningX += size.x; } } } elementAsType.ActuallyPutItemsBackInPoolThatAreStillCleared(); Window_InGameBuildTabMenu.Instance.EntityChangedSinceLastButtonSetUpdate_Queue = false; Window_InGameBuildTabMenu.Instance.MenuIndexChangedSinceLastButtonSetUpdate = true; } }
void BuildIOS(BuildQueueItem buildQueueItem) { BuildPlayerOptions buildPlayerOptions = new BuildPlayerOptions(); // Set target iOS buildPlayerOptions.target = BuildTarget.iOS; // Get all scenes paths that are added to build settings buildPlayerOptions.scenes = EditorBuildSettings.scenes.Select(scene => scene.path).ToArray(); // Set Stripping level switch ((int)(buildQueueItem.BuildOptions as IOSBuildOptions).StrippingLevel) { case (int)CustomiOSStrippingLevel.Low: PlayerSettings.SetManagedStrippingLevel(BuildTargetGroup.iOS, ManagedStrippingLevel.Low); break; case (int)CustomiOSStrippingLevel.Medium: PlayerSettings.SetManagedStrippingLevel(BuildTargetGroup.iOS, ManagedStrippingLevel.Medium); break; case (int)CustomiOSStrippingLevel.High: PlayerSettings.SetManagedStrippingLevel(BuildTargetGroup.iOS, ManagedStrippingLevel.High); break; default: throw new Exception("Unknown Stripping level selected"); } // Set installation path buildPlayerOptions.locationPathName = "Builds/" + Application.productName + "_" + PlayerSettings.GetManagedStrippingLevel(BuildTargetGroup.iOS); // Build player BuildReport report = BuildPipeline.BuildPlayer(buildPlayerOptions); BuildSummary summary = report.summary; if (summary.result == BuildResult.Succeeded) { Debug.Log("Build succeeded: " + summary.totalSize + " bytes\nBuild location: " + buildPlayerOptions.locationPathName); } if (summary.result == BuildResult.Failed) { throw new Exception("Build failed"); } }
public void SetBuildQueueItem(BuildQueueItem Value) { Item = Value; }
public override void UpdateContent(ArcenUIWrapperedUnityImage Image, ArcenUI_Image.SubImageGroup SubImages, SubTextGroup SubTexts) { GameEntityTypeData typeData = this.TypeToBuild; if (typeData == null) { return; } WorldSide localSide = World_AIW2.Instance.GetLocalPlayerSide(); Planet planet = Engine_AIW2.Instance.NonSim_GetPlanetBeingCurrentlyViewed(); CombatSide localCombatSide = planet.Combat.GetSideForWorldSide(localSide); int debugStage = -1; try { debugStage = 1; debugStage = 2; SubImages[INDEX_ICON_NO_FLAIR].WrapperedImage.UpdateWith(null, true); SubImages[INDEX_ICON_FLAIR_ONLY].WrapperedImage.UpdateWith(typeData.GUISprite_Icon_White, true); // uncomment if you want a crazy experiment with icons varying in size over time //float size = ( World_AIW2.Instance.GameSecond * 10 ) % 100; //if ( size < 1 ) // size = 1; //SubImages[INDEX_ICON_FLAIR_ONLY].WrapperedImage.SetSize( size, size / 2 ); // uncomment if you want to try vertically centering non-flair icons instead of leaving the gap at the bottom //if ( typeData.GUISprite_Flair == null ) // SubImages[INDEX_ICON_FLAIR_ONLY].WrapperedImage.SetOffset( 0, 5 ); debugStage = 4; SubImages[INDEX_FLAIR].WrapperedImage.UpdateWith(typeData.GUISprite_Flair, true); debugStage = 5; bool showFuel = typeData.BalanceStats.SquadFuelConsumption > 0 && localSide.NetFuel < typeData.BalanceStats.SquadFuelConsumption; SubImages[INDEX_FUEL].WrapperedImage.UpdateToShowOrHide(showFuel); debugStage = 6; bool showPower = typeData.BalanceStats.SquadPowerConsumption > 0 && localCombatSide.NetPower < typeData.BalanceStats.SquadPowerConsumption; SubImages[INDEX_POWER].WrapperedImage.UpdateToShowOrHide(showPower); debugStage = 7; bool showScience = false; bool showLocked = false; bool showUnlocked = false; if (this.ButtonMode == Mode.Tech) { if (typeData.TechPrereq == null) { // shouldn't really be on the tech menu anyway } else { if (localSide.GetHasResearched(typeData.TechPrereq)) { showUnlocked = true; } else if (localSide.GetCanResearch(typeData.TechPrereq, true, false) != ArcenRejectionReason.Unknown) { showLocked = true; } else if (localSide.GetCanResearch(typeData.TechPrereq, false, false) != ArcenRejectionReason.Unknown) { showScience = true; } } } SubImages[INDEX_SCIENCE].WrapperedImage.UpdateToShowOrHide(showScience); //uncomment if you want a crazy experiemnt replacing this icon with a fuel icon //SubImages[INDEX_SCIENCE].WrapperedImage.SetBundleAndPathInBundle( "arcenui", "assets/icons/officialgui/resources/fuel.png" ); SubImages[INDEX_LOCKED].WrapperedImage.UpdateToShowOrHide(showLocked); Image.SetColor(showLocked ? ColorMath.LightGray : ColorMath.White); SubImages[INDEX_UNLOCKED].WrapperedImage.UpdateToShowOrHide(showUnlocked); debugStage = 8; bool showActiveKeyboardColumnIndicator = false; if (this.ButtonMode == Mode.Build) { showActiveKeyboardColumnIndicator = this.ColumnIndex == Window_InGameBuildTypeIconMenu.Instance.CurrentTypeIndex; } else if (this.ButtonMode == Mode.Tech) { showActiveKeyboardColumnIndicator = this.ColumnIndex == Window_InGameTechTypeIconMenu.Instance.CurrentTypeIndex; } SubImages[INDEX_ACTIVE_KEYBOARD_COLUMN].WrapperedImage.UpdateToShowOrHide(showActiveKeyboardColumnIndicator); debugStage = 15; int markLevel = typeData.Balance_MarkLevel.Ordinal; if (markLevel < 0 || markLevel > 5) { markLevel = 0; } SubImages[INDEX_MARK_LEVEL].WrapperedImage.UpdateWith(markLevel <= 0 ? null : Window_InGameOutlineSidebar.Sprite_MarkLevels[markLevel], true); } catch (Exception e) { ArcenDebugging.ArcenDebugLog("Exception in UpdateContent (image) at stage " + debugStage + ":" + e.ToString(), Verbosity.ShowAsError); } debugStage = -1; try { debugStage = 1; ArcenUIWrapperedTMProText text = SubTexts[TEXT_INDEX_UPPER_LEFT].Text; debugStage = 2; ArcenDoubleCharacterBuffer buffer = text.StartWritingToBuffer(); if (typeData != null) { switch (this.ButtonMode) { case Mode.Build: case Mode.Queue: if (planet != null) { int remainingCap = localCombatSide.GetRemainingCap(typeData); text.SetFontSize(12); buffer.Add(remainingCap); if (remainingCap <= 0) { text.SetColor(ColorMath.LightRed); } else { text.SetColor(ColorMath.White); } } break; case Mode.Tech: if (typeData.TechPrereq == null) { break; } if (localSide.GetHasResearched(typeData.TechPrereq)) { break; } int cost = typeData.TechPrereq.ScienceCost; buffer.Add(cost); if (cost > localSide.StoredScience) { text.SetColor(ColorMath.LightRed); } else { text.SetColor(ColorMath.White); } break; } } text.FinishWritingToBuffer(); debugStage = 3; text = SubTexts[TEXT_INDEX_ABOVE_BUTTON].Text; debugStage = 4; buffer = text.StartWritingToBuffer(); if (this.ButtonMode == Mode.Queue) { GameEntity builder = null; Engine_AIW2.Instance.DoForSelected(SelectionCommandScope.CurrentPlanet_UnlessViewingGalaxy, delegate(GameEntity selected) { if (selected.TypeData != this.TypeDoingTheBuilding) { return(DelReturn.Continue); } if (builder != null) { // only show time display when there's only one builder, otherwise it's not clear what should be shown builder = null; return(DelReturn.Break); } builder = selected; return(DelReturn.Continue); }); debugStage = 5; if (builder != null && builder.BuildQueue != null) { BuildQueueItem item = builder.BuildQueue.GetQueueItemFor(typeData); if (item != null) { bool showTimer = item.MetalSpentOnCurrentIteration > 0 && item.NumberBuiltThisLoop < item.NumberToBuildEachLoop; if (showTimer) { FInt metalLeft = typeData.BalanceStats.SquadMetalCost - item.MetalSpentOnCurrentIteration; FInt metalRate = builder.TypeData.MetalFlows[MetalFlowPurpose.BuildingShipsInternally].EffectiveThroughput; if (metalLeft > 0 && metalRate > 0) { FInt secondsLeft = metalLeft / metalRate; buffer.Add(Engine_Universal.ToHoursAndMinutesString(secondsLeft.IntValue)); } } } } } debugStage = 6; text.FinishWritingToBuffer(); } catch (Exception e) { ArcenDebugging.ArcenDebugLog("Exception in UpdateContent (text) at stage " + debugStage + ":" + e.ToString(), Verbosity.ShowAsError); } }
public override void OnUpdate() { WorldSide localSide = World_AIW2.Instance.GetLocalSide(); if (localSide == null) { return; } ArcenUI_ButtonSet elementAsType = (ArcenUI_ButtonSet)Element; Window_InGameBuildMenu windowController = (Window_InGameBuildMenu)Element.Window.Controller; if (windowController.EntityChangedSinceLastButtonSetUpdate_Queue) { elementAsType.ClearButtons(); GameEntity entity = World_AIW2.Instance.GetEntityByID(windowController.EntityID); if (entity != null) { float runningX = 0; { bTogglePause newButtonController = new bTogglePause(); Vector2 offset; offset.x = runningX; offset.y = 0; Vector2 size; size.x = elementAsType.ButtonWidth / 2; size.y = elementAsType.ButtonHeight; elementAsType.AddButton(newButtonController, size, offset); runningX += size.x; } { bToggleLoop newButtonController = new bToggleLoop(); Vector2 offset; offset.x = runningX; offset.y = 0; Vector2 size; size.x = elementAsType.ButtonWidth / 2; size.y = elementAsType.ButtonHeight; elementAsType.AddButton(newButtonController, size, offset); runningX += size.x; } if (entity.BuildQueue != null) { List <BuildQueueItem> items = entity.BuildQueue.Items; for (int x = 0; x < items.Count; x++) { BuildQueueItem item = items[x]; bQueueItem newButtonController = new bQueueItem(entity.TypeData, item, x); Vector2 offset; offset.x = runningX; offset.y = 0; Vector2 size; size.x = elementAsType.ButtonWidth; size.y = elementAsType.ButtonHeight; elementAsType.AddButton(newButtonController, size, offset); runningX += size.x; } } } elementAsType.ActuallyPutItemsBackInPoolThatAreStillCleared(); windowController.EntityChangedSinceLastButtonSetUpdate_Queue = false; windowController.MenuIndexChangedSinceLastButtonSetUpdate = true; } }