Skip to content

Commit

Permalink
fix most of those bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
GrahamKracker committed Jun 8, 2023
1 parent 9adc1a0 commit c5565e6
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 46 deletions.
13 changes: 2 additions & 11 deletions LATEST.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,2 @@
Initial Alpha Release
- still in early alpha
- does not work on coop
- merging algorithm itself may not produce predictable results, especially dealing with camos and lead popping power
- should be fully compatible with modded towers/ modded towersets, as well as paths++
- heroes are experimental and are not balanced at all in terms of cost
- wizard lord pheonix loves to spawn infinite pheonixs
- geraldo doesnt work
- merged towers should be saved within the map save

Big thanks to @doombubbles for his ultimate crosspathing algorithm, which was used here
Fixed an issue with tower saving
Fixed paths-plus-plus as being a dependency
73 changes: 39 additions & 34 deletions Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public partial class Main : BloonsTD6Mod

private static float totalcost;

public static bool HasPathsPlusPlus = ModHelper.HasMod("PathsPlusPlus");
public static bool HasPathsPlusPlus => ModHelper.HasMod("PathsPlusPlus");
private static ModHelperScrollPanel towersetselect;
private static ModHelperScrollPanel pathselect;
private static ModHelperPanel finalselect;
Expand Down Expand Up @@ -167,46 +167,48 @@ private static void SetUpTowerButtons()

public static void DestroyPathsPlusPlusSliders()
{
pathselect.ScrollRect.StopMovement();
pathselect.ScrollRect.SetNormalizedPosition(.5f, 0);
pathselect.ScrollRect.enabled = false;
foreach (var slider in Pathsplusplussliders.Values)
Object.Destroy(slider.transform.parent.gameObject);
Pathsplusplussliders.Clear();
if (HasPathsPlusPlus)
{
pathselect.ScrollRect.StopMovement();
pathselect.ScrollRect.SetNormalizedPosition(.5f, 0);
pathselect.ScrollRect.enabled = false;
foreach (var slider in Pathsplusplussliders.Values)
Object.Destroy(slider.transform.parent.gameObject);
Pathsplusplussliders.Clear();
}
}

public static void GeneratePathsPlusPlusSliders(string baseId)
{
if (!HasPathsPlusPlus) return;

DestroyPathsPlusPlusSliders();

if (HasPathsPlusPlus)
foreach (var path in GetContent<PathPlusPlus>().Where(p => p.Tower == baseId))
{
foreach (var path in GetContent<PathPlusPlus>().Where(p => p.Tower == baseId))
{
var i = path.Path + 1;
var currentpath = pathselect.AddPanel(new Info($"Path{i}", 290, 300), VanillaSprites.BrownInsertPanel);
currentpath.AddText(new Info($"Path{i}Text", 290, 100, new Vector2(.5f, .85f)), $"Path {i}", 50f);

var slider = currentpath.AddSlider(new Info($"Path{i}Input", 180, 60, new Vector2(.5f, .35f)), 0, 0, 5,
1,
new Vector2(85, 85), new Action<float>(
tier =>
{
selectedtower = InGame.instance.GetGameModel().GetTowerModel(selectedBaseID,
(int)Pathsliders[0].CurrentValue, (int)Pathsliders[1].CurrentValue,
(int)Pathsliders[2].CurrentValue);
ApplyPathPlusPlus(path,(int)tier, ref selectedtower);
UpdateBottomBar();
}
));
var i = path.Path + 1;
var currentpath = pathselect.AddPanel(new Info($"Path{i}", 290, 300), VanillaSprites.BrownInsertPanel);
currentpath.AddText(new Info($"Path{i}Text", 290, 100, new Vector2(.5f, .85f)), $"Path {i}", 50f);

Object.Destroy(slider.DefaultNotch.gameObject);
pathselect.AddScrollContent(currentpath);
Pathsplusplussliders[i] = slider;
var slider = currentpath.AddSlider(new Info($"Path{i}Input", 180, 60, new Vector2(.5f, .35f)), 0, 0, 5,
1,
new Vector2(85, 85), new Action<float>(
tier =>
{
selectedtower = InGame.instance.GetGameModel().GetTowerModel(selectedBaseID,
(int)Pathsliders[0].CurrentValue, (int)Pathsliders[1].CurrentValue,
(int)Pathsliders[2].CurrentValue);
ApplyPathPlusPlus(path,(int)tier, ref selectedtower);
UpdateBottomBar();
}
));

Object.Destroy(slider.DefaultNotch.gameObject);
pathselect.AddScrollContent(currentpath);
Pathsplusplussliders[i] = slider;

pathselect.ScrollRect.enabled = true;
pathselect.ScrollRect.horizontalNormalizedPosition = 0f;
}
pathselect.ScrollRect.enabled = true;
pathselect.ScrollRect.horizontalNormalizedPosition = 0f;
}
}

Expand Down Expand Up @@ -285,7 +287,10 @@ private static void CreateTowerSetButton(string name, string icon, string backgr
var towerpanel = towersetpanel.AddButton(new Info(tower.name, width, 290),
background, new Action(() =>
{
GeneratePathsPlusPlusSliders(tower.baseId);
if (HasPathsPlusPlus)
{
GeneratePathsPlusPlusSliders(tower.baseId);
}

if (selectedBaseID == tower.name)
{
Expand Down Expand Up @@ -500,7 +505,7 @@ private static void HideAllSelected()

public override void OnTowerSaved(Tower tower, TowerSaveDataModel saveData)
{
var OCMutator = tower.GetMutator("OC").TryCast<SupportRemoveFilterOutTag.MutatorTower>();
var OCMutator = tower.GetMutator("OC")?.TryCast<SupportRemoveFilterOutTag.MutatorTower>();
if (OCMutator != null)
saveData.metaData["OC"] = OCMutator.removeScriptsWithSupportMutatorId;
}
Expand Down
2 changes: 1 addition & 1 deletion ModHelperData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ public static class ModHelperData
{
public const string Name = "OmegaCrosspathing";
public const string Description = "Allows you to merge towers together, should be fully compatible with ultimate crosspathing, custom towers, custom heroes, and custom towersets. Thanks to doombubbles for the ultimate crosspathing algorithm, which was used here.";
public const string Version = "0.0.1";
public const string Version = "0.0.2";
public const string RepoOwner = "GrahamKracker";
public const string RepoName = "OmegaCrosspathing";
public const string WorksOnVersion = "37";
Expand Down

0 comments on commit c5565e6

Please sign in to comment.