Skip to content

Commit

Permalink
Fixed patches for epic games
Browse files Browse the repository at this point in the history
  • Loading branch information
doombubbles committed Aug 16, 2023
1 parent 9679675 commit 4b56e36
Show file tree
Hide file tree
Showing 20 changed files with 1,231 additions and 32 deletions.
38 changes: 35 additions & 3 deletions BloonsTD6 Mod Helper/Api/Helpers/AttackHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,17 @@
using Il2CppAssets.Scripts.Simulation.SMath;
namespace BTD_Mod_Helper.Api.Helpers;

/// <summary>
/// A wrapper around AttackModels for making them easier to create
/// </summary>
public class AttackHelper : ModelHelper<AttackModel>
{
private AttackFilterModel Filter => Model.GetBehavior<AttackFilterModel>();
/// <summary>
/// This AttackModel's AttackFilterModel
/// </summary>
public AttackFilterModel Filter => Model.GetBehavior<AttackFilterModel>();

/// <seealso cref="AttackModel.weapons"/>
public WeaponModel Weapon
{
get => Model.GetChild<WeaponModel>();
Expand All @@ -22,6 +29,7 @@ public WeaponModel Weapon
}
}

/// <seealso cref="AttackModel.weapons"/>
public WeaponModel[] Weapons
{
get => Model.weapons;
Expand All @@ -33,12 +41,14 @@ public WeaponModel[] Weapons
}
}

/// <seealso cref="AttackModel.range"/>
public float Range
{
get => Model.range;
set => Model.range = value;
}

/// <seealso cref="AttackModel.behaviors"/>
public Model[] Behaviors
{
get => Model.behaviors;
Expand All @@ -50,6 +60,8 @@ public Model[] Behaviors
}
}


/// <seealso cref="AttackFilterModel.filters"/>
public FilterModel[] Filters
{
get => Filter.filters;
Expand All @@ -63,6 +75,7 @@ public FilterModel[] Filters
}
}

/// <seealso cref="AttackModel.targetProvider"/>
public TargetSupplierModel TargetProvider
{
get => Model.targetProvider;
Expand All @@ -78,6 +91,9 @@ public TargetSupplierModel TargetProvider
}
}

/// <seealso cref="AttackModel.offsetX"/>
/// <seealso cref="AttackModel.offsetY"/>
/// <seealso cref="AttackModel.offsetZ"/>
public Vector3 Offset
{
get => new(Model.offsetX, Model.offsetY, Model.offsetZ);
Expand All @@ -89,47 +105,57 @@ public Vector3 Offset
}
}

/// <seealso cref="AttackModel.attackThroughWalls"/>
public bool AttackThroughWalls
{
get => Model.attackThroughWalls;
set => Model.attackThroughWalls = value;
}

/// <seealso cref="AttackModel.fireWithoutTarget"/>
public bool FireWithoutTarget
{
get => Model.fireWithoutTarget;
set => Model.fireWithoutTarget = value;
}


/// <seealso cref="AttackModel.framesBeforeRetarget"/>
public int FramesBeforeRetarget
{
get => Model.framesBeforeRetarget;
set => Model.framesBeforeRetarget = value;
}

/// <seealso cref="AttackModel.addsToSharedGrid"/>
public bool AddToSharedGrid
{
get => Model.addsToSharedGrid;
set => Model.addsToSharedGrid = value;
}

/// <seealso cref="AttackModel.sharedGridRange"/>
public float SharedGridRange
{
get => Model.sharedGridRange;
set => Model.sharedGridRange = value;
}

/// <seealso cref="FilterInvisibleModel.isActive"/>
public bool CanSeeCamo
{
get => !Filter.GetChild<FilterInvisibleModel>().isActive;
set => Filter.GetChild<FilterInvisibleModel>().isActive = !value;
}

private AttackHelper(AttackModel attack) : base(attack)
{
}

/// <summary>
/// Begins construction of a new AttackModel with sensible default values
/// </summary>
/// <param name="name">The model name (don't need the AttackModel_ part)</param>
public AttackHelper(string name = "") : this(new AttackModel(name,
new Il2CppReferenceArray<WeaponModel>(0), 0, new[]
{
Expand All @@ -141,8 +167,14 @@ public AttackHelper(string name = "") : this(new AttackModel(name,
{
}

/// <summary>
/// Unwraps the model
/// </summary>
public static implicit operator AttackModel(AttackHelper helper) => helper.Model;


/// <summary>
/// Wraps a model
/// </summary>
public static implicit operator AttackHelper(AttackModel model) => new(model);

}
11 changes: 11 additions & 0 deletions BloonsTD6 Mod Helper/Api/Helpers/ModelHelper.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,26 @@
using Il2CppAssets.Scripts.Models;
namespace BTD_Mod_Helper.Api.Helpers;

/// <summary>
/// A wrapper class around a Model
/// </summary>
public abstract class ModelHelper
{
/// <summary>
/// The internal model
/// </summary>
public abstract Model Model { get; }
}

/// <inheritdoc />
public abstract class ModelHelper<T> : ModelHelper where T : Model
{
/// <inheritdoc />
public override T Model { get; }

/// <summary>
/// Creates a wrapper around an existing model
/// </summary>
protected ModelHelper(T model)
{
Model = model;
Expand Down
1 change: 1 addition & 0 deletions BloonsTD6 Mod Helper/Api/Helpers/ProcessHelper.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Diagnostics;
using BTD_Mod_Helper.UI.BTD6;
using Il2CppAssets.Scripts.Unity.Menu;
using MelonLoader.Utils;
namespace BTD_Mod_Helper.Api.Helpers;
Expand Down
52 changes: 48 additions & 4 deletions BloonsTD6 Mod Helper/Api/Helpers/ProjectileHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,47 +8,64 @@
using Il2CppAssets.Scripts.Utils;
namespace BTD_Mod_Helper.Api.Helpers;

/// <summary>
/// A wrapper around ProjectileModels for making them easier to create
/// </summary>
public class ProjectileHelper : ModelHelper<ProjectileModel>
{
private ProjectileFilterModel Filter => Model.GetBehavior<ProjectileFilterModel>();
private DisplayModel DisplayModel => Model.GetBehavior<DisplayModel>();

/// <summary>
/// This ProjectileModel's ProjectileFilterModel
/// </summary>
public ProjectileFilterModel Filter => Model.GetBehavior<ProjectileFilterModel>();

/// <summary>
/// This ProjectileModel's DisplayModel
/// </summary>
public DisplayModel DisplayModel => Model.GetBehavior<DisplayModel>();

/// <seealso cref="ProjectileModel.display"/>
public string Display
{
get => Model.display.guidRef;
set => Model.display.guidRef = Model.GetBehavior<DisplayModel>().display.guidRef = value;
}

/// <seealso cref="ProjectileModel.display"/>
public PrefabReference DisplayReference
{
get => Model.display;
set => Model.display = Model.GetBehavior<DisplayModel>().display = value;
}

/// <seealso cref="ProjectileModel.radius"/>
public float Radius
{
get => Model.radius;
set => Model.radius = value;
}

/// <seealso cref="ProjectileModel.vsBlockerRadius"/>
public float VsBlockerRadius
{
get => Model.vsBlockerRadius;
set => Model.vsBlockerRadius = value;
}

/// <seealso cref="ProjectileModel.pierce"/>
public float Pierce
{
get => Model.pierce;
set => Model.pierce = value;
}

/// <seealso cref="ProjectileModel.maxPierce"/>
public float MaxPierce
{
get => Model.maxPierce;
set => Model.maxPierce = value;
}

/// <seealso cref="ProjectileModel.behaviors"/>
public Model[] Behaviors
{
get => Model.behaviors ?? new Il2CppReferenceArray<Model>(0);
Expand All @@ -64,6 +81,7 @@ public Model[] Behaviors
}
}

/// <seealso cref="ProjectileFilterModel.filters"/>
public FilterModel[] Filters
{
get => Filter.filters;
Expand All @@ -78,62 +96,78 @@ public FilterModel[] Filters
}
}

/// <seealso cref="ProjectileModel.ignoreBlockers"/>
public bool IgnoreBlockers
{
get => Model.ignoreBlockers;
set => Model.ignoreBlockers = value;
}

/// <seealso cref="ProjectileModel.usePointCollisionWithBloons"/>
public bool UsePointCollisionWithBloons
{
get => Model.usePointCollisionWithBloons;
set => Model.usePointCollisionWithBloons = value;
}

/// <seealso cref="ProjectileModel.canCollisionBeBlockedByMapLos"/>
public bool CanCollisionBeBlockedByMapLos
{
get => Model.canCollisionBeBlockedByMapLos;
set => Model.canCollisionBeBlockedByMapLos = value;
}

/// <seealso cref="ProjectileModel.scale"/>
public float Scale
{
get => Model.scale;
set => Model.scale = value;
}

public int[] CollissionPasses => CollissionPasses;
/// <seealso cref="ProjectileModel.collisionPasses"/>
public int[] CollissionPasses
{
get => Model.collisionPasses;
set => Model.collisionPasses = value;
}


/// <seealso cref="ProjectileModel.dontUseCollisionChecker"/>
public bool DontUseCollisionChecker
{
get => Model.dontUseCollisionChecker;
set => Model.dontUseCollisionChecker = value;
}

/// <seealso cref="ProjectileModel.checkCollisionFrames"/>
public int CheckCollisionFrames
{
get => Model.checkCollisionFrames;
set => Model.checkCollisionFrames = value;
}

/// <seealso cref="ProjectileModel.ignoreNonTargetable"/>
public bool IgnoreNonTargetable
{
get => Model.ignoreNonTargetable;
set => Model.ignoreNonTargetable = value;
}

/// <seealso cref="ProjectileModel.ignorePierceExhaustion"/>
public bool IgnorePierceExhaustion
{
get => Model.ignorePierceExhaustion;
set => Model.ignorePierceExhaustion = value;
}

/// <seealso cref="ProjectileModel.saveId"/>
public string SaveId
{
get => Model.saveId;
set => Model.saveId = value;
}

/// <seealso cref="FilterInvisibleModel.isActive"/>
public bool CanHitCamo
{
get => !Filter.GetChild<FilterInvisibleModel>().isActive;
Expand All @@ -148,6 +182,10 @@ private ProjectileHelper(ProjectileModel Projectile) : base(Projectile)
{
}

/// <summary>
/// Begins construction of a new ProjectileModel with sensible default values
/// </summary>
/// <param name="name">The model name (don't need the ProjectileModel_ part)</param>
public ProjectileHelper(string name = "") : this(new ProjectileModel(
new PrefabReference {guidRef = ""}, name, behaviors: new Model[]
{
Expand All @@ -163,12 +201,18 @@ public ProjectileHelper(string name = "") : this(new ProjectileModel(
{
}

/// <summary>
/// Unwraps the model (and updates collission passes)
/// </summary>
public static implicit operator ProjectileModel(ProjectileHelper helper)
{
helper.Model.UpdateCollisionPassList();
return helper.Model;
}

/// <summary>
/// Wraps a model
/// </summary>
public static implicit operator ProjectileHelper(ProjectileModel model) => new(model);

}
Loading

0 comments on commit 4b56e36

Please sign in to comment.