From 292a40504a4cb4eec05e1f19a245a6a2dd7761f9 Mon Sep 17 00:00:00 2001 From: Wunarg Date: Mon, 13 Dec 2021 14:42:12 +0100 Subject: [PATCH 01/19] New modifier page --- Content/Data/Modifications.Body.cs | 13 +++++++++++++ content/Mod.cs | 1 + 2 files changed, 14 insertions(+) create mode 100644 Content/Data/Modifications.Body.cs diff --git a/Content/Data/Modifications.Body.cs b/Content/Data/Modifications.Body.cs new file mode 100644 index 000000000..735310e21 --- /dev/null +++ b/Content/Data/Modifications.Body.cs @@ -0,0 +1,13 @@ +using TC2.Base.Components; + +namespace TC2.Base +{ + public sealed partial class ModInstance + { + private static void RegisterBodyModifications(ref List definitions) + { + + } + } +} + diff --git a/content/Mod.cs b/content/Mod.cs index ab89618cb..b55b0aef0 100644 --- a/content/Mod.cs +++ b/content/Mod.cs @@ -10,6 +10,7 @@ protected override void OnRegister(ModContext context) Modification.OnInitialize += RegisterMeleeModifications; Modification.OnInitialize += RegisterDrillModifications; Modification.OnInitialize += RegisterMedkitModifications; + Modification.OnInitialize += RegisterBodyModifications; } protected override void OnInitialize(ModContext context) From 9d80317f7ea488e9b95557715d81546b76ecb812 Mon Sep 17 00:00:00 2001 From: Wunarg Date: Mon, 13 Dec 2021 14:45:51 +0100 Subject: [PATCH 02/19] Moved old body modifiers --- Content/Data/Modifications.Body.cs | 110 ++++++++++++++++++++++++++++- content/Data/Modifications.cs | 110 ----------------------------- 2 files changed, 109 insertions(+), 111 deletions(-) diff --git a/Content/Data/Modifications.Body.cs b/Content/Data/Modifications.Body.cs index 735310e21..e5784171c 100644 --- a/Content/Data/Modifications.Body.cs +++ b/Content/Data/Modifications.Body.cs @@ -6,7 +6,115 @@ public sealed partial class ModInstance { private static void RegisterBodyModifications(ref List definitions) { - + definitions.Add(Modification.Definition.New + ( + identifier: "body.bulk", + name: "Batch Production", + description: "More efficient manufacturing process by producing multiple items in bulk.", + + validate: static (ref Modification.Context context, in Body.Data data, ref Modification.Handle handle, Span modifications) => + { + ref var batch_size = ref handle.GetData(); + batch_size = Maths.Clamp(batch_size, 1, 10); + + return true; + }, + +#if CLIENT + draw_editor: static (ref Modification.Context context, in Body.Data data, ref Modification.Handle handle, Span modifications) => + { + ref var batch_size = ref handle.GetData(); + return GUI.SliderInt("##stuff", ref batch_size, 1, 10, "%d"); + }, +#endif + + can_add: static (ref Modification.Context context, in Body.Data data, ref Modification.Handle handle, Span modifications) => + { + return !modifications.HasModification(handle); + }, + + apply_1: static (ref Modification.Context context, ref Body.Data data, ref Modification.Handle handle, Span modifications) => + { + ref readonly var recipe_old = ref context.GetRecipeOld(); + ref var recipe_new = ref context.GetRecipeNew(); + + ref var batch_size = ref handle.GetData(); + + recipe_new.min *= batch_size; + recipe_new.max *= batch_size; + recipe_new.step *= batch_size; + + for (int i = 0; i < context.requirements_new.Length; i++) + { + ref var requirement = ref context.requirements_new[i]; + + if (requirement.type == Crafting.Requirement.Type.Resource) + { + ref var material = ref requirement.material.GetDefinition(); + if (material.flags.HasAll(Material.Flags.Manufactured)) + { + requirement.amount *= MathF.Pow(0.99f, batch_size - 1); + } + else + { + requirement.amount *= MathF.Pow(0.98f, batch_size - 1); + } + } + else if (requirement.type == Crafting.Requirement.Type.Work) + { + switch (requirement.work) + { + case Work.Type.Machining: + { + requirement.amount *= MathF.Pow(0.95f, batch_size - 1); + } + break; + + case Work.Type.Smithing: + { + requirement.amount *= MathF.Pow(0.93f, batch_size - 1); + } + break; + + case Work.Type.Assembling: + { + requirement.amount *= MathF.Pow(0.90f, batch_size - 1); + } + break; + + default: + { + requirement.amount *= MathF.Pow(0.95f, batch_size - 1); + } + break; + } + } + } + } + )); + + //definitions.Add(Modification.Definition.New // Can be used on any recipe which results in a prefab + //( + // identifier: "body.efficient_crafting", + // name: "Efficient Crafting", + // description: "Rework the design to reduce material costs slightly.", + + // apply_1: static (ref Modification.Context context, ref Modification.Handle handle, Span modifications) => + // { + // foreach (ref var requirement in context.requirements_new) + // { + // if (requirement.type == Crafting.Requirement.Type.Resource) + // { + // requirement.amount *= 0.80f; + // } + // else if (requirement.type == Crafting.Requirement.Type.Work) + // { + // requirement.amount *= 1.05f; + // requirement.difficulty += 2.50f; + // } + // } + // } + //)); } } } diff --git a/content/Data/Modifications.cs b/content/Data/Modifications.cs index 47bc710b0..bc372d1b4 100644 --- a/content/Data/Modifications.cs +++ b/content/Data/Modifications.cs @@ -112,29 +112,6 @@ private static void RegisterModifications(ref List defi } )); - //definitions.Add(Modification.Definition.New // Can be used on any recipe which results in a prefab - //( - // identifier: "body.efficient_crafting", - // name: "Efficient Crafting", - // description: "Rework the design to reduce material costs slightly.", - - // apply_1: static (ref Modification.Context context, ref Modification.Handle handle, Span modifications) => - // { - // foreach (ref var requirement in context.requirements_new) - // { - // if (requirement.type == Crafting.Requirement.Type.Resource) - // { - // requirement.amount *= 0.80f; - // } - // else if (requirement.type == Crafting.Requirement.Type.Work) - // { - // requirement.amount *= 1.05f; - // requirement.difficulty += 2.50f; - // } - // } - // } - //)); - definitions.Add(Modification.Definition.New ( identifier: "fuse.length", @@ -331,93 +308,6 @@ private static void RegisterModifications(ref List defi } } )); - - definitions.Add(Modification.Definition.New - ( - identifier: "body.bulk", - name: "Batch Production", - description: "More efficient manufacturing process by producing multiple items in bulk.", - - validate: static (ref Modification.Context context, in Body.Data data, ref Modification.Handle handle, Span modifications) => - { - ref var batch_size = ref handle.GetData(); - batch_size = Maths.Clamp(batch_size, 1, 10); - - return true; - }, - -#if CLIENT - draw_editor: static (ref Modification.Context context, in Body.Data data, ref Modification.Handle handle, Span modifications) => - { - ref var batch_size = ref handle.GetData(); - return GUI.SliderInt("##stuff", ref batch_size, 1, 10, "%d"); - }, -#endif - - can_add: static (ref Modification.Context context, in Body.Data data, ref Modification.Handle handle, Span modifications) => - { - return !modifications.HasModification(handle); - }, - - apply_1: static (ref Modification.Context context, ref Body.Data data, ref Modification.Handle handle, Span modifications) => - { - ref readonly var recipe_old = ref context.GetRecipeOld(); - ref var recipe_new = ref context.GetRecipeNew(); - - ref var batch_size = ref handle.GetData(); - - recipe_new.min *= batch_size; - recipe_new.max *= batch_size; - recipe_new.step *= batch_size; - - for (int i = 0; i < context.requirements_new.Length; i++) - { - ref var requirement = ref context.requirements_new[i]; - - if (requirement.type == Crafting.Requirement.Type.Resource) - { - ref var material = ref requirement.material.GetDefinition(); - if (material.flags.HasAll(Material.Flags.Manufactured)) - { - requirement.amount *= MathF.Pow(0.99f, batch_size - 1); - } - else - { - requirement.amount *= MathF.Pow(0.98f, batch_size - 1); - } - } - else if (requirement.type == Crafting.Requirement.Type.Work) - { - switch (requirement.work) - { - case Work.Type.Machining: - { - requirement.amount *= MathF.Pow(0.95f, batch_size - 1); - } - break; - - case Work.Type.Smithing: - { - requirement.amount *= MathF.Pow(0.93f, batch_size - 1); - } - break; - - case Work.Type.Assembling: - { - requirement.amount *= MathF.Pow(0.90f, batch_size - 1); - } - break; - - default: - { - requirement.amount *= MathF.Pow(0.95f, batch_size - 1); - } - break; - } - } - } - } - )); } } } From 01f90764d35e866115ac02daa52affc17f8130b5 Mon Sep 17 00:00:00 2001 From: Wunarg Date: Mon, 13 Dec 2021 14:57:06 +0100 Subject: [PATCH 03/19] Lightweight modifier --- Content/Data/Modifications.Body.cs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/Content/Data/Modifications.Body.cs b/Content/Data/Modifications.Body.cs index e5784171c..9342db606 100644 --- a/Content/Data/Modifications.Body.cs +++ b/Content/Data/Modifications.Body.cs @@ -115,6 +115,32 @@ private static void RegisterBodyModifications(ref List // } // } //)); + + definitions.Add(Modification.Definition.New + ( + identifier: "body.lightweight_design", + category: "Body", + name: "Lightweight Design", + description: "Redesign the object to have slightly less weight but be harder to produce", + + can_add: static (ref Modification.Context context, in Body.Data data, ref Modification.Handle handle, Span modifications) => + { + return !modifications.HasModification(handle); + }, + + apply_1: static (ref Modification.Context context, ref Body.Data data, ref Modification.Handle handle, Span modifications) => + { + data.mass_multiplier *= 0.80f; + foreach (ref var requirement in context.requirements_new) + { + if (requirement.type == Crafting.Requirement.Type.Work) + { + requirement.amount *= 1.30f; + requirement.difficulty += 2.0f; + } + } + } + )); } } } From 27d8a35b9f99bff30fe1b8515463607ac9dd88f7 Mon Sep 17 00:00:00 2001 From: Wunarg Date: Mon, 13 Dec 2021 15:00:31 +0100 Subject: [PATCH 04/19] Heavyweight design modifier --- Content/Data/Modifications.Body.cs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/Content/Data/Modifications.Body.cs b/Content/Data/Modifications.Body.cs index 9342db606..04b2c8120 100644 --- a/Content/Data/Modifications.Body.cs +++ b/Content/Data/Modifications.Body.cs @@ -141,6 +141,28 @@ private static void RegisterBodyModifications(ref List } } )); + + definitions.Add(Modification.Definition.New + ( + identifier: "body.heavyweight_design", + category: "Body", + name: "Heavyweight Design", + description: "Redesign the object to be a lot heavier", + + apply_1: static (ref Modification.Context context, ref Body.Data data, ref Modification.Handle handle, Span modifications) => + { + data.mass_multiplier *= 2.00f; + //This modifier is mostly a negative but sometimes you may want to increase the weight of an object like, + //For example you can increase the weight of your own melee weapons to make them harder to grab for your opponents + foreach (ref var requirement in context.requirements_new) + { + if (requirement.type == Crafting.Requirement.Type.Work) + { + requirement.amount *= 1.10f; + } + } + } + )); } } } From 7d8411f244ba473c8d6c9f6d4820a42bd099ea27 Mon Sep 17 00:00:00 2001 From: Wunarg Date: Mon, 13 Dec 2021 15:06:27 +0100 Subject: [PATCH 05/19] Rebalanced old commented out modifier --- Content/Data/Modifications.Body.cs | 47 ++++++++++++++++-------------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/Content/Data/Modifications.Body.cs b/Content/Data/Modifications.Body.cs index 04b2c8120..4dbb5a2c8 100644 --- a/Content/Data/Modifications.Body.cs +++ b/Content/Data/Modifications.Body.cs @@ -93,28 +93,31 @@ private static void RegisterBodyModifications(ref List } )); - //definitions.Add(Modification.Definition.New // Can be used on any recipe which results in a prefab - //( - // identifier: "body.efficient_crafting", - // name: "Efficient Crafting", - // description: "Rework the design to reduce material costs slightly.", - - // apply_1: static (ref Modification.Context context, ref Modification.Handle handle, Span modifications) => - // { - // foreach (ref var requirement in context.requirements_new) - // { - // if (requirement.type == Crafting.Requirement.Type.Resource) - // { - // requirement.amount *= 0.80f; - // } - // else if (requirement.type == Crafting.Requirement.Type.Work) - // { - // requirement.amount *= 1.05f; - // requirement.difficulty += 2.50f; - // } - // } - // } - //)); + definitions.Add(Modification.Definition.New // Can be used on any recipe which results in a prefab + ( + identifier: "body.efficient_crafting", + category: "Body", + name: "Efficient Crafting", + description: "Rework the design to reduce material costs slightly.", + + //This modifier is nearly always an option but only with many npcs or very high skills is this actually worth while since it ramps up crafting time a ton + + apply_1: static (ref Modification.Context context, ref Body.Data data, ref Modification.Handle handle, Span modifications) => + { + foreach (ref var requirement in context.requirements_new) + { + if (requirement.type == Crafting.Requirement.Type.Resource) + { + requirement.amount *= 0.95f; + } + else if (requirement.type == Crafting.Requirement.Type.Work) + { + requirement.amount *= 1.50f; + requirement.difficulty += 3.00f; + } + } + } + )); definitions.Add(Modification.Definition.New ( From e71d9ce06c0bb40b22b807e90a22fe38679887c1 Mon Sep 17 00:00:00 2001 From: Wunarg Date: Mon, 13 Dec 2021 15:21:42 +0100 Subject: [PATCH 06/19] Mushroom wood modifier --- Content/Data/Modifications.Body.cs | 43 +++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/Content/Data/Modifications.Body.cs b/Content/Data/Modifications.Body.cs index 4dbb5a2c8..cf083bf9a 100644 --- a/Content/Data/Modifications.Body.cs +++ b/Content/Data/Modifications.Body.cs @@ -93,7 +93,7 @@ private static void RegisterBodyModifications(ref List } )); - definitions.Add(Modification.Definition.New // Can be used on any recipe which results in a prefab + definitions.Add(Modification.Definition.New ( identifier: "body.efficient_crafting", category: "Body", @@ -166,6 +166,47 @@ private static void RegisterBodyModifications(ref List } } )); + + definitions.Add(Modification.Definition.New + ( + identifier: "body.mushroom_wood", + category: "Body", + name: "Mushroom Wood", + description: "Uses mushroom scraps as a wood replacement", + + //the purpose of this modifier is to add another use to mushroom scraps AND to allow people to use spare mushrooms as wood + //this modifier is likely to be more usefull once buildings can be blueprinted + + can_add: static (ref Modification.Context context, in Body.Data data, ref Modification.Handle handle, Span modifications) => + { + return context.requirements_new.Has(Crafting.Requirement.Resource("wood", 0.00f)) && !modifications.HasModification(handle); + }, + + apply_1: static (ref Modification.Context context, ref Body.Data data, ref Modification.Handle handle, Span modifications) => + { + var wood_amount = 0.00f; + foreach (ref var requirement in context.requirements_new) + { + if (requirement.type == Crafting.Requirement.Type.Work) + { + requirement.amount *= 0.70f; + requirement.difficulty += 1.00f; + //Mushroom scraps are faster to process but require you to be more experienced + //This is also fine balance wise since mushroom scraps are harder to get than wood + } + else if (requirement.type == Crafting.Requirement.Type.Resource) + { + ref var material = ref requirement.material.GetDefinition(); + if (material.identifier == "wood") + { + wood_amount += requirement.amount; + requirement = default; + } + } + } + context.requirements_new.Add(Crafting.Requirement.Resource("mushroom", wood_amount)); + } + )); } } } From 0fc1d0f23997ddb222c45c11e5314400e8eece40 Mon Sep 17 00:00:00 2001 From: Wunarg Date: Mon, 13 Dec 2021 15:51:16 +0100 Subject: [PATCH 07/19] Floaty Modifier --- Content/Data/Modifications.Body.cs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/Content/Data/Modifications.Body.cs b/Content/Data/Modifications.Body.cs index cf083bf9a..e161e38b9 100644 --- a/Content/Data/Modifications.Body.cs +++ b/Content/Data/Modifications.Body.cs @@ -134,6 +134,7 @@ private static void RegisterBodyModifications(ref List apply_1: static (ref Modification.Context context, ref Body.Data data, ref Modification.Handle handle, Span modifications) => { data.mass_multiplier *= 0.80f; + data.gravity *= 0.90f; foreach (ref var requirement in context.requirements_new) { if (requirement.type == Crafting.Requirement.Type.Work) @@ -167,6 +168,34 @@ private static void RegisterBodyModifications(ref List } )); + definitions.Add(Modification.Definition.New + ( + identifier: "body.floaty", + category: "Body", + name: "Floaty", + description: "Makes the object fall slower", + + can_add: static (ref Modification.Context context, in Body.Data data, ref Modification.Handle handle, Span modifications) => + { + return !modifications.HasModification(handle); + }, + + apply_1: static (ref Modification.Context context, ref Body.Data data, ref Modification.Handle handle, Span modifications) => + { + data.gravity *= 0.20f; + //Very fun modifer which makes an object behave very floaty + //TODO: should cost motion salt or some sort of gas, current cost is temporary + foreach (ref var requirement in context.requirements_new) + { + if (requirement.type == Crafting.Requirement.Type.Work) + { + requirement.amount *= 1.30f; + } + } + context.requirements_new.Add(Crafting.Requirement.Resource("chitin", 50)); + } + )); + definitions.Add(Modification.Definition.New ( identifier: "body.mushroom_wood", From 818746222def8cad5eb63347a8c3299785043f38 Mon Sep 17 00:00:00 2001 From: Wunarg Date: Mon, 13 Dec 2021 16:00:46 +0100 Subject: [PATCH 08/19] Heavy weight modifier now also increases gravity to increase falling speed --- Content/Data/Modifications.Body.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Content/Data/Modifications.Body.cs b/Content/Data/Modifications.Body.cs index e161e38b9..fb7d00245 100644 --- a/Content/Data/Modifications.Body.cs +++ b/Content/Data/Modifications.Body.cs @@ -156,6 +156,7 @@ private static void RegisterBodyModifications(ref List apply_1: static (ref Modification.Context context, ref Body.Data data, ref Modification.Handle handle, Span modifications) => { data.mass_multiplier *= 2.00f; + data.gravity *= 1.10f; //This modifier is mostly a negative but sometimes you may want to increase the weight of an object like, //For example you can increase the weight of your own melee weapons to make them harder to grab for your opponents foreach (ref var requirement in context.requirements_new) From 79a45e1a5db97cb30bbb76598b323621000b3789 Mon Sep 17 00:00:00 2001 From: Wunarg Date: Mon, 13 Dec 2021 16:09:20 +0100 Subject: [PATCH 09/19] Floaty cost comment --- Content/Data/Modifications.Body.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Content/Data/Modifications.Body.cs b/Content/Data/Modifications.Body.cs index fb7d00245..31505d935 100644 --- a/Content/Data/Modifications.Body.cs +++ b/Content/Data/Modifications.Body.cs @@ -194,6 +194,7 @@ private static void RegisterBodyModifications(ref List } } context.requirements_new.Add(Crafting.Requirement.Resource("chitin", 50)); + //TODO: Cost should be equal to mass but i cannot access mass right now } )); From 08520afe40d86583659cef82c03bdef704d41e5a Mon Sep 17 00:00:00 2001 From: Wunarg Date: Wed, 22 Dec 2021 10:43:41 +0100 Subject: [PATCH 10/19] Merge fixes --- .../Modifications.Body.cs | 30 +++++ content/Modifications/Modifications.cs | 116 ------------------ 2 files changed, 30 insertions(+), 116 deletions(-) rename Content/{Data => Modifications}/Modifications.Body.cs (85%) diff --git a/Content/Data/Modifications.Body.cs b/Content/Modifications/Modifications.Body.cs similarity index 85% rename from Content/Data/Modifications.Body.cs rename to Content/Modifications/Modifications.Body.cs index 31505d935..4b9111727 100644 --- a/Content/Data/Modifications.Body.cs +++ b/Content/Modifications/Modifications.Body.cs @@ -238,6 +238,36 @@ private static void RegisterBodyModifications(ref List context.requirements_new.Add(Crafting.Requirement.Resource("mushroom", wood_amount)); } )); + + + definitions.Add(Modification.Definition.New + ( + identifier: "body.random_activation", + category: "Utility", + name: "Random Activation", + description: "Item randomly activates on its own.", + + // This randomly causes a left click and a space bar (at the same time) + // Working examples: guns, fuse explosives, drills, mounts (yes they will use whatever is on them), melee weapons, even medkits + // Due to the wide variety of uses this has, this costs a large amount of materials + // This doesn't aim, so using anything which uses aim direction requires additional setup + + apply_0: static (ref Modification.Context context, ref Body.Data data, ref Modification.Handle handle, Span modifications) => + { + ref var random_activation = ref context.GetOrAddComponent(); + random_activation.duration += 0.20f; + }, + + apply_1: static (ref Modification.Context context, ref Body.Data data, ref Modification.Handle handle, Span modifications) => + { + context.requirements_new.Add(Crafting.Requirement.Resource("salt.motion", 10.00f)); // High cost + + if (!context.GetComponent().IsNull()) + { + context.requirements_new.Add(Crafting.Requirement.Resource("salt.motion", 10.00f)); // Even higher cost on melee weapons + } + } + )); } } } diff --git a/content/Modifications/Modifications.cs b/content/Modifications/Modifications.cs index 5069157d3..e0821b96f 100644 --- a/content/Modifications/Modifications.cs +++ b/content/Modifications/Modifications.cs @@ -394,122 +394,6 @@ private static void RegisterModifications(ref List defi } )); - definitions.Add(Modification.Definition.New - ( - identifier: "body.random_activation", - category: "Utility", - name: "Random Activation", - description: "Item randomly activates on its own.", - - // This randomly causes a left click and a space bar (at the same time) - // Working examples: guns, fuse explosives, drills, mounts (yes they will use whatever is on them), melee weapons, even medkits - // Due to the wide variety of uses this has, this costs a large amount of materials - // This doesn't aim, so using anything which uses aim direction requires additional setup - - apply_0: static (ref Modification.Context context, ref Body.Data data, ref Modification.Handle handle, Span modifications) => - { - ref var random_activation = ref context.GetOrAddComponent(); - random_activation.duration += 0.20f; - }, - - apply_1: static (ref Modification.Context context, ref Body.Data data, ref Modification.Handle handle, Span modifications) => - { - context.requirements_new.Add(Crafting.Requirement.Resource("salt.motion", 10.00f)); // High cost - - if (!context.GetComponent().IsNull()) - { - context.requirements_new.Add(Crafting.Requirement.Resource("salt.motion", 10.00f)); // Even higher cost on melee weapons - } - } - )); - - definitions.Add(Modification.Definition.New - ( - identifier: "body.bulk", - name: "Batch Production", - description: "More efficient manufacturing process by producing multiple items in bulk.", - - validate: static (ref Modification.Context context, in Body.Data data, ref Modification.Handle handle, Span modifications) => - { - ref var batch_size = ref handle.GetData(); - batch_size = Maths.Clamp(batch_size, 1, 10); - - return true; - }, - -#if CLIENT - draw_editor: static (ref Modification.Context context, in Body.Data data, ref Modification.Handle handle, Span modifications) => - { - ref var batch_size = ref handle.GetData(); - return GUI.SliderInt("##stuff", ref batch_size, 1, 10, "%d"); - }, -#endif - - can_add: static (ref Modification.Context context, in Body.Data data, ref Modification.Handle handle, Span modifications) => - { - return !modifications.HasModification(handle); - }, - - apply_1: static (ref Modification.Context context, ref Body.Data data, ref Modification.Handle handle, Span modifications) => - { - ref readonly var recipe_old = ref context.GetRecipeOld(); - ref var recipe_new = ref context.GetRecipeNew(); - - ref var batch_size = ref handle.GetData(); - - recipe_new.min *= batch_size; - recipe_new.max *= batch_size; - recipe_new.step *= batch_size; - - for (int i = 0; i < context.requirements_new.Length; i++) - { - ref var requirement = ref context.requirements_new[i]; - - if (requirement.type == Crafting.Requirement.Type.Resource) - { - ref var material = ref requirement.material.GetDefinition(); - if (material.flags.HasAll(Material.Flags.Manufactured)) - { - requirement.amount *= MathF.Pow(0.99f, batch_size - 1); - } - else - { - requirement.amount *= MathF.Pow(0.98f, batch_size - 1); - } - } - else if (requirement.type == Crafting.Requirement.Type.Work) - { - switch (requirement.work) - { - case Work.Type.Machining: - { - requirement.amount *= MathF.Pow(0.95f, batch_size - 1); - } - break; - - case Work.Type.Smithing: - { - requirement.amount *= MathF.Pow(0.93f, batch_size - 1); - } - break; - - case Work.Type.Assembling: - { - requirement.amount *= MathF.Pow(0.90f, batch_size - 1); - } - break; - - default: - { - requirement.amount *= MathF.Pow(0.95f, batch_size - 1); - } - break; - } - } - } - } - )); - definitions.Add(Modification.Definition.New ( identifier: "cover.chitin_lined", From 3feceb89648bef3dc96b19e39df047380290546a Mon Sep 17 00:00:00 2001 From: Wunarg Date: Mon, 28 Feb 2022 16:24:44 +0100 Subject: [PATCH 11/19] Updated costs and everything --- Content/Modifications/Modifications.Body.cs | 133 ++------------------ content/Modifications/Modifications.cs | 3 +- 2 files changed, 9 insertions(+), 127 deletions(-) diff --git a/Content/Modifications/Modifications.Body.cs b/Content/Modifications/Modifications.Body.cs index 4b9111727..7d0bd69bf 100644 --- a/Content/Modifications/Modifications.Body.cs +++ b/Content/Modifications/Modifications.Body.cs @@ -6,97 +6,11 @@ public sealed partial class ModInstance { private static void RegisterBodyModifications(ref List definitions) { - definitions.Add(Modification.Definition.New - ( - identifier: "body.bulk", - name: "Batch Production", - description: "More efficient manufacturing process by producing multiple items in bulk.", - - validate: static (ref Modification.Context context, in Body.Data data, ref Modification.Handle handle, Span modifications) => - { - ref var batch_size = ref handle.GetData(); - batch_size = Maths.Clamp(batch_size, 1, 10); - - return true; - }, - -#if CLIENT - draw_editor: static (ref Modification.Context context, in Body.Data data, ref Modification.Handle handle, Span modifications) => - { - ref var batch_size = ref handle.GetData(); - return GUI.SliderInt("##stuff", ref batch_size, 1, 10, "%d"); - }, -#endif - - can_add: static (ref Modification.Context context, in Body.Data data, ref Modification.Handle handle, Span modifications) => - { - return !modifications.HasModification(handle); - }, - - apply_1: static (ref Modification.Context context, ref Body.Data data, ref Modification.Handle handle, Span modifications) => - { - ref readonly var recipe_old = ref context.GetRecipeOld(); - ref var recipe_new = ref context.GetRecipeNew(); - - ref var batch_size = ref handle.GetData(); - - recipe_new.min *= batch_size; - recipe_new.max *= batch_size; - recipe_new.step *= batch_size; - - for (int i = 0; i < context.requirements_new.Length; i++) - { - ref var requirement = ref context.requirements_new[i]; - - if (requirement.type == Crafting.Requirement.Type.Resource) - { - ref var material = ref requirement.material.GetDefinition(); - if (material.flags.HasAll(Material.Flags.Manufactured)) - { - requirement.amount *= MathF.Pow(0.99f, batch_size - 1); - } - else - { - requirement.amount *= MathF.Pow(0.98f, batch_size - 1); - } - } - else if (requirement.type == Crafting.Requirement.Type.Work) - { - switch (requirement.work) - { - case Work.Type.Machining: - { - requirement.amount *= MathF.Pow(0.95f, batch_size - 1); - } - break; - - case Work.Type.Smithing: - { - requirement.amount *= MathF.Pow(0.93f, batch_size - 1); - } - break; - - case Work.Type.Assembling: - { - requirement.amount *= MathF.Pow(0.90f, batch_size - 1); - } - break; - - default: - { - requirement.amount *= MathF.Pow(0.95f, batch_size - 1); - } - break; - } - } - } - } - )); definitions.Add(Modification.Definition.New ( identifier: "body.efficient_crafting", - category: "Body", + category: "Crafting", name: "Efficient Crafting", description: "Rework the design to reduce material costs slightly.", @@ -185,7 +99,7 @@ private static void RegisterBodyModifications(ref List { data.gravity *= 0.20f; //Very fun modifer which makes an object behave very floaty - //TODO: should cost motion salt or some sort of gas, current cost is temporary + foreach (ref var requirement in context.requirements_new) { if (requirement.type == Crafting.Requirement.Type.Work) @@ -193,15 +107,14 @@ private static void RegisterBodyModifications(ref List requirement.amount *= 1.30f; } } - context.requirements_new.Add(Crafting.Requirement.Resource("chitin", 50)); - //TODO: Cost should be equal to mass but i cannot access mass right now + context.requirements_new.Add(Crafting.Requirement.Resource("salt.motion", 2.00f)); // Low ish cost, but effect is not very usefull in nearly all cases } )); definitions.Add(Modification.Definition.New ( identifier: "body.mushroom_wood", - category: "Body", + category: "Crafting", name: "Mushroom Wood", description: "Uses mushroom scraps as a wood replacement", @@ -220,17 +133,17 @@ private static void RegisterBodyModifications(ref List { if (requirement.type == Crafting.Requirement.Type.Work) { - requirement.amount *= 0.70f; + requirement.amount *= 0.50f; requirement.difficulty += 1.00f; - //Mushroom scraps are faster to process but require you to be more experienced - //This is also fine balance wise since mushroom scraps are harder to get than wood + //Mushroom scraps are faster to process but require you to be a bit more experienced + //This is also fine balance wise since mushroom scraps are much harder to get than wood } else if (requirement.type == Crafting.Requirement.Type.Resource) { ref var material = ref requirement.material.GetDefinition(); if (material.identifier == "wood") { - wood_amount += requirement.amount; + wood_amount += requirement.amount*0.50f; //It costs excactly half as much but mushroom scraps are a ton more expensive requirement = default; } } @@ -238,36 +151,6 @@ private static void RegisterBodyModifications(ref List context.requirements_new.Add(Crafting.Requirement.Resource("mushroom", wood_amount)); } )); - - - definitions.Add(Modification.Definition.New - ( - identifier: "body.random_activation", - category: "Utility", - name: "Random Activation", - description: "Item randomly activates on its own.", - - // This randomly causes a left click and a space bar (at the same time) - // Working examples: guns, fuse explosives, drills, mounts (yes they will use whatever is on them), melee weapons, even medkits - // Due to the wide variety of uses this has, this costs a large amount of materials - // This doesn't aim, so using anything which uses aim direction requires additional setup - - apply_0: static (ref Modification.Context context, ref Body.Data data, ref Modification.Handle handle, Span modifications) => - { - ref var random_activation = ref context.GetOrAddComponent(); - random_activation.duration += 0.20f; - }, - - apply_1: static (ref Modification.Context context, ref Body.Data data, ref Modification.Handle handle, Span modifications) => - { - context.requirements_new.Add(Crafting.Requirement.Resource("salt.motion", 10.00f)); // High cost - - if (!context.GetComponent().IsNull()) - { - context.requirements_new.Add(Crafting.Requirement.Resource("salt.motion", 10.00f)); // Even higher cost on melee weapons - } - } - )); } } } diff --git a/content/Modifications/Modifications.cs b/content/Modifications/Modifications.cs index 1dfcda2fd..9e3406b6f 100644 --- a/content/Modifications/Modifications.cs +++ b/content/Modifications/Modifications.cs @@ -510,8 +510,7 @@ private static void RegisterModifications(ref List defi } } )); - ->>>>>>> main + definitions.Add(Modification.Definition.New ( identifier: "cover.chitin_lined", From 326428ab32b0cf1a8806a9a97f1ffdd282f10d60 Mon Sep 17 00:00:00 2001 From: Wunarg Date: Sun, 22 May 2022 14:39:48 +0200 Subject: [PATCH 12/19] Moved Body modifiers to seperate file --- content/Modifications/Modifications.Body.cs | 256 ++++++++++++++++++ content/Modifications/Modifications.cs | 278 -------------------- 2 files changed, 256 insertions(+), 278 deletions(-) diff --git a/content/Modifications/Modifications.Body.cs b/content/Modifications/Modifications.Body.cs index 7d0bd69bf..6fff0170c 100644 --- a/content/Modifications/Modifications.Body.cs +++ b/content/Modifications/Modifications.Body.cs @@ -151,6 +151,262 @@ private static void RegisterBodyModifications(ref List context.requirements_new.Add(Crafting.Requirement.Resource("mushroom", wood_amount)); } )); + + definitions.Add(Modification.Definition.New + ( + identifier: "body.bulk", + category: "Crafting", + name: "Batch Production", + description: "More efficient manufacturing process by producing multiple items in bulk.", + + validate: static (ref Modification.Context context, in Body.Data data, ref Modification.Handle handle, Span modifications) => + { + ref var batch_size = ref handle.GetData(); + batch_size = Maths.Clamp(batch_size, 1, 10); + + return true; + }, + +#if CLIENT + draw_editor: static (ref Modification.Context context, in Body.Data data, ref Modification.Handle handle, Span modifications) => + { + ref var batch_size = ref handle.GetData(); + return GUI.SliderInt("Count", ref batch_size, 1, 10); + }, +#endif + + can_add: static (ref Modification.Context context, in Body.Data data, ref Modification.Handle handle, Span modifications) => + { + return !modifications.HasModification(handle); + }, + + apply_1: static (ref Modification.Context context, ref Body.Data data, ref Modification.Handle handle, Span modifications) => + { + ref readonly var recipe_old = ref context.GetRecipeOld(); + ref var recipe_new = ref context.GetRecipeNew(); + + ref var batch_size = ref handle.GetData(); + + recipe_new.min *= batch_size; + recipe_new.max *= batch_size; + recipe_new.step *= batch_size; + + for (int i = 0; i < context.requirements_new.Length; i++) + { + ref var requirement = ref context.requirements_new[i]; + + if (requirement.type == Crafting.Requirement.Type.Resource) + { + ref var material = ref requirement.material.GetDefinition(); + if (material.flags.HasAll(Material.Flags.Manufactured)) + { + requirement.amount *= MathF.Pow(0.99f, batch_size - 1); + } + else + { + requirement.amount *= MathF.Pow(0.98f, batch_size - 1); + } + } + else if (requirement.type == Crafting.Requirement.Type.Work) + { + switch (requirement.work) + { + case Work.Type.Machining: + { + requirement.amount *= MathF.Pow(0.95f, batch_size - 1); + } + break; + + case Work.Type.Smithing: + { + requirement.amount *= MathF.Pow(0.93f, batch_size - 1); + } + break; + + case Work.Type.Assembling: + { + requirement.amount *= MathF.Pow(0.90f, batch_size - 1); + } + break; + + default: + { + requirement.amount *= MathF.Pow(0.95f, batch_size - 1); + } + break; + } + } + } + } + )); + + definitions.Add(Modification.Definition.New + ( + identifier: "body.recycled", + category: "Crafting", + name: "Scrap-Recycled", + description: "Lowers the production cost significantly, while also reducing overall item quality.", + + validate: static (ref Modification.Context context, in Body.Data data, ref Modification.Handle handle, Span modifications) => + { + ref var ratio = ref handle.GetData(); + ratio = Maths.Clamp(ratio, 0.10f, 0.65f); + + return true; + }, + +#if CLIENT + draw_editor: static (ref Modification.Context context, in Body.Data data, ref Modification.Handle handle, Span modifications) => + { + ref var ratio = ref handle.GetData(); + return GUI.SliderFloat("Ratio", ref ratio, 0.10f, 0.65f); + }, +#endif + + can_add: static (ref Modification.Context context, in Body.Data data, ref Modification.Handle handle, Span modifications) => + { + if (modifications.HasModification(handle)) return false; + + var has_valid_material = false; + + for (int i = 0; i < context.requirements_new.Length; i++) + { + ref var requirement = ref context.requirements_new[i]; + + if (requirement.type == Crafting.Requirement.Type.Resource) + { + ref var material = ref requirement.material.GetDefinition(); + if (material.type == Material.Type.Metal || material.type == Material.Type.Wood || material.type == Material.Type.Fabric || material.type == Material.Type.Rubber) + { + has_valid_material = true; + break; + } + } + } + + return has_valid_material; + }, + + apply_0: static (ref Modification.Context context, ref Body.Data data, ref Modification.Handle handle, Span modifications) => + { + ref var ratio = ref handle.GetData(); + + ref var armor = ref context.GetComponent(); + if (!armor.IsNull()) + { + armor.toughness *= 1.00f - ratio; + armor.protection *= 1.00f - ratio; + + if (ratio > 0.15f) + { + armor.pain_modifier *= 1.00f + ratio; + } + } + + ref var health = ref context.GetComponent(); + if (!health.IsNull()) + { + health.max *= MathF.Pow(1.00f - ratio, 1.20f); + } + + ref var gun = ref context.GetComponent(); + if (!gun.IsNull()) + { + gun.stability *= MathF.Pow(1.00f - ratio, 1.30f); + gun.failure_rate *= MathF.Pow(1.00f - ratio, 1.50f); + + if (ratio > 0.10f) + { + gun.failure_rate = MathF.Max(0.00f, gun.failure_rate + (ratio * 0.50f)); + } + + gun.reload_interval *= 1.00f + (ratio * 0.20f); + gun.velocity_multiplier *= 1.00f - (ratio * 0.05f); + gun.jitter_multiplier += ratio * 1.50f; + } + + ref var melee = ref context.GetComponent(); + if (!melee.IsNull()) + { + melee.damage_base *= 1.00f - ratio; + melee.damage_bonus *= MathF.Pow(1.00f + ratio, 1.10f); + } + + ref var holdable = ref context.GetComponent(); + if (!holdable.IsNull()) + { + holdable.force_multiplier *= MathF.Pow(1.00f - (ratio * 0.50f), 1.30f); + holdable.torque_multiplier *= MathF.Pow(1.00f - (ratio * 0.10f), 1.20f); + } + + ref var attachable = ref context.GetComponent(); + if (!attachable.IsNull()) + { + attachable.force_multiplier *= MathF.Pow(1.00f - (ratio * 0.40f), 1.20f); + attachable.torque_multiplier *= MathF.Pow(1.00f - (ratio * 0.05f), 1.20f); + } + }, + + apply_1: static (ref Modification.Context context, ref Body.Data data, ref Modification.Handle handle, Span modifications) => + { + ref var ratio = ref handle.GetData(); + + ref var material_scrap = ref Material.GetMaterial("scrap"); + var total_mass = 0.00f; + + for (int i = 0; i < context.requirements_new.Length; i++) + { + ref var requirement = ref context.requirements_new[i]; + + if (requirement.type == Crafting.Requirement.Type.Resource) + { + ref var material = ref requirement.material.GetDefinition(); + if (material.type == Material.Type.Metal || material.type == Material.Type.Wood || material.type == Material.Type.Fabric || material.type == Material.Type.Rubber) + { + if (material.flags.HasAll(Material.Flags.Manufactured)) + { + var removed_amount = requirement.amount * (ratio); + requirement.amount -= removed_amount; + + total_mass += material.mass_per_unit * removed_amount * 2.10f; + } + else + { + var removed_amount = requirement.amount * (ratio * 0.70f); + requirement.amount -= removed_amount; + + total_mass += material.mass_per_unit * removed_amount * 1.70f; + } + } + } + else if (requirement.type == Crafting.Requirement.Type.Work) + { + switch (requirement.work) + { + case Work.Type.Machining: + { + requirement.amount *= MathF.Pow(1.00f - ratio, 1.50f); + } + break; + + case Work.Type.Smithing: + { + requirement.amount *= MathF.Pow(1.00f - ratio, 1.30f); + } + break; + + case Work.Type.Assembling: + { + requirement.amount *= MathF.Pow(1.00f - (ratio * 0.80f), 1.10f); + } + break; + } + } + } + + context.requirements_new.Add(Crafting.Requirement.Resource(material_scrap.id, total_mass / material_scrap.mass_per_unit)); + } + )); } } } diff --git a/content/Modifications/Modifications.cs b/content/Modifications/Modifications.cs index a628471e8..fedb5a6b3 100644 --- a/content/Modifications/Modifications.cs +++ b/content/Modifications/Modifications.cs @@ -195,28 +195,6 @@ private static void RegisterModifications(ref List defi } } )); - //definitions.Add(Modification.Definition.New // Can be used on any recipe which results in a prefab - //( - // identifier: "body.efficient_crafting", - // name: "Efficient Crafting", - // description: "Rework the design to reduce material costs slightly.", - - // apply_1: static (ref Modification.Context context, ref Modification.Handle handle, Span modifications) => - // { - // foreach (ref var requirement in context.requirements_new) - // { - // if (requirement.type == Crafting.Requirement.Type.Resource) - // { - // requirement.amount *= 0.80f; - // } - // else if (requirement.type == Crafting.Requirement.Type.Work) - // { - // requirement.amount *= 1.05f; - // requirement.difficulty += 2.50f; - // } - // } - // } - //)); definitions.Add(Modification.Definition.New ( @@ -470,262 +448,6 @@ private static void RegisterModifications(ref List defi } )); - definitions.Add(Modification.Definition.New - ( - identifier: "body.bulk", - category: "Crafting", - name: "Batch Production", - description: "More efficient manufacturing process by producing multiple items in bulk.", - - validate: static (ref Modification.Context context, in Body.Data data, ref Modification.Handle handle, Span modifications) => - { - ref var batch_size = ref handle.GetData(); - batch_size = Maths.Clamp(batch_size, 1, 10); - - return true; - }, - -#if CLIENT - draw_editor: static (ref Modification.Context context, in Body.Data data, ref Modification.Handle handle, Span modifications) => - { - ref var batch_size = ref handle.GetData(); - return GUI.SliderInt("Count", ref batch_size, 1, 10); - }, -#endif - - can_add: static (ref Modification.Context context, in Body.Data data, ref Modification.Handle handle, Span modifications) => - { - return !modifications.HasModification(handle); - }, - - apply_1: static (ref Modification.Context context, ref Body.Data data, ref Modification.Handle handle, Span modifications) => - { - ref readonly var recipe_old = ref context.GetRecipeOld(); - ref var recipe_new = ref context.GetRecipeNew(); - - ref var batch_size = ref handle.GetData(); - - recipe_new.min *= batch_size; - recipe_new.max *= batch_size; - recipe_new.step *= batch_size; - - for (int i = 0; i < context.requirements_new.Length; i++) - { - ref var requirement = ref context.requirements_new[i]; - - if (requirement.type == Crafting.Requirement.Type.Resource) - { - ref var material = ref requirement.material.GetDefinition(); - if (material.flags.HasAll(Material.Flags.Manufactured)) - { - requirement.amount *= MathF.Pow(0.99f, batch_size - 1); - } - else - { - requirement.amount *= MathF.Pow(0.98f, batch_size - 1); - } - } - else if (requirement.type == Crafting.Requirement.Type.Work) - { - switch (requirement.work) - { - case Work.Type.Machining: - { - requirement.amount *= MathF.Pow(0.95f, batch_size - 1); - } - break; - - case Work.Type.Smithing: - { - requirement.amount *= MathF.Pow(0.93f, batch_size - 1); - } - break; - - case Work.Type.Assembling: - { - requirement.amount *= MathF.Pow(0.90f, batch_size - 1); - } - break; - - default: - { - requirement.amount *= MathF.Pow(0.95f, batch_size - 1); - } - break; - } - } - } - } - )); - - definitions.Add(Modification.Definition.New - ( - identifier: "body.recycled", - category: "Crafting", - name: "Scrap-Recycled", - description: "Lowers the production cost significantly, while also reducing overall item quality.", - - validate: static (ref Modification.Context context, in Body.Data data, ref Modification.Handle handle, Span modifications) => - { - ref var ratio = ref handle.GetData(); - ratio = Maths.Clamp(ratio, 0.10f, 0.65f); - - return true; - }, - -#if CLIENT - draw_editor: static (ref Modification.Context context, in Body.Data data, ref Modification.Handle handle, Span modifications) => - { - ref var ratio = ref handle.GetData(); - return GUI.SliderFloat("Ratio", ref ratio, 0.10f, 0.65f); - }, -#endif - - can_add: static (ref Modification.Context context, in Body.Data data, ref Modification.Handle handle, Span modifications) => - { - if (modifications.HasModification(handle)) return false; - - var has_valid_material = false; - - for (int i = 0; i < context.requirements_new.Length; i++) - { - ref var requirement = ref context.requirements_new[i]; - - if (requirement.type == Crafting.Requirement.Type.Resource) - { - ref var material = ref requirement.material.GetDefinition(); - if (material.type == Material.Type.Metal || material.type == Material.Type.Wood || material.type == Material.Type.Fabric || material.type == Material.Type.Rubber) - { - has_valid_material = true; - break; - } - } - } - - return has_valid_material; - }, - - apply_0: static (ref Modification.Context context, ref Body.Data data, ref Modification.Handle handle, Span modifications) => - { - ref var ratio = ref handle.GetData(); - - ref var armor = ref context.GetComponent(); - if (!armor.IsNull()) - { - armor.toughness *= 1.00f - ratio; - armor.protection *= 1.00f - ratio; - - if (ratio > 0.15f) - { - armor.pain_modifier *= 1.00f + ratio; - } - } - - ref var health = ref context.GetComponent(); - if (!health.IsNull()) - { - health.max *= MathF.Pow(1.00f - ratio, 1.20f); - } - - ref var gun = ref context.GetComponent(); - if (!gun.IsNull()) - { - gun.stability *= MathF.Pow(1.00f - ratio, 1.30f); - gun.failure_rate *= MathF.Pow(1.00f - ratio, 1.50f); - - if (ratio > 0.10f) - { - gun.failure_rate = MathF.Max(0.00f, gun.failure_rate + (ratio * 0.50f)); - } - - gun.reload_interval *= 1.00f + (ratio * 0.20f); - gun.velocity_multiplier *= 1.00f - (ratio * 0.05f); - gun.jitter_multiplier += ratio * 1.50f; - } - - ref var melee = ref context.GetComponent(); - if (!melee.IsNull()) - { - melee.damage_base *= 1.00f - ratio; - melee.damage_bonus *= MathF.Pow(1.00f + ratio, 1.10f); - } - - ref var holdable = ref context.GetComponent(); - if (!holdable.IsNull()) - { - holdable.force_multiplier *= MathF.Pow(1.00f - (ratio * 0.50f), 1.30f); - holdable.torque_multiplier *= MathF.Pow(1.00f - (ratio * 0.10f), 1.20f); - } - - ref var attachable = ref context.GetComponent(); - if (!attachable.IsNull()) - { - attachable.force_multiplier *= MathF.Pow(1.00f - (ratio * 0.40f), 1.20f); - attachable.torque_multiplier *= MathF.Pow(1.00f - (ratio * 0.05f), 1.20f); - } - }, - - apply_1: static (ref Modification.Context context, ref Body.Data data, ref Modification.Handle handle, Span modifications) => - { - ref var ratio = ref handle.GetData(); - - ref var material_scrap = ref Material.GetMaterial("scrap"); - var total_mass = 0.00f; - - for (int i = 0; i < context.requirements_new.Length; i++) - { - ref var requirement = ref context.requirements_new[i]; - - if (requirement.type == Crafting.Requirement.Type.Resource) - { - ref var material = ref requirement.material.GetDefinition(); - if (material.type == Material.Type.Metal || material.type == Material.Type.Wood || material.type == Material.Type.Fabric || material.type == Material.Type.Rubber) - { - if (material.flags.HasAll(Material.Flags.Manufactured)) - { - var removed_amount = requirement.amount * (ratio); - requirement.amount -= removed_amount; - - total_mass += material.mass_per_unit * removed_amount * 2.10f; - } - else - { - var removed_amount = requirement.amount * (ratio * 0.70f); - requirement.amount -= removed_amount; - - total_mass += material.mass_per_unit * removed_amount * 1.70f; - } - } - } - else if (requirement.type == Crafting.Requirement.Type.Work) - { - switch (requirement.work) - { - case Work.Type.Machining: - { - requirement.amount *= MathF.Pow(1.00f - ratio, 1.50f); - } - break; - - case Work.Type.Smithing: - { - requirement.amount *= MathF.Pow(1.00f - ratio, 1.30f); - } - break; - - case Work.Type.Assembling: - { - requirement.amount *= MathF.Pow(1.00f - (ratio * 0.80f), 1.10f); - } - break; - } - } - } - - context.requirements_new.Add(Crafting.Requirement.Resource(material_scrap.id, total_mass / material_scrap.mass_per_unit)); - } - )); - //definitions.Add(Modification.Definition.New //( // identifier: "holdable.compact", From fd86f840ef1a5dd853278d30618bd3a141001215 Mon Sep 17 00:00:00 2001 From: Wunarg Date: Sun, 22 May 2022 14:51:49 +0200 Subject: [PATCH 13/19] Fixed a duplicate modifier --- content/Modifications/Modifications.cs | 63 -------------------------- 1 file changed, 63 deletions(-) diff --git a/content/Modifications/Modifications.cs b/content/Modifications/Modifications.cs index fedb5a6b3..58d2997d8 100644 --- a/content/Modifications/Modifications.cs +++ b/content/Modifications/Modifications.cs @@ -133,69 +133,6 @@ private static void RegisterModifications(ref List defi } )); - definitions.Add(Modification.Definition.New - ( - identifier: "health.smirgl_structure", - category: "Protection", - name: "Smirgl-Reinforced Structure", - description: "Replaces entire structure with smirgl, greatly increasing durability.", - - can_add: static (ref Modification.Context context, in Health.Data data, ref Modification.Handle handle, Span modifications) => - { - var has_ingot = false; - foreach (ref var requirement in context.requirements_new) - { - if (requirement.type == Crafting.Requirement.Type.Resource) - { - ref var material = ref requirement.material.GetDefinition(); - if (material.flags.HasAll(Material.Flags.Ingot)) - { - has_ingot = true; - break; - } - } - } - - return has_ingot && !modifications.HasModification(handle); - }, - - apply_1: static (ref Modification.Context context, ref Health.Data data, ref Modification.Handle handle, Span modifications) => - { - var ingot_amount = 0.00f; - foreach (ref var requirement in context.requirements_new) - { - if (requirement.type == Crafting.Requirement.Type.Work) - { - requirement.amount *= 1.50f; - requirement.difficulty += 5.00f; - } - else if (requirement.type == Crafting.Requirement.Type.Resource) - { - ref var material = ref requirement.material.GetDefinition(); - if (material.flags.HasAll(Material.Flags.Ingot)) - { - ingot_amount += requirement.amount; - requirement = default; - } - } - } - - var total_amount = 3.00f + (ingot_amount * 0.30f); - context.requirements_new.Add(Crafting.Requirement.Resource("smirgl_ingot", total_amount)); - - data.max += total_amount * 1000.00f; - data.armor *= 1.35f; - data.armor += 200.00f; - - ref var body = ref context.GetComponent(); - if (!body.IsNull()) - { - ref var material = ref Material.GetMaterial("smirgl_ingot"); - body.mass_extra += total_amount * material.mass_per_unit * 0.70f; - } - } - )); - definitions.Add(Modification.Definition.New ( identifier: "fuse.length", From 7b055384d39675466adcf91e9d3f1c226ff1d7f8 Mon Sep 17 00:00:00 2001 From: Wunarg Date: Fri, 17 Jun 2022 21:08:23 +0200 Subject: [PATCH 14/19] Fixed --- .../Augments/Augments.Body.cs | 62 +++++++++---------- 1 file changed, 31 insertions(+), 31 deletions(-) rename content/Augments/Modifications.Body.cs => Content/Augments/Augments.Body.cs (75%) diff --git a/content/Augments/Modifications.Body.cs b/Content/Augments/Augments.Body.cs similarity index 75% rename from content/Augments/Modifications.Body.cs rename to Content/Augments/Augments.Body.cs index 6fff0170c..b87fbbd0a 100644 --- a/content/Augments/Modifications.Body.cs +++ b/Content/Augments/Augments.Body.cs @@ -4,10 +4,10 @@ namespace TC2.Base { public sealed partial class ModInstance { - private static void RegisterBodyModifications(ref List definitions) + private static void RegisterBodyAugments(ref List definitions) { - definitions.Add(Modification.Definition.New + definitions.Add(Augment.Definition.New ( identifier: "body.efficient_crafting", category: "Crafting", @@ -16,7 +16,7 @@ private static void RegisterBodyModifications(ref List //This modifier is nearly always an option but only with many npcs or very high skills is this actually worth while since it ramps up crafting time a ton - apply_1: static (ref Modification.Context context, ref Body.Data data, ref Modification.Handle handle, Span modifications) => + apply_1: static (ref Augment.Context context, ref Body.Data data, ref Augment.Handle handle, Span Augments) => { foreach (ref var requirement in context.requirements_new) { @@ -33,19 +33,19 @@ private static void RegisterBodyModifications(ref List } )); - definitions.Add(Modification.Definition.New + definitions.Add(Augment.Definition.New ( identifier: "body.lightweight_design", category: "Body", name: "Lightweight Design", description: "Redesign the object to have slightly less weight but be harder to produce", - can_add: static (ref Modification.Context context, in Body.Data data, ref Modification.Handle handle, Span modifications) => + can_add: static (ref Augment.Context context, in Body.Data data, ref Augment.Handle handle, Span Augments) => { - return !modifications.HasModification(handle); + return !Augments.HasAugment(handle); }, - apply_1: static (ref Modification.Context context, ref Body.Data data, ref Modification.Handle handle, Span modifications) => + apply_1: static (ref Augment.Context context, ref Body.Data data, ref Augment.Handle handle, Span Augments) => { data.mass_multiplier *= 0.80f; data.gravity *= 0.90f; @@ -60,14 +60,14 @@ private static void RegisterBodyModifications(ref List } )); - definitions.Add(Modification.Definition.New + definitions.Add(Augment.Definition.New ( identifier: "body.heavyweight_design", category: "Body", name: "Heavyweight Design", description: "Redesign the object to be a lot heavier", - apply_1: static (ref Modification.Context context, ref Body.Data data, ref Modification.Handle handle, Span modifications) => + apply_1: static (ref Augment.Context context, ref Body.Data data, ref Augment.Handle handle, Span Augments) => { data.mass_multiplier *= 2.00f; data.gravity *= 1.10f; @@ -83,19 +83,19 @@ private static void RegisterBodyModifications(ref List } )); - definitions.Add(Modification.Definition.New + definitions.Add(Augment.Definition.New ( identifier: "body.floaty", category: "Body", name: "Floaty", description: "Makes the object fall slower", - can_add: static (ref Modification.Context context, in Body.Data data, ref Modification.Handle handle, Span modifications) => + can_add: static (ref Augment.Context context, in Body.Data data, ref Augment.Handle handle, Span Augments) => { - return !modifications.HasModification(handle); + return !Augments.HasAugment(handle); }, - apply_1: static (ref Modification.Context context, ref Body.Data data, ref Modification.Handle handle, Span modifications) => + apply_1: static (ref Augment.Context context, ref Body.Data data, ref Augment.Handle handle, Span Augments) => { data.gravity *= 0.20f; //Very fun modifer which makes an object behave very floaty @@ -107,11 +107,11 @@ private static void RegisterBodyModifications(ref List requirement.amount *= 1.30f; } } - context.requirements_new.Add(Crafting.Requirement.Resource("salt.motion", 2.00f)); // Low ish cost, but effect is not very usefull in nearly all cases + context.requirements_new.Add(Crafting.Requirement.Resource("pellet.motion", 2.00f)); // Low ish cost, but effect is not very usefull in nearly all cases } )); - definitions.Add(Modification.Definition.New + definitions.Add(Augment.Definition.New ( identifier: "body.mushroom_wood", category: "Crafting", @@ -121,12 +121,12 @@ private static void RegisterBodyModifications(ref List //the purpose of this modifier is to add another use to mushroom scraps AND to allow people to use spare mushrooms as wood //this modifier is likely to be more usefull once buildings can be blueprinted - can_add: static (ref Modification.Context context, in Body.Data data, ref Modification.Handle handle, Span modifications) => + can_add: static (ref Augment.Context context, in Body.Data data, ref Augment.Handle handle, Span Augments) => { - return context.requirements_new.Has(Crafting.Requirement.Resource("wood", 0.00f)) && !modifications.HasModification(handle); + return context.requirements_new.Has(Crafting.Requirement.Resource("wood", 0.00f)) && !Augments.HasAugment(handle); }, - apply_1: static (ref Modification.Context context, ref Body.Data data, ref Modification.Handle handle, Span modifications) => + apply_1: static (ref Augment.Context context, ref Body.Data data, ref Augment.Handle handle, Span Augments) => { var wood_amount = 0.00f; foreach (ref var requirement in context.requirements_new) @@ -152,14 +152,14 @@ private static void RegisterBodyModifications(ref List } )); - definitions.Add(Modification.Definition.New + definitions.Add(Augment.Definition.New ( identifier: "body.bulk", category: "Crafting", name: "Batch Production", description: "More efficient manufacturing process by producing multiple items in bulk.", - validate: static (ref Modification.Context context, in Body.Data data, ref Modification.Handle handle, Span modifications) => + validate: static (ref Augment.Context context, in Body.Data data, ref Augment.Handle handle, Span Augments) => { ref var batch_size = ref handle.GetData(); batch_size = Maths.Clamp(batch_size, 1, 10); @@ -168,19 +168,19 @@ private static void RegisterBodyModifications(ref List }, #if CLIENT - draw_editor: static (ref Modification.Context context, in Body.Data data, ref Modification.Handle handle, Span modifications) => + draw_editor: static (ref Augment.Context context, in Body.Data data, ref Augment.Handle handle, Span Augments) => { ref var batch_size = ref handle.GetData(); return GUI.SliderInt("Count", ref batch_size, 1, 10); }, #endif - can_add: static (ref Modification.Context context, in Body.Data data, ref Modification.Handle handle, Span modifications) => + can_add: static (ref Augment.Context context, in Body.Data data, ref Augment.Handle handle, Span Augments) => { - return !modifications.HasModification(handle); + return !Augments.HasAugment(handle); }, - apply_1: static (ref Modification.Context context, ref Body.Data data, ref Modification.Handle handle, Span modifications) => + apply_1: static (ref Augment.Context context, ref Body.Data data, ref Augment.Handle handle, Span Augments) => { ref readonly var recipe_old = ref context.GetRecipeOld(); ref var recipe_new = ref context.GetRecipeNew(); @@ -240,14 +240,14 @@ private static void RegisterBodyModifications(ref List } )); - definitions.Add(Modification.Definition.New + definitions.Add(Augment.Definition.New ( identifier: "body.recycled", category: "Crafting", name: "Scrap-Recycled", description: "Lowers the production cost significantly, while also reducing overall item quality.", - validate: static (ref Modification.Context context, in Body.Data data, ref Modification.Handle handle, Span modifications) => + validate: static (ref Augment.Context context, in Body.Data data, ref Augment.Handle handle, Span Augments) => { ref var ratio = ref handle.GetData(); ratio = Maths.Clamp(ratio, 0.10f, 0.65f); @@ -256,16 +256,16 @@ private static void RegisterBodyModifications(ref List }, #if CLIENT - draw_editor: static (ref Modification.Context context, in Body.Data data, ref Modification.Handle handle, Span modifications) => + draw_editor: static (ref Augment.Context context, in Body.Data data, ref Augment.Handle handle, Span Augments) => { ref var ratio = ref handle.GetData(); return GUI.SliderFloat("Ratio", ref ratio, 0.10f, 0.65f); }, #endif - can_add: static (ref Modification.Context context, in Body.Data data, ref Modification.Handle handle, Span modifications) => + can_add: static (ref Augment.Context context, in Body.Data data, ref Augment.Handle handle, Span Augments) => { - if (modifications.HasModification(handle)) return false; + if (Augments.HasAugment(handle)) return false; var has_valid_material = false; @@ -287,7 +287,7 @@ private static void RegisterBodyModifications(ref List return has_valid_material; }, - apply_0: static (ref Modification.Context context, ref Body.Data data, ref Modification.Handle handle, Span modifications) => + apply_0: static (ref Augment.Context context, ref Body.Data data, ref Augment.Handle handle, Span Augments) => { ref var ratio = ref handle.GetData(); @@ -347,7 +347,7 @@ private static void RegisterBodyModifications(ref List } }, - apply_1: static (ref Modification.Context context, ref Body.Data data, ref Modification.Handle handle, Span modifications) => + apply_1: static (ref Augment.Context context, ref Body.Data data, ref Augment.Handle handle, Span Augments) => { ref var ratio = ref handle.GetData(); From 641b84f3cb6d46279050b7a3beb83b7557e765b5 Mon Sep 17 00:00:00 2001 From: Wunarg Date: Tue, 21 Jun 2022 18:58:34 +0200 Subject: [PATCH 15/19] Better text --- Content/Augments/Augments.Body.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Content/Augments/Augments.Body.cs b/Content/Augments/Augments.Body.cs index b87fbbd0a..4d08cf8e0 100644 --- a/Content/Augments/Augments.Body.cs +++ b/Content/Augments/Augments.Body.cs @@ -38,7 +38,7 @@ private static void RegisterBodyAugments(ref List definition identifier: "body.lightweight_design", category: "Body", name: "Lightweight Design", - description: "Redesign the object to have slightly less weight but be harder to produce", + description: "Redesign the object to have slightly less weight.", can_add: static (ref Augment.Context context, in Body.Data data, ref Augment.Handle handle, Span Augments) => { @@ -65,7 +65,7 @@ private static void RegisterBodyAugments(ref List definition identifier: "body.heavyweight_design", category: "Body", name: "Heavyweight Design", - description: "Redesign the object to be a lot heavier", + description: "Redesign the object to be a lot heavier.", apply_1: static (ref Augment.Context context, ref Body.Data data, ref Augment.Handle handle, Span Augments) => { @@ -88,7 +88,7 @@ private static void RegisterBodyAugments(ref List definition identifier: "body.floaty", category: "Body", name: "Floaty", - description: "Makes the object fall slower", + description: "Use motion pellets to reduce the effects of gravity on an object.", can_add: static (ref Augment.Context context, in Body.Data data, ref Augment.Handle handle, Span Augments) => { @@ -116,7 +116,7 @@ private static void RegisterBodyAugments(ref List definition identifier: "body.mushroom_wood", category: "Crafting", name: "Mushroom Wood", - description: "Uses mushroom scraps as a wood replacement", + description: "Uses mushroom scraps as a wood replacement.", //the purpose of this modifier is to add another use to mushroom scraps AND to allow people to use spare mushrooms as wood //this modifier is likely to be more usefull once buildings can be blueprinted From c5b4ec21eb4731110fa47d6378c59098c1e06753 Mon Sep 17 00:00:00 2001 From: Wunarg Date: Sun, 16 Oct 2022 11:13:31 +0200 Subject: [PATCH 16/19] Moved Mushroom glow and updated moved --- Content/Augments/Augments.Body.cs | 49 ++++++++++++++++++++++++------- content/Augments/Augments.cs | 27 ----------------- 2 files changed, 38 insertions(+), 38 deletions(-) diff --git a/Content/Augments/Augments.Body.cs b/Content/Augments/Augments.Body.cs index 4d08cf8e0..9b7c78392 100644 --- a/Content/Augments/Augments.Body.cs +++ b/Content/Augments/Augments.Body.cs @@ -111,6 +111,33 @@ private static void RegisterBodyAugments(ref List definition } )); + definitions.Add(Augment.Definition.New + ( + identifier: "health.mushroom_glow", + category: "Utility", + name: "Mushroom Glow", + description: "Glows in the dark.", + + can_add: static (ref Augment.Context context, in Body.Data data, ref Augment.Handle handle, Span augments) => + { + return !context.HasComponent() && !augments.HasAugment(handle); + }, + + apply_0: static (ref Augment.Context context, ref Body.Data data, ref Augment.Handle handle, Span augments) => + { + ref var light = ref context.GetOrAddComponent(); + light.color = new Vector4(0.600f, 1.000f, 0.400f, 1.250f); + light.scale = new Vector2(32.000f, 32.000f); + light.intensity = 1.000f; + light.texture = "light_invsqr"; + }, + + apply_1: static (ref Augment.Context context, ref Body.Data data, ref Augment.Handle handle, Span augments) => + { + context.requirements_new.Add(Crafting.Requirement.Resource("mushroom.green", 10.00f)); + } + )); + definitions.Add(Augment.Definition.New ( identifier: "body.mushroom_wood", @@ -159,7 +186,7 @@ private static void RegisterBodyAugments(ref List definition name: "Batch Production", description: "More efficient manufacturing process by producing multiple items in bulk.", - validate: static (ref Augment.Context context, in Body.Data data, ref Augment.Handle handle, Span Augments) => + validate: static (ref Augment.Context context, in Body.Data data, ref Augment.Handle handle, Span augments) => { ref var batch_size = ref handle.GetData(); batch_size = Maths.Clamp(batch_size, 1, 10); @@ -168,19 +195,19 @@ private static void RegisterBodyAugments(ref List definition }, #if CLIENT - draw_editor: static (ref Augment.Context context, in Body.Data data, ref Augment.Handle handle, Span Augments) => + draw_editor: static (ref Augment.Context context, in Body.Data data, ref Augment.Handle handle, Span augments) => { ref var batch_size = ref handle.GetData(); return GUI.SliderInt("Count", ref batch_size, 1, 10); }, #endif - can_add: static (ref Augment.Context context, in Body.Data data, ref Augment.Handle handle, Span Augments) => + can_add: static (ref Augment.Context context, in Body.Data data, ref Augment.Handle handle, Span augments) => { - return !Augments.HasAugment(handle); + return !augments.HasAugment(handle); }, - apply_1: static (ref Augment.Context context, ref Body.Data data, ref Augment.Handle handle, Span Augments) => + apply_1: static (ref Augment.Context context, ref Body.Data data, ref Augment.Handle handle, Span augments) => { ref readonly var recipe_old = ref context.GetRecipeOld(); ref var recipe_new = ref context.GetRecipeNew(); @@ -247,7 +274,7 @@ private static void RegisterBodyAugments(ref List definition name: "Scrap-Recycled", description: "Lowers the production cost significantly, while also reducing overall item quality.", - validate: static (ref Augment.Context context, in Body.Data data, ref Augment.Handle handle, Span Augments) => + validate: static (ref Augment.Context context, in Body.Data data, ref Augment.Handle handle, Span augments) => { ref var ratio = ref handle.GetData(); ratio = Maths.Clamp(ratio, 0.10f, 0.65f); @@ -256,16 +283,16 @@ private static void RegisterBodyAugments(ref List definition }, #if CLIENT - draw_editor: static (ref Augment.Context context, in Body.Data data, ref Augment.Handle handle, Span Augments) => + draw_editor: static (ref Augment.Context context, in Body.Data data, ref Augment.Handle handle, Span augments) => { ref var ratio = ref handle.GetData(); return GUI.SliderFloat("Ratio", ref ratio, 0.10f, 0.65f); }, #endif - can_add: static (ref Augment.Context context, in Body.Data data, ref Augment.Handle handle, Span Augments) => + can_add: static (ref Augment.Context context, in Body.Data data, ref Augment.Handle handle, Span augments) => { - if (Augments.HasAugment(handle)) return false; + if (augments.HasAugment(handle)) return false; var has_valid_material = false; @@ -287,7 +314,7 @@ private static void RegisterBodyAugments(ref List definition return has_valid_material; }, - apply_0: static (ref Augment.Context context, ref Body.Data data, ref Augment.Handle handle, Span Augments) => + apply_0: static (ref Augment.Context context, ref Body.Data data, ref Augment.Handle handle, Span augments) => { ref var ratio = ref handle.GetData(); @@ -347,7 +374,7 @@ private static void RegisterBodyAugments(ref List definition } }, - apply_1: static (ref Augment.Context context, ref Body.Data data, ref Augment.Handle handle, Span Augments) => + apply_1: static (ref Augment.Context context, ref Body.Data data, ref Augment.Handle handle, Span augments) => { ref var ratio = ref handle.GetData(); diff --git a/content/Augments/Augments.cs b/content/Augments/Augments.cs index b7cfc1580..72097672a 100644 --- a/content/Augments/Augments.cs +++ b/content/Augments/Augments.cs @@ -65,33 +65,6 @@ private static void RegisterAugments(ref List definitions) } )); - definitions.Add(Augment.Definition.New - ( - identifier: "health.mushroom_glow", - category: "Utility", - name: "Mushroom Glow", - description: "Glows in the dark.", - - can_add: static (ref Augment.Context context, in Body.Data data, ref Augment.Handle handle, Span augments) => - { - return !context.HasComponent() && !augments.HasAugment(handle); - }, - - apply_0: static (ref Augment.Context context, ref Body.Data data, ref Augment.Handle handle, Span augments) => - { - ref var light = ref context.GetOrAddComponent(); - light.color = new Vector4(0.600f, 1.000f, 0.400f, 1.250f); - light.scale = new Vector2(32.000f, 32.000f); - light.intensity = 1.000f; - light.texture = "light_invsqr"; - }, - - apply_1: static (ref Augment.Context context, ref Body.Data data, ref Augment.Handle handle, Span augments) => - { - context.requirements_new.Add(Crafting.Requirement.Resource("mushroom.green", 10.00f)); - } - )); - definitions.Add(Augment.Definition.New ( identifier: "health.varnish", From 196635fd372e573dabaf6c7c69dbed5271de9135 Mon Sep 17 00:00:00 2001 From: Wunarg Date: Sun, 16 Oct 2022 11:19:37 +0200 Subject: [PATCH 17/19] Commented out floaty --- Content/Augments/Augments.Body.cs | 58 +++++++++++++++---------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/Content/Augments/Augments.Body.cs b/Content/Augments/Augments.Body.cs index 9b7c78392..a0ca6700c 100644 --- a/Content/Augments/Augments.Body.cs +++ b/Content/Augments/Augments.Body.cs @@ -22,11 +22,11 @@ private static void RegisterBodyAugments(ref List definition { if (requirement.type == Crafting.Requirement.Type.Resource) { - requirement.amount *= 0.95f; + requirement.amount *= 0.95f; //Tiny cost reduction effect } else if (requirement.type == Crafting.Requirement.Type.Work) { - requirement.amount *= 1.50f; + requirement.amount *= 1.50f; //Large work cost increase requirement.difficulty += 3.00f; } } @@ -83,33 +83,33 @@ private static void RegisterBodyAugments(ref List definition } )); - definitions.Add(Augment.Definition.New - ( - identifier: "body.floaty", - category: "Body", - name: "Floaty", - description: "Use motion pellets to reduce the effects of gravity on an object.", - - can_add: static (ref Augment.Context context, in Body.Data data, ref Augment.Handle handle, Span Augments) => - { - return !Augments.HasAugment(handle); - }, - - apply_1: static (ref Augment.Context context, ref Body.Data data, ref Augment.Handle handle, Span Augments) => - { - data.gravity *= 0.20f; - //Very fun modifer which makes an object behave very floaty - - foreach (ref var requirement in context.requirements_new) - { - if (requirement.type == Crafting.Requirement.Type.Work) - { - requirement.amount *= 1.30f; - } - } - context.requirements_new.Add(Crafting.Requirement.Resource("pellet.motion", 2.00f)); // Low ish cost, but effect is not very usefull in nearly all cases - } - )); + //definitions.Add(Augment.Definition.New + //( + // identifier: "body.floaty", + // category: "Body", + // name: "Floaty", + // description: "Use motion pellets to partially counteract gravity on an object.", + // + // can_add: static (ref Augment.Context context, in Body.Data data, ref Augment.Handle handle, Span Augments) => + // { + // return !Augments.HasAugment(handle); + // }, + // + // apply_1: static (ref Augment.Context context, ref Body.Data data, ref Augment.Handle handle, Span Augments) => + // { + // data.gravity *= 0.20f; + // //Very fun modifer which makes an object behave very floaty + // + // foreach (ref var requirement in context.requirements_new) + // { + // if (requirement.type == Crafting.Requirement.Type.Work) + // { + // requirement.amount *= 1.30f; + // } + // } + // context.requirements_new.Add(Crafting.Requirement.Resource("pellet.motion", 2.00f)); // Low ish cost, but effect is not very usefull in nearly all cases + // } + //)); definitions.Add(Augment.Definition.New ( From 8878580453cce8e5f597e96830e821eaf44023ae Mon Sep 17 00:00:00 2001 From: Wunarg Date: Sun, 16 Oct 2022 11:22:22 +0200 Subject: [PATCH 18/19] Merge fix --- Content/Augments/Augments.Body.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Content/Augments/Augments.Body.cs b/Content/Augments/Augments.Body.cs index a0ca6700c..84279d808 100644 --- a/Content/Augments/Augments.Body.cs +++ b/Content/Augments/Augments.Body.cs @@ -113,7 +113,7 @@ private static void RegisterBodyAugments(ref List definition definitions.Add(Augment.Definition.New ( - identifier: "health.mushroom_glow", + identifier: "utility.mushroom_glow", category: "Utility", name: "Mushroom Glow", description: "Glows in the dark.", From 185033fa3e8bcedfd263c1d2c2bc967a6f552a01 Mon Sep 17 00:00:00 2001 From: Wunarg Date: Sun, 16 Oct 2022 11:42:34 +0200 Subject: [PATCH 19/19] Fixed merge errors (was weird) --- Content/Augments/Augments.Body.cs | 6 +-- content/Augments/Augments.cs | 89 +++++++++++++++++++++++++++++-- 2 files changed, 89 insertions(+), 6 deletions(-) diff --git a/Content/Augments/Augments.Body.cs b/Content/Augments/Augments.Body.cs index 84279d808..61b2f2f88 100644 --- a/Content/Augments/Augments.Body.cs +++ b/Content/Augments/Augments.Body.cs @@ -2,11 +2,10 @@ namespace TC2.Base { - public sealed partial class ModInstance + public sealed partial class BaseMod { private static void RegisterBodyAugments(ref List definitions) { - definitions.Add(Augment.Definition.New ( identifier: "body.efficient_crafting", @@ -267,6 +266,7 @@ private static void RegisterBodyAugments(ref List definition } )); + definitions.Add(Augment.Definition.New ( identifier: "body.recycled", @@ -366,7 +366,7 @@ private static void RegisterBodyAugments(ref List definition holdable.torque_multiplier *= MathF.Pow(1.00f - (ratio * 0.10f), 1.20f); } - ref var attachable = ref context.GetComponent(); + ref var attachable = ref context.GetComponent(); if (!attachable.IsNull()) { attachable.force_multiplier *= MathF.Pow(1.00f - (ratio * 0.40f), 1.20f); diff --git a/content/Augments/Augments.cs b/content/Augments/Augments.cs index be2eca3ae..eb82f18c5 100644 --- a/content/Augments/Augments.cs +++ b/content/Augments/Augments.cs @@ -851,7 +851,7 @@ private static void RegisterAugments(ref List definitions) }, apply_1: static (ref Augment.Context context, ref Pill.Data data, ref Augment.Handle handle, Span augments) => - { + { ref var value = ref handle.GetData(); ref var consumable = ref context.GetComponent(); @@ -861,12 +861,95 @@ private static void RegisterAugments(ref List definitions) } } )); - } - } + + definitions.Add(Augment.Definition.New + ( + identifier: "holdable.attachable", + category: "Utility", + name: "Attachment Connector", + description: "Enables mounting this item to attachment slots.", + + validate: static (ref Augment.Context context, in Holdable.Data data, ref Augment.Handle handle, Span augments) => + { + ref var offset = ref handle.GetData(); + + offset.X = Maths.Clamp(offset.X, -1.00f, 1.00f); + offset.Y = Maths.Clamp(offset.Y, -1.00f, 1.00f); + offset = Maths.Snap(offset, 0.125f); + + return true; + }, + + can_add: static (ref Augment.Context context, in Holdable.Data data, ref Augment.Handle handle, Span augments) => + { + return !context.HasComponent(); + }, + +#if CLIENT + draw_editor: static (ref Augment.Context context, in Holdable.Data data, ref Augment.Handle handle, Span augments) => + { + ref var offset = ref handle.GetData(); + + var size = GUI.GetRemainingSpace(); + size.X *= 0.50f; + + var dirty = false; + dirty |= GUI.Picker("offset", size: size, ref offset, min: new Vector2(-1.00f, -1.00f), max: new Vector2(1.00f, 1.00f)); + + //dirty |= GUI.SliderFloat("X", ref offset.X, -0.50f, 0.50f, size: size); + //GUI.SameLine(); + //dirty |= GUI.SliderFloat("Y", ref offset.Y, -0.20f, 0.10f, size: size); + + return dirty; + }, + + generate_sprite: static (ref Augment.Context context, in Holdable.Data data, ref Augment.Handle handle, Span augments, ref DynamicTexture.Context draw) => + { + ref var offset = ref handle.GetData(); + draw.DrawSprite("augment.attachable", offset, scale: new(1.00f, 1.00f), pivot: new(0.50f, 0.50f)); + }, +#endif + + apply_0: static (ref Augment.Context context, ref Holdable.Data data, ref Augment.Handle handle, Span augments) => + { + ref var offset = ref handle.GetData(); + + ref var attachable = ref context.GetOrAddComponent(); + if (!attachable.IsNull()) + { + attachable.offset = offset; + } }, apply_1: static (ref Augment.Context context, ref Holdable.Data data, ref Augment.Handle handle, Span augments) => { + } + )); + + definitions.Add(Augment.Definition.New + ( + identifier: "landmine.safety", + category: "Utility", + name: "Safety Markings", + description: "Prevents faction members from stepping on the land mine.", + + can_add: static (ref Augment.Context context, in LandMine.Data data, ref Augment.Handle handle, Span augments) => + { + return !augments.HasAugment(handle); + }, + + apply_0: static (ref Augment.Context context, ref LandMine.Data data, ref Augment.Handle handle, Span augments) => + { + data.flags |= LandMine.Flags.Faction; + }, + + apply_1: static (ref Augment.Context context, ref LandMine.Data data, ref Augment.Handle handle, Span augments) => + { + context.requirements_new.Add(Crafting.Requirement.Resource("paper", 1)); + } + )); + } + } }