-
Notifications
You must be signed in to change notification settings - Fork 3
Body modifiers #14
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
Wunarg
wants to merge
27
commits into
TFlippy:main
Choose a base branch
from
Wunarg:Body-Modifiers
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Body modifiers #14
Changes from 10 commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
292a405
New modifier page
Wunarg 9d80317
Moved old body modifiers
Wunarg 01f9076
Lightweight modifier
Wunarg 27d8a35
Heavyweight design modifier
Wunarg 7d8411f
Rebalanced old commented out modifier
Wunarg e71d9ce
Mushroom wood modifier
Wunarg 0fc1d0f
Floaty Modifier
Wunarg 8187462
Heavy weight modifier now also increases gravity to increase falling …
Wunarg 79a45e1
Floaty cost comment
Wunarg 261e197
Merge branch 'main' into Body-Modifiers
Wunarg e725033
Merge branch 'main' into Body-Modifiers
Wunarg 08520af
Merge fixes
Wunarg 3e71d84
Merge branch 'main' into Body-Modifiers
Wunarg 3feceb8
Updated costs and everything
Wunarg c15c0af
Merge branch 'main' into Body-Modifiers
Wunarg 326428a
Moved Body modifiers to seperate file
Wunarg fd86f84
Fixed a duplicate modifier
Wunarg b438674
Merge branch 'main' into Body-Modifiers
Wunarg 7b05538
Fixed
Wunarg f113ddd
Merge branch 'main' into Body-Modifiers
Wunarg 641b84f
Better text
Wunarg 93d1c9f
Merge branch 'main' into Body-Modifiers
Wunarg c5b4ec2
Moved Mushroom glow and updated moved
Wunarg 196635f
Commented out floaty
Wunarg ef516c5
Merge branch 'main' into Body-Modifiers
Wunarg 8878580
Merge fix
Wunarg 185033f
Fixed merge errors (was weird)
Wunarg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,244 @@ | ||
using TC2.Base.Components; | ||
|
||
namespace TC2.Base | ||
{ | ||
public sealed partial class ModInstance | ||
{ | ||
private static void RegisterBodyModifications(ref List<Modification.Definition> definitions) | ||
{ | ||
definitions.Add(Modification.Definition.New<Body.Data> | ||
( | ||
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<Modification.Handle> modifications) => | ||
{ | ||
ref var batch_size = ref handle.GetData<int>(); | ||
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<Modification.Handle> modifications) => | ||
{ | ||
ref var batch_size = ref handle.GetData<int>(); | ||
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<Modification.Handle> modifications) => | ||
{ | ||
return !modifications.HasModification(handle); | ||
}, | ||
|
||
apply_1: static (ref Modification.Context context, ref Body.Data data, ref Modification.Handle handle, Span<Modification.Handle> modifications) => | ||
{ | ||
ref readonly var recipe_old = ref context.GetRecipeOld(); | ||
ref var recipe_new = ref context.GetRecipeNew(); | ||
|
||
ref var batch_size = ref handle.GetData<int>(); | ||
|
||
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<Body.Data> | ||
( | ||
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<Modification.Handle> 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<Body.Data> | ||
( | ||
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<Modification.Handle> modifications) => | ||
{ | ||
return !modifications.HasModification(handle); | ||
}, | ||
|
||
apply_1: static (ref Modification.Context context, ref Body.Data data, ref Modification.Handle handle, Span<Modification.Handle> 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) | ||
{ | ||
requirement.amount *= 1.30f; | ||
requirement.difficulty += 2.0f; | ||
} | ||
} | ||
} | ||
)); | ||
|
||
definitions.Add(Modification.Definition.New<Body.Data> | ||
( | ||
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<Modification.Handle> 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) | ||
{ | ||
if (requirement.type == Crafting.Requirement.Type.Work) | ||
{ | ||
requirement.amount *= 1.10f; | ||
} | ||
} | ||
} | ||
)); | ||
|
||
definitions.Add(Modification.Definition.New<Body.Data> | ||
( | ||
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<Modification.Handle> modifications) => | ||
{ | ||
return !modifications.HasModification(handle); | ||
}, | ||
|
||
apply_1: static (ref Modification.Context context, ref Body.Data data, ref Modification.Handle handle, Span<Modification.Handle> 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)); | ||
//TODO: Cost should be equal to mass but i cannot access mass right now | ||
} | ||
)); | ||
|
||
definitions.Add(Modification.Definition.New<Body.Data> | ||
( | ||
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<Modification.Handle> 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<Modification.Handle> 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)); | ||
} | ||
)); | ||
} | ||
} | ||
} | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.