Skip to content

Commit 122e0ff

Browse files
stuffu
1 parent 22d1fb5 commit 122e0ff

26 files changed

Lines changed: 405 additions & 118 deletions

Assets/FortifiedDecal.png

54 KB
Loading

BloonFactory.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ public override void OnNewGameModel(GameModel result)
4040
try
4141
{
4242
var bloonModel = result.bloons.First(bl => bl.id == bloon.BloonTemplate.TemplateId);
43-
4443
MelonLogger.Msg($"Updating Existing BloonModel - {bloon.BloonTemplate.Name}");
4544

4645
bloon.ModifyExistingBloonModel(bloonModel, result.roundSet);

BloonFactory.csproj

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@
1717
<HintPath>..\..\SteamLibrary\steamapps\common\BloonsTD6\Mods\FactoryCore.dll</HintPath>
1818
</Reference>
1919
</ItemGroup>
20-
<ItemGroup>
21-
<Folder Include="Property\" />
22-
</ItemGroup>
2320

2421
<Import Project="..\btd6.targets" />
2522
</Project>

Categories/DisplayCategory.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ internal class DisplayCategory : Category
1212
{
1313
public override string Name => "Display";
1414

15-
public override Type[] Modules => [ typeof(SimpleDisplayModule) ];
15+
public override Type[] Modules => [ typeof(SimpleDisplayModule), typeof(DamageStateDisplayModule), typeof(BloonTextureModule), typeof(CustomTextureModule), typeof(DecalModule) ];
1616
}
1717
}

Categories/LogicCategory.cs

Lines changed: 0 additions & 17 deletions
This file was deleted.

CustomBloon.cs

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using BloonFactory.Modules;
22
using BloonFactory.Modules.Core;
3+
using BloonFactory.Modules.Display;
34
using BTD_Mod_Helper.Api;
45
using BTD_Mod_Helper.Api.Bloons;
56
using FactoryCore.API;
@@ -43,17 +44,33 @@ public void ModifyExistingBloonModel(BloonModel model, RoundSetModel roundset)
4344
BloonTemplate.LoadModules();
4445
foreach (var module in BloonTemplate.GetModulesOfType<BloonModule>())
4546
{
46-
MelonLogger.Msg("Processing module");
47-
module.currentModel = model;
48-
module.currentRoundSet = roundset;
49-
module.ProcessModule();
47+
try
48+
{
49+
MelonLogger.Msg("Processing module");
50+
module.currentModel = model;
51+
module.currentRoundSet = roundset;
52+
module.ProcessModule();
53+
}
54+
catch (Exception ex)
55+
{
56+
MelonLogger.Error(ex);
57+
}
5058
}
5159

5260
foreach (var module in BloonTemplate.GetModulesOfType<TriggerModule>())
5361
{
54-
module.currentModel = model;
55-
module.ProcessModule();
62+
try
63+
{
64+
module.currentModel = model;
65+
module.ProcessModule();
66+
}
67+
catch (Exception ex)
68+
{
69+
MelonLogger.Error(ex);
70+
}
5671
}
72+
73+
DamageStateDisplayModule.DamageStateFix(model);
5774
}
5875
public override IEnumerable<ModContent> Load()
5976
{

LinkTypes/BloonTexture.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using UnityEngine;
7+
8+
namespace BloonFactory.LinkTypes
9+
{
10+
internal class BloonTexture
11+
{
12+
public Texture2D texture;
13+
}
14+
}

ModHelperData.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@ namespace BloonFactory;
22

33
public static class ModHelperData
44
{
5-
public const string WorksOnVersion = "47.0";
5+
public const string WorksOnVersion = "50.1";
66
public const string Version = "1.0.0";
77
public const string Name = "BloonFactory";
88

9-
public const string Description = "An empty mod";
9+
public const string Description = "A mod for creating custom bloons";
1010

11-
public const string RepoOwner = ""; // TODO add your github username hero, also in the download url in README.md
12-
public const string RepoName = ""; // TODO add your repo name here, also in the download url in README.md
11+
public const string Author = "CommanderCat";
12+
public const string RepoOwner = "";
13+
public const string RepoName = "";
1314
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
using BTD_Mod_Helper.Api;
2+
using BTD_Mod_Helper.Api.Components;
3+
using BTD_Mod_Helper.Api.Enums;
4+
using BTD_Mod_Helper.Extensions;
5+
using FactoryCore.API;
6+
using FactoryCore.API.ModuleValues;
7+
using System;
8+
using System.Collections.Generic;
9+
using System.Linq;
10+
using System.Text;
11+
using System.Threading.Tasks;
12+
using UnityEngine;
13+
using UnityEngine.Assertions;
14+
using static Il2CppNinjaKiwi.GUTS.Models.BossRushRandomizerSettings;
15+
16+
namespace BloonFactory.ModuleProperties
17+
{
18+
internal class BloonTextureModuleProperty : ModuleProperty
19+
{
20+
public Func<Texture2D> GenerateTexture;
21+
22+
public BloonTextureModuleProperty(Func<Texture2D> getTexture)
23+
{
24+
GenerateTexture = getTexture;
25+
}
26+
public override ModHelperPanel GetVisual(ModHelperPanel root)
27+
{
28+
var panel = root.AddPanel(new Info("BloonTextureModuleValue", 0, 0, 1000, 500));
29+
var image = panel.AddImage(new Info("BloonTexture", 0, 0, 500, 500, new Vector2(0.5f, 0.5f)), ModContent.GetSprite<BloonFactory>("BaseBloon"));
30+
31+
panel.AddButton(new Info("Reload", -100, -50, 100, 100, new Vector2(1, 1)), VanillaSprites.RestartBtn, new Action(() =>
32+
{
33+
UpdateImage(image);
34+
}));
35+
UpdateImage(image);
36+
37+
return panel;
38+
}
39+
public void UpdateImage(ModHelperImage image)
40+
{
41+
var texture = GenerateTexture.Invoke();
42+
var sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0.5f), 200);
43+
image.Image.sprite = sprite;
44+
}
45+
public override void LoadData()
46+
{
47+
48+
}
49+
}
50+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
using BTD_Mod_Helper.Api.Components;
2+
using BTD_Mod_Helper.Api.Enums;
3+
using BTD_Mod_Helper.Api.Helpers;
4+
using FactoryCore.API.ModuleValues;
5+
using NfdSharp;
6+
using System;
7+
using System.Collections.Generic;
8+
using System.IO;
9+
using System.Linq;
10+
using System.Text;
11+
using System.Threading.Tasks;
12+
using UnityEngine;
13+
using static Il2CppNinjaKiwi.GUTS.Models.BossRushRandomizerSettings;
14+
using static Il2CppSystem.Linq.Expressions.Interpreter.CastInstruction.CastInstructionNoT;
15+
using static Il2CppSystem.Linq.Expressions.Interpreter.NullableMethodCallInstruction;
16+
17+
namespace BloonFactory.ModuleProperties
18+
{
19+
internal class FileModuleProperty : ModuleProperty
20+
{
21+
public byte[] DefaultValue;
22+
public string Filter;
23+
24+
public FileModuleProperty(byte[] defaultValue, string name, string filter)
25+
{
26+
DefaultValue = defaultValue;
27+
Name = name;
28+
Filter = filter;
29+
}
30+
public override ModHelperPanel GetVisual(ModHelperPanel root)
31+
{
32+
var panel = root.AddPanel(new Info("FloatSliderModuleValue", 0, 0, 1000, 300));
33+
var button = panel.AddButton(new Info("Button", 0, 0, 750, 250, new Vector2(0.5f, 0.5f)), VanillaSprites.GreenBtnLong, new Action(ButtonPressed));
34+
button.AddText(new Info("Text", 0, 0, 700, 200, new Vector2(0.5f, 0.5f)), "Select File").EnableAutoSizing(100, 0);
35+
return panel;
36+
}
37+
public void ButtonPressed()
38+
{
39+
FileDialogHelper.PrepareNativeDlls();
40+
41+
if (Nfd.OpenDialog(Filter, "", out string path) == Nfd.NfdResult.NFD_OKAY)
42+
{
43+
byte[] bytes = File.ReadAllBytes(path);
44+
Module.SetValue(bytes, Name);
45+
}
46+
}
47+
public override void LoadData()
48+
{
49+
if (!Module.HasValue(Name))
50+
Module.SetValue(DefaultValue, Name);
51+
}
52+
}
53+
}

0 commit comments

Comments
 (0)