Skip to content

Holdable modifiers #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 20 commits into
base: main
Choose a base branch
from
Open
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
113 changes: 113 additions & 0 deletions Content/Augments/Augments.Holdable.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
using TC2.Base.Components;

namespace TC2.Base
{
public sealed partial class BaseMod
{
private static void RegisterHoldableAugments(ref List<Augment.Definition> definitions)
{
definitions.Add(Augment.Definition.New<Holdable.Data>
(
identifier: "holdable.sneaky",
category: "Utility",
name: "Sneaky",
description: "Hold this item BEHIND your body to make it less obvious",

can_add: static (ref Augment.Context context, in Holdable.Data data, ref Augment.Handle handle, Span<Augment.Handle> Augments) =>
{
ref var renderer = ref context.GetComponent<Animated.Renderer.Data>();
return !Augments.HasAugment(handle) && !renderer.IsNull();
},

apply_1: static (ref Augment.Context context, ref Holdable.Data data, ref Augment.Handle handle, Span<Augment.Handle> Augments) =>
{
ref var renderer = ref context.GetComponent<Animated.Renderer.Data>();
if (!renderer.IsNull())
{
renderer.z = -140.00f;
}

ref var gun = ref context.GetComponent<Gun.Data>();
if (!gun.IsNull())
{
gun.damage_multiplier *= 0.80f;
}

ref var melee = ref context.GetComponent<Melee.Data>();
if (!melee.IsNull())
{
melee.damage_base *= 0.80f;
}

foreach (ref var requirement in context.requirements_new)
{
if (requirement.type == Crafting.Requirement.Type.Work)
{
requirement.difficulty += 1.00f;
requirement.amount *= 1.20f;
}
}
}
));

definitions.Add(Augment.Definition.New<Holdable.Data>
(
identifier: "holdable.rubber_grip",
category: "Utility",
name: "Rubber Grip",
description: "Get a better grip on the item by adding a rubber grip",

can_add: static (ref Augment.Context context, in Holdable.Data data, ref Augment.Handle handle, Span<Augment.Handle> Augments) =>
{
return !Augments.HasAugment(handle);
},

apply_1: static (ref Augment.Context context, ref Holdable.Data data, ref Augment.Handle handle, Span<Augment.Handle> Augments) =>
{
data.force_multiplier *= 1.5f;
data.torque_multiplier *= 1.5f;

foreach (ref var requirement in context.requirements_new)
{
if (requirement.type == Crafting.Requirement.Type.Work)
{
requirement.amount *= 1.10f;
}
}

context.requirements_new.Add(Crafting.Requirement.Resource("rubber", 5.00f));
}
));

definitions.Add(Augment.Definition.New<Holdable.Data>
(
identifier: "holdable.lubricated_grip",
category: "Utility",
name: "Slippery Grip",
description: "Lubricate any grippable places of the object making it nearly unholdable",

can_add: static (ref Augment.Context context, in Holdable.Data data, ref Augment.Handle handle, Span<Augment.Handle> Augments) =>
{
return !Augments.HasAugment(handle);
},

apply_1: static (ref Augment.Context context, ref Holdable.Data data, ref Augment.Handle handle, Span<Augment.Handle> Augments) =>
{
data.force_multiplier *= 0.01f;
data.torque_multiplier *= 0.01f;

foreach (ref var requirement in context.requirements_new)
{
if (requirement.type == Crafting.Requirement.Type.Work)
{
requirement.amount *= 1.10f;
}
}

context.requirements_new.Add(Crafting.Requirement.Resource("lubricant", 5.00f));
}
));
}
}
}

1 change: 1 addition & 0 deletions content/Mod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ protected override void OnRegister(ModContext context)
Augment.OnInitialize += RegisterDrillAugments;
Augment.OnInitialize += RegisterMedkitAugments;
Augment.OnInitialize += RegisterExplosiveAugments;
Augment.OnInitialize += RegisterHoldableAugments;
Augment.OnInitialize += RegisterArmorAugments;

Material.OnPostInitialize += Essence.Init;
Expand Down