Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added Assets/CamoDecal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
153 changes: 153 additions & 0 deletions Assets/DefaultTemplate.cstmbln
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
{
"Guid": "1119f64d-4989-44d4-955d-8f11f37e7c25",
"Name": "Bloon",
"modules": [
{
"$type": "BloonFactory.Modules.Core.BloonModule, BloonFactory",
"Id": "ad6bb6d7-748a-4b15-8c0d-05947da96450",
"PropertiesData": {
"Name": "Custom Bloon",
"Health": 5,
"Speed": 18.0,
"Damage": 1
},
"Outputs": [
{
"Name": "Visuals",
"Id": "ee8871a8-9a12-4985-99a2-d7317059e68c",
"Type": "BloonFactory.LinkTypes.Visuals, BloonFactory, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null",
"InputsGuids": [
"bc5c65f3-ec44-4e67-b83b-8214edc22586"
]
},
{
"Name": "Bloon",
"Id": "4246f3a7-3c85-45f0-8b7a-9858939dc9b9",
"Type": "Il2CppAssets.Scripts.Models.Bloons.BloonModel, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null",
"InputsGuids": [
"938505a6-f385-49b3-8b79-2fbe48170148",
"f2b42e3a-73b5-4185-9573-a76d341f69b0"
]
},
{
"Name": "Roundset",
"Id": "987491a9-97a7-4667-b18c-7ac7f49db8bc",
"Type": "Il2CppAssets.Scripts.Models.Rounds.RoundSetModel, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null",
"InputsGuids": []
}
],
"Inputs": [],
"XPosition": 0,
"YPosition": 0,
"Name": "Bloon",
"IsRemovable": false,
"Description": "Adds the base functionality of your custom bloon."
},
{
"$type": "BloonFactory.Modules.Behaviors.AddChildrenModule, BloonFactory",
"Id": "92558238-e733-4366-bfd3-fcf73f7493bd",
"PropertiesData": {
"Bloon": 134,
"Count": 3,
"BloonId": "Red"
},
"Outputs": [],
"Inputs": [
{
"Name": "Bloon",
"Id": "938505a6-f385-49b3-8b79-2fbe48170148",
"Type": "Il2CppAssets.Scripts.Models.Bloons.BloonModel, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null",
"OutputGuid": "4246f3a7-3c85-45f0-8b7a-9858939dc9b9"
}
],
"XPosition": 2427.6753,
"YPosition": -904.11255,
"Name": "Add Children",
"IsRemovable": true,
"Description": ""
},
{
"$type": "BloonFactory.Modules.Display.SimpleDisplayModule, BloonFactory",
"Id": "6963cfac-503f-4e23-a3b6-57a4d33d685e",
"PropertiesData": {},
"Outputs": [
{
"Name": "Texture",
"Id": "03fb67ce-aeaa-4a51-970d-3b4190956755",
"Type": "BloonFactory.LinkTypes.BloonTexture, BloonFactory, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null",
"InputsGuids": [
"7b5caf92-8aa8-40eb-b5ae-fa0a0e79e5cc"
]
}
],
"Inputs": [
{
"Name": "Visuals",
"Id": "bc5c65f3-ec44-4e67-b83b-8214edc22586",
"Type": "BloonFactory.LinkTypes.Visuals, BloonFactory, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null",
"OutputGuid": "ee8871a8-9a12-4985-99a2-d7317059e68c"
}
],
"XPosition": 2429.0137,
"YPosition": -161.29633,
"Name": "Simple Display",
"IsRemovable": true,
"Description": ""
},
{
"$type": "BloonFactory.Modules.Display.BloonTextureModule, BloonFactory",
"Id": "ae92b115-beb5-49c1-9858-22237c129e94",
"PropertiesData": {
"Color": {
"$type": "FactoryCore.API.ModuleProperties.SavedColor, FactoryCore",
"r": 1.0,
"g": 1.0,
"b": 1.0,
"a": 1.0
}
},
"Outputs": [
{
"Name": "Texture",
"Id": "561198d3-c28b-4e10-8d7c-d13c8aabe2a2",
"Type": "BloonFactory.LinkTypes.BloonTexture, BloonFactory, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null",
"InputsGuids": []
}
],
"Inputs": [
{
"Name": "Texture",
"Id": "7b5caf92-8aa8-40eb-b5ae-fa0a0e79e5cc",
"Type": "BloonFactory.LinkTypes.BloonTexture, BloonFactory, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null",
"OutputGuid": "03fb67ce-aeaa-4a51-970d-3b4190956755"
}
],
"XPosition": 3968.8193,
"YPosition": -185.531,
"Name": "Bloon Texture",
"IsRemovable": true,
"Description": ""
},
{
"$type": "BloonFactory.Modules.Behaviors.CashOnPopModule, BloonFactory",
"Id": "948a1fca-47a0-4d89-a391-b7b517a96a70",
"PropertiesData": {
"Cash": 1
},
"Outputs": [],
"Inputs": [
{
"Name": "Bloon",
"Id": "f2b42e3a-73b5-4185-9573-a76d341f69b0",
"Type": "Il2CppAssets.Scripts.Models.Bloons.BloonModel, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null",
"OutputGuid": "4246f3a7-3c85-45f0-8b7a-9858939dc9b9"
}
],
"XPosition": 2431.2456,
"YPosition": -1327.9586,
"Name": "Cash On Pop",
"IsRemovable": true,
"Description": ""
}
]
}
Binary file added Assets/HorizontalSplitDecal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Assets/HorizontalStripesDecal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Assets/VerticalSplitDecal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Assets/VerticalStripesDecal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions BloonFactory.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,15 @@
<Optimize>False</Optimize>
<DebugType>embedded</DebugType>
</PropertyGroup>
<ItemGroup>
<None Remove="Assets\DefaultTemplate.cstmbln" />
</ItemGroup>
<ItemGroup>
<Content Include=".github\workflows\build.yml" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Assets\DefaultTemplate.cstmbln" />
</ItemGroup>
<ItemGroup>
<Reference Include="FactoryCore">
<HintPath>..\..\SteamLibrary\steamapps\common\BloonsTD6\Mods\FactoryCore.dll</HintPath>
Expand Down
2 changes: 1 addition & 1 deletion Categories/BehaviorsCategory.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using BloonFactory.Modules.Behaviors;
using FactoryCore.API;

Check failure on line 2 in Categories/BehaviorsCategory.cs

View workflow job for this annotation

GitHub Actions / build

The type or namespace name 'FactoryCore' could not be found (are you missing a using directive or an assembly reference?)
using System;
using System.Collections.Generic;
using System.Linq;
Expand All @@ -12,6 +12,6 @@
{
public override string Name => "Behaviors";

public override Type[] Modules => [typeof(DamageReductionModule), typeof(QuickEntryModule), typeof(SpeedUpNearbyBloonsModule), typeof(CashOnPopModule)];
public override Type[] Modules => [typeof(DamageReductionModule), typeof(QuickEntryModule), typeof(SpeedUpNearbyBloonsModule), typeof(CashOnPopModule), typeof(AddChildrenModule)];
}
}
2 changes: 2 additions & 0 deletions CustomBloon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
using BloonFactory.Modules.Display;
using BTD_Mod_Helper.Api;
using BTD_Mod_Helper.Api.Bloons;
using FactoryCore.API;

Check failure on line 6 in CustomBloon.cs

View workflow job for this annotation

GitHub Actions / build

The type or namespace name 'FactoryCore' could not be found (are you missing a using directive or an assembly reference?)
using Il2CppAssets.Scripts.Models.Bloons;
using Il2CppAssets.Scripts.Models.Rounds;
using Il2CppNinjaKiwi.Common.ResourceUtils;
using MelonLoader;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
Expand Down
6 changes: 5 additions & 1 deletion ModuleProperties/BloonTextureModuleProperty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using UnityEngine;
using UnityEngine.Assertions;
using static Il2CppNinjaKiwi.GUTS.Models.BossRushRandomizerSettings;
using TaskScheduler = BTD_Mod_Helper.Api.TaskScheduler;

namespace BloonFactory.ModuleProperties
{
Expand All @@ -32,7 +33,10 @@ public override ModHelperPanel GetVisual(ModHelperPanel root)
{
UpdateImage(image);
}));
UpdateImage(image);
TaskScheduler.ScheduleTask(() =>
{
UpdateImage(image);
}, ScheduleType.WaitForFrames, 5);

return panel;
}
Expand Down
28 changes: 24 additions & 4 deletions Modules/Actions/SpawnBloonsActionModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
using Il2CppAssets.Scripts.Models.Bloons.Behaviors;
using Il2CppAssets.Scripts.Unity;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using MelonLoader;
using System;
using System.Linq;

namespace BloonFactory.Modules.Actions
Expand All @@ -15,9 +17,15 @@ internal class SpawnBloonsActionModule : Module
public override string Name => "Spawn Bloons";
public override void GetModuleProperties()
{
AddProperty(new EnumModuleProperty("Bloon", Game.instance.model.bloons.Select(a => a.name).ToArray(), 0));
AddProperty(new EnumModuleProperty("Bloon", Game.instance.model.bloons.Select(a => a.name).ToArray(), 0, new Action<int>((value) =>
{
SetValue(Game.instance.model.bloons[GetValue<int>("Bloon")].id, "BloonId");
})));
AddProperty(new IntModuleProperty("Count", 10, 0, int.MaxValue));
AddProperty(new FloatModuleProperty("Distance Ahead", 45, float.MinValue, float.MaxValue));

if (!HasValue("BloonId"))
SetValue(Game.instance.model.bloons[0].id, "BloonId");
}
public override void GetLinkNodes()
{
Expand All @@ -26,9 +34,21 @@ public override void GetLinkNodes()

public override void ProcessModule()
{
var trigger = GetInputValue<Trigger>("Trigger");
trigger.bloonModel.AddBehavior(new SpawnBloonsActionModel("SpawnBloonsActionModel", Id.ToString(), Game.instance.model.bloons[GetValue<int>("Bloon")].id, GetValue<int>("Count"), 0.02f
, GetValue<float>("Distance Ahead"), 0, 0, new Il2CppStringArray(["BloonariusAttackSpew"]), new Il2CppStringArray(["BloonariusAttackSpewMoab"]), 1.5f, false, "Bloonarius"));
try
{
var trigger = GetInputValue<Trigger>("Trigger");
string id = GetValue<string>("BloonId");

if (!Game.instance.model.bloons.Any(a => a.id == id))
return;

trigger.bloonModel.AddBehavior(new SpawnBloonsActionModel("SpawnBloonsActionModel", Id.ToString(), id, GetValue<int>("Count"), 0.02f
, GetValue<float>("Distance Ahead"), 0, 0, new Il2CppStringArray(["BloonariusAttackSpew"]), new Il2CppStringArray(["BloonariusAttackSpewMoab"]), 1.5f, false, "Bloonarius"));
}
catch (Exception ex)
{
MelonLogger.Error($"Failed to add action. {ex}");
}

}
}
Expand Down
51 changes: 51 additions & 0 deletions Modules/Behaviors/AddChildrenModule.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using BloonFactory.LinkTypes;
using BTD_Mod_Helper.Extensions;
using FactoryCore.API;
using FactoryCore.API.ModuleProperties;
using FactoryCore.API.ModuleValues;
using Il2CppAssets.Scripts.Models.Bloons;
using Il2CppAssets.Scripts.Models.Bloons.Behaviors;
using Il2CppAssets.Scripts.Unity;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using MelonLoader;
using System;
using System.Linq;
using static Il2CppNinjaKiwi.GUTS.Models.BossRushRandomizerSettings;

namespace BloonFactory.Modules.Behaviors
{
internal class AddChildrenModule : Module
{
public override string Name => "Add Children";
public override void GetModuleProperties()
{
AddProperty(new EnumModuleProperty("Bloon", Game.instance.model.bloons.Select(a => a.name).ToArray(), 0, new Action<int>((value) =>
{
SetValue(Game.instance.model.bloons[GetValue<int>("Bloon")].id, "BloonId");
})));
AddProperty(new IntModuleProperty("Count", 10, 0, int.MaxValue));

if (!HasValue("BloonId"))
SetValue("", "BloonId");
}
public override void GetLinkNodes()
{
AddInput<BloonModel>("Bloon");
}

public override void ProcessModule()
{
try
{
string id = GetValue<string>("BloonId");
if (Game.instance.model.bloons.Any(a => a.id == id))
GetInputValue<BloonModel>("Bloon").AddToChildren(id, GetValue<int>("Count"));
}
catch (Exception ex)
{
MelonLogger.Error($"Failed to add action. {ex}");
}

}
}
}
1 change: 0 additions & 1 deletion Modules/Core/BloonModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ internal class BloonModule : Module
public RoundSetModel currentRoundSet;
public override void GetModuleProperties()
{
AddProperty(new StringModuleProperty("Name", "Custom Bloon", 20));
AddProperty(new IntModuleProperty("Health", 1, 1, int.MaxValue));
AddProperty(new FloatModuleProperty("Speed", 25, 1, float.MaxValue));
AddProperty(new IntModuleProperty("Damage", 1, 1, int.MaxValue));
Expand Down
23 changes: 19 additions & 4 deletions Modules/Display/DecalModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,33 +14,48 @@ namespace BloonFactory.Modules.Display
{
internal class DecalModule : Module
{
public static string[] FileNameFromDecal => ["FortifiedDecal"];
public static string[] FileNameFromDecal => ["FortifiedDecal", "CamoDecal", "HorizontalStripesDecal", "VerticalStripesDecal", "HorizontalSplitDecal", "VerticalSplitDecal"];
public override string Name => "Decal";

BloonTexture bloonTexture;
public override void GetLinkNodes()
{
AddInput<BloonTexture>("Texture");
AddOutput<BloonTexture>("Texture", () => bloonTexture);
}
public override void GetModuleProperties()
{
AddProperty(new EnumModuleProperty("Decal", ["Fortified"], 0));
AddProperty(new EnumModuleProperty("Decal", ["Fortified", "Camo", "Horizontal Stripes", "Vertical Stripes", "Horizontal Split", "Vertical Split"], 0));
AddProperty(new ColorModuleProperty("Color", Color.white, false));
}
public override void ProcessModule()
{
var texture = GetInputValue<BloonTexture>("Texture");
if (texture.texture == null)
return;

Color color = GetValue<SavedColor>("Color");
var decalTexture = ModContent.GetTexture<BloonFactory>(FileNameFromDecal[GetValue<int>("Decal")]);
for (int x = 0; x < decalTexture.width; x++)
{
for (int y = 0; y < decalTexture.height; y++)
{
Color decalColor = decalTexture.GetPixel(x, y);
Color decalColor = decalTexture.GetPixel(x, y) * color;
Color textureColor = texture.texture.GetPixel(x, y);
texture.texture.SetPixel(x, y, decalColor.a < 0.1f ? textureColor : decalColor);
texture.texture.SetPixel(x, y, OverlayColor(textureColor, decalColor));
}
}
texture.texture.Apply();

bloonTexture = texture;
GetOutputsModules("Texture").ProcessAll();
}
public Color OverlayColor(Color baseColor, Color overlayColor)
{
float a = overlayColor.a;
var color = overlayColor;
color.a = 1;
return Color.Lerp(baseColor, color, a);
}
}
}
Loading
Loading