• R/O
  • HTTP
  • SSH
  • HTTPS

提交

标签
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

First Machine Age's Mods (Combined repo.)


Commit MetaInfo

修订版a88406ebaaa318aed3c2e00da9b28d674eb8dc44 (tree)
时间2020-06-25 06:13:34
作者melchior <melchior@user...>
Commitermelchior

Log Message

W.I.P. added shape, changes for Recipie patcher

更改概述

差异

--- a/ElementalTools/Assignments.cs
+++ b/ElementalTools/Assignments.cs
@@ -14,40 +14,37 @@ namespace ElementalTools
1414 {
1515 public partial class ElementalToolsSystem : ModSystem
1616 {
17-
17+
1818 internal const string malletItemKey = @"ItemMallet";
1919 internal const string malletAssetKey = @"mallet";
20+ internal const string hammerAssetKey = @"hammer";
2021 internal const string fmaKey = @"fma";
2122
22- private void RegisterItemClasses()
23+ private void RegisterItemClasses( )
2324 {
24- CoreAPI.RegisterItemClass(malletItemKey, typeof(ItemMallet));
25+ CoreAPI.RegisterItemClass(malletItemKey, typeof(ItemMallet));
2526 }
2627
2728
2829 private void ManipulateGridRecipies( )
2930 {
30- uint malletizedCount = 0;
31- //Thread.Sleep(1000);
3231 Mod.Logger.VerboseDebug($"Total GridRecipies: {CoreAPI.World.GridRecipes.Count}");
3332
3433
35- var alternateQuery = from gridRecipie in CoreAPI.World.GridRecipes
36- where gridRecipie.Ingredients.Any(gi => gi.Value.IsTool && gi.Value.Code.BeginsWith(GlobalConstants.DefaultDomain, @"hammer"))
34+ var nonCrushingHammerRecipies = from gridRecipie in CoreAPI.World.GridRecipes
35+ where gridRecipie.Ingredients.Any(gi => gi.Value.IsTool && gi.Value.Code.BeginsWith(GlobalConstants.DefaultDomain, hammerAssetKey))
3736 where gridRecipie.Output.Code.BeginsWith(GlobalConstants.DefaultDomain, @"nugget") == false
3837 where gridRecipie.Output.Code.BeginsWith(GlobalConstants.DefaultDomain, @"lime") == false
3938 select gridRecipie;
4039
41- Mod.Logger.VerboseDebug($"Found {alternateQuery.Count( )} Recipies using Hammer, (non ore)");
42-
43- if (alternateQuery.Any( )) {
44- foreach (var recipieToClone in alternateQuery.ToArray( ))
45- {
46- var cloneRecipie = recipieToClone.Clone( );
47-
48- cloneRecipie.Name = new AssetLocation("fma", $"clone_{malletizedCount}");
49-
50- var hammerIngredient = cloneRecipie.Ingredients.First(gi => gi.Value.IsTool && gi.Value.Code.BeginsWith(GlobalConstants.DefaultDomain, @"hammer"));
40+ CraftingRecipeIngredient hammerIngredient = new CraftingRecipeIngredient {
41+ Type = EnumItemClass.Item,
42+ //Name = "hammer",
43+ IsTool = true,
44+ Code = new AssetLocation(GlobalConstants.DefaultDomain, hammerAssetKey),
45+ Quantity = 1,
46+ //IsWildCard = false,
47+ };
5148
5249 CraftingRecipeIngredient malletIngredient = new CraftingRecipeIngredient {
5350 Type = EnumItemClass.Item,
@@ -57,57 +54,46 @@ namespace ElementalTools
5754 Quantity = 1,
5855 //IsWildCard = false,
5956 };
60- cloneRecipie.Ingredients[hammerIngredient.Key] = malletIngredient;
6157
62- cloneRecipie.ResolveIngredients(ServerCore.World);
63- ServerCore.RegisterCraftingRecipe(cloneRecipie);
64- malletizedCount++;
65- }
58+ var results = SingleSwapinReplicas(nonCrushingHammerRecipies, hammerIngredient, malletIngredient);
59+
60+
61+ Mod.Logger.VerboseDebug($"Added {results} Mallet recipies");
6662
67- Mod.Logger.VerboseDebug($"Added {malletizedCount} Mallet recipies");
68-
69-
70- /*
71- GridRecipe testRecipie = new GridRecipe {
72- IngredientPattern = "M\tF",
73- Name = new AssetLocation("fma","LogToSticks"),
74- Height = 2,
75- Width = 1,
76- Ingredients =
77- new Dictionary<string, CraftingRecipeIngredient>{
78- {"M", new CraftingRecipeIngredient{
79- Name = "mallet",
80- Type = EnumItemClass.Item,
81- Code = new AssetLocation(fmaKey, malletAssetKey),
82- IsTool = true,
83- Quantity = 1,}
84- },
85- {"F", new CraftingRecipeIngredient{
86- Name = "wood",
87- Type = EnumItemClass.Item,
88- Code = new AssetLocation(GlobalConstants.DefaultDomain,"firewood"),
89- Quantity = 1,}
90- },
91- },
92- Output = new CraftingRecipeIngredient{
93- Type = EnumItemClass.Item,
94- Quantity = 3,
95- Code = new AssetLocation(GlobalConstants.DefaultDomain,"stick"),
96- },
97- };//Needs: ResolvedItemstack <- for Non-wildcard !!!!
98- testRecipie.ResolveIngredients(ServerCore.World);
99-
100- ServerCore.RegisterCraftingRecipe(testRecipie);
101- */
10263
10364 }
10465
105- //TODO: Recycling assignment of Smeltable properties from all smith/grid/recipe forms...
10666
10767
108- }
68+ private uint SingleSwapinReplicas(IEnumerable<GridRecipe> sourceRecipies, CraftingRecipeIngredient target, CraftingRecipeIngredient replacement)
69+ {
70+ uint replicaCount = 0;
71+
72+ if (sourceRecipies.Any( ))
73+ {
74+ foreach (var recipieToClone in sourceRecipies.ToArray( )) {
75+ var cloneRecipie = recipieToClone.Clone( );
76+
77+ cloneRecipie.Name = new AssetLocation(fmaKey, $"clone_{replacement.Code.Path}_{replicaCount}");
10978
79+ var targetTag = cloneRecipie.Ingredients.FirstOrDefault(gi => gi.Value.Type == target.Type &&
80+ gi.Value.IsTool == target.IsTool &&
81+ gi.Value.Code == target.Code &&
82+ gi.Value.Quantity == target.Quantity
83+ );
84+ if (targetTag.Key != null && targetTag.Value != null) {
85+ cloneRecipie.Ingredients[targetTag.Key] = replacement;
11086
87+ cloneRecipie.ResolveIngredients(ServerCore.World);
88+ ServerCore.RegisterCraftingRecipe(cloneRecipie);
89+ replicaCount++;
90+ }
91+ else Mod.Logger.Warning("Recipe replacement - fails to locate target| {0}", target.Code);
92+
93+ }
94+ }
95+ return replicaCount;
96+ }
97+ //TODO: Recycling assignment of Smeltable properties from all smith/grid/recipe forms...
11198 }
11299 }
113-
--- a/ElementalTools/ElementalTools.csproj
+++ b/ElementalTools/ElementalTools.csproj
@@ -92,6 +92,9 @@
9292 <None Include="assets\fma\shapes\item\tools\mallet.json">
9393 <CopyToOutputDirectory>Always</CopyToOutputDirectory>
9494 </None>
95+ <None Include="assets\fma\shapes\item\tools\bit_brace.json">
96+ <CopyToOutputDirectory>Always</CopyToOutputDirectory>
97+ </None>
9598 </ItemGroup>
9699 <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
97100 </Project>
\ No newline at end of file
--- /dev/null
+++ b/ElementalTools/assets/fma/shapes/item/tools/bit_brace.json
@@ -0,0 +1,150 @@
1+{
2+ "editor": {
3+ "allAngles": false,
4+ "entityTextureMode": false
5+ },
6+ "textureWidth": 16,
7+ "textureHeight": 16,
8+ "textureSizes": {
9+ },
10+ "textures": {
11+ "steel": "block/metal/plate/steel",
12+ "tinbronze": "item/tool/material/tinbronze",
13+ "wood": "item/tool/material/wood",
14+ "brass": "item/tool/material/brass"
15+ },
16+ "elements": [
17+ {
18+ "name": "BraceC",
19+ "from": [ 5.0, 9.0, 5.0 ],
20+ "to": [ 13.0, 10.25, 6.25 ],
21+ "rotationOrigin": [ 15.0, 8.5, 9.25 ],
22+ "faces": {
23+ "north": { "texture": "#tinbronze", "uv": [ 6.75, 15.0, 14.75, 16.0 ] },
24+ "east": { "texture": "#tinbronze", "uv": [ 4.5, 9.0, 5.75, 10.0 ] },
25+ "south": { "texture": "#tinbronze", "uv": [ 3.0, 15.0, 11.0, 16.0 ] },
26+ "west": { "texture": "#tinbronze", "uv": [ 4.25, 9.5, 5.5, 10.5 ] },
27+ "up": { "texture": "#tinbronze", "uv": [ 7.75, 15.0, 15.75, 16.0 ] },
28+ "down": { "texture": "#tinbronze", "uv": [ 2.0, 15.0, 10.0, 16.0 ] }
29+ },
30+ "children": [
31+ {
32+ "name": "BraceU",
33+ "from": [ 6.75, 0.0, 1.25 ],
34+ "to": [ 8.0, 1.25, 4.25 ],
35+ "faces": {
36+ "north": { "texture": "#tinbronze", "uv": [ 5.0, 1.0, 6.25, 2.0 ] },
37+ "east": { "texture": "#tinbronze", "uv": [ 4.0, 1.0, 7.0, 2.0 ] },
38+ "south": { "texture": "#tinbronze", "uv": [ 4.75, 2.0, 6.0, 3.0 ] },
39+ "west": { "texture": "#tinbronze", "uv": [ 3.75, 1.0, 6.75, 2.0 ] },
40+ "up": { "texture": "#tinbronze", "uv": [ 4.5, 0.0, 5.75, 3.0 ] },
41+ "down": { "texture": "#tinbronze", "uv": [ 5.0, 0.5, 6.25, 3.5 ] }
42+ }
43+ },
44+ {
45+ "name": "BraceL",
46+ "from": [ 0.0, 0.0, 1.0 ],
47+ "to": [ 1.25, 1.25, 4.0 ],
48+ "faces": {
49+ "north": { "texture": "#tinbronze", "uv": [ 4.25, 10.5, 5.5, 11.5 ] },
50+ "east": { "texture": "#tinbronze", "uv": [ 2.5, 8.0, 5.5, 9.0 ] },
51+ "south": { "texture": "#tinbronze", "uv": [ 4.5, 10.0, 5.75, 11.0 ] },
52+ "west": { "texture": "#tinbronze", "uv": [ 2.75, 8.0, 5.75, 9.0 ] },
53+ "up": { "texture": "#tinbronze", "uv": [ 4.75, 8.0, 6.0, 11.0 ] },
54+ "down": { "texture": "#tinbronze", "uv": [ 4.25, 8.0, 5.5, 11.0 ] }
55+ }
56+ },
57+ {
58+ "name": "BraceUT",
59+ "from": [ 8.0, 0.0, 3.0 ],
60+ "to": [ 10.0, 1.25, 4.25 ],
61+ "faces": {
62+ "north": { "texture": "#tinbronze", "uv": [ 4.0, 1.0, 6.0, 2.0 ] },
63+ "east": { "texture": "#tinbronze", "uv": [ 4.75, 1.5, 6.0, 2.5 ] },
64+ "south": { "texture": "#tinbronze", "uv": [ 4.0, 1.0, 6.0, 2.0 ] },
65+ "west": { "texture": "#tinbronze", "uv": [ 4.75, 1.5, 6.0, 2.5 ] },
66+ "up": { "texture": "#tinbronze", "uv": [ 4.0, 1.0, 6.0, 2.0 ] },
67+ "down": { "texture": "#tinbronze", "uv": [ 4.5, 1.5, 6.5, 2.5 ] }
68+ }
69+ },
70+ {
71+ "name": "BraceLT",
72+ "from": [ -2.0, 0.0, 2.75 ],
73+ "to": [ 0.0, 1.25, 4.0 ],
74+ "faces": {
75+ "north": { "texture": "#tinbronze", "uv": [ 3.5, 9.0, 5.5, 10.0 ] },
76+ "east": { "texture": "#tinbronze", "uv": [ 5.25, 8.5, 6.5, 9.5 ] },
77+ "south": { "texture": "#tinbronze", "uv": [ 4.0, 9.0, 6.0, 10.0 ] },
78+ "west": { "texture": "#tinbronze", "uv": [ 4.25, 9.0, 5.5, 10.0 ] },
79+ "up": { "texture": "#tinbronze", "uv": [ 3.75, 10.5, 5.75, 11.5 ] },
80+ "down": { "texture": "#tinbronze", "uv": [ 4.0, 9.0, 6.0, 10.0 ] }
81+ },
82+ "children": [
83+ {
84+ "name": "BitHolder",
85+ "from": [ -2.0, -0.4, -0.4 ],
86+ "to": [ 0.0, 1.6, 1.6 ],
87+ "rotationOrigin": [ 0.0, 0.5, 0.5 ],
88+ "faces": {
89+ "north": { "texture": "#brass", "uv": [ 0.0, 0.0, 2.0, 2.0 ] },
90+ "east": { "texture": "#brass", "uv": [ 0.0, 0.0, 2.0, 2.0 ] },
91+ "south": { "texture": "#brass", "uv": [ 0.0, 0.0, 2.0, 2.0 ] },
92+ "west": { "texture": "#brass", "uv": [ 0.0, 0.0, 2.0, 2.0 ] },
93+ "up": { "texture": "#brass", "uv": [ 0.0, 0.0, 2.0, 2.0 ] },
94+ "down": { "texture": "#brass", "uv": [ 0.0, 0.0, 2.0, 2.0 ] }
95+ },
96+ "children": [
97+ {
98+ "name": "Shaft_1",
99+ "from": [ -3.0, 0.75, 0.75 ],
100+ "to": [ 0.0, 1.25, 1.25 ],
101+ "rotationOrigin": [ -1.0, 1.0, 1.0 ],
102+ "faces": {
103+ "north": { "texture": "#steel", "uv": [ 0.0, 0.0, 3.0, 0.5 ] },
104+ "east": { "texture": "#steel", "uv": [ 0.0, 0.0, 0.5, 0.5 ] },
105+ "south": { "texture": "#steel", "uv": [ 0.0, 0.0, 3.0, 0.5 ] },
106+ "west": { "texture": "#steel", "uv": [ 0.0, 0.0, 0.5, 0.5 ] },
107+ "up": { "texture": "#steel", "uv": [ 0.0, 0.0, 3.0, 0.5 ] },
108+ "down": { "texture": "#steel", "uv": [ 0.0, 0.0, 3.0, 0.5 ] }
109+ },
110+ "children": [
111+ {
112+ "name": "CuttingBit_1",
113+ "from": [ -0.27, 0.12, -0.12 ],
114+ "to": [ 0.13, 0.37, 0.28 ],
115+ "rotationOrigin": [ -0.2, 0.25, 0.25 ],
116+ "rotationX": -45.0,
117+ "rotationY": -45.0,
118+ "faces": {
119+ "north": { "texture": "#steel", "uv": [ 0.0, 0.0, 0.5, 0.5 ], "enabled": false },
120+ "east": { "texture": "#steel", "uv": [ 0.0, 0.0, 0.5, 0.5 ], "enabled": false },
121+ "south": { "texture": "#steel", "uv": [ 4.5, 8.5, 5.0, 9.0 ] },
122+ "west": { "texture": "#steel", "uv": [ 5.0, 8.5, 5.5, 9.0 ] },
123+ "up": { "texture": "#steel", "uv": [ 5.5, 8.5, 6.0, 9.0 ] },
124+ "down": { "texture": "#steel", "uv": [ 6.0, 8.5, 6.5, 9.0 ] }
125+ }
126+ }
127+ ]
128+ }
129+ ]
130+ }
131+ ]
132+ },
133+ {
134+ "name": "TopCap",
135+ "from": [ 10.0, -1.0, 2.0 ],
136+ "to": [ 11.25, 2.0, 5.0 ],
137+ "rotationOrigin": [ 10.0, 0.25, 3.75 ],
138+ "rotationX": 44.999992699547086,
139+ "faces": {
140+ "north": { "texture": "#wood", "uv": [ 3.75, 0.0, 5.0, 3.0 ] },
141+ "east": { "texture": "#wood", "uv": [ 2.5, 0.0, 5.5, 3.0 ] },
142+ "south": { "texture": "#wood", "uv": [ 2.5, 0.0, 3.75, 3.0 ] },
143+ "west": { "texture": "#wood", "uv": [ 2.5, 0.0, 5.5, 3.0 ] },
144+ "up": { "texture": "#wood", "uv": [ 3.25, 0.0, 4.5, 3.0 ] },
145+ "down": { "texture": "#wood", "uv": [ 3.25, 0.0, 4.5, 3.0 ] }
146+ }
147+ }
148+ ]
149+ }
150+ ]}
\ No newline at end of file