• 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

修订版febc126211f2719fa83411f12488aaa359a212c1 (tree)
时间2021-04-08 12:28:00
作者melchior <melchior@user...>
Commitermelchior

Log Message

Prelimiary unit value mapping

更改概述

差异

--- a/AnvilMetalRecovery/MetalRecoverySystem.cs
+++ b/AnvilMetalRecovery/MetalRecoverySystem.cs
@@ -14,10 +14,12 @@ using Vintagestory.ServerMods;
1414 namespace AnvilMetalRecovery
1515 {
1616 public partial class MetalRecoverySystem : ModSystem
17- {
17+ {
1818 internal const string anvilKey = @"Anvil";
1919 internal const float ingotVoxelEquivalent = 2.38f;
2020
21+ private Dictionary<AssetLocation, uint> itemToVoxelLookup = new Dictionary<AssetLocation, uint>();
22+
2123 private ICoreAPI CoreAPI;
2224 private ICoreServerAPI ServerAPI;
2325 private ServerCoreAPI ServerCore { get; set; }
@@ -114,23 +116,45 @@ namespace AnvilMetalRecovery
114116 //Count out Voxels in smthing recipes for all metal-ingot(?) derived items;
115117 var examineList = ServerAPI.World.SmithingRecipes.Where(sr => sr.Enabled && sr.Ingredient.Type == EnumItemClass.Item && sr.Output.Type == EnumItemClass.Item);
116118
117- foreach (var recipie in examineList) {
119+ foreach (var recipie in examineList)
120+ {
118121 CollectibleObject inputObject = recipie.Ingredient.Type == EnumItemClass.Item ? ServerAPI.World.GetItem(recipie.Ingredient.Code) : ServerAPI.World.GetBlock(recipie.Ingredient.Code) as CollectibleObject;
119122 Item outputItem = ServerAPI.World.GetItem(recipie.Output.Code);
120123
121- if (inputObject.CombustibleProps != null && inputObject.CombustibleProps.SmeltingType == EnumSmeltType.Smelt && inputObject.CombustibleProps.SmeltedRatio > 0)
122- {
124+ if (inputObject.CombustibleProps != null && inputObject.CombustibleProps.SmeltingType == EnumSmeltType.Smelt && inputObject.CombustibleProps.SmeltedRatio > 0) {
123125 //Item Input Has a metal Unit value...(Smeltable)
124126 //Resolve?
125127 int setVoxels = 0;
126- var unsprung = recipie.Voxels.OfType<bool>( );
127- setVoxels = unsprung.Count(vox => vox);
128+ setVoxels = recipie.Voxels.OfType<bool>( ).Count(vox => vox);
128129
129130 #if DEBUG
130- Mod.Logger.VerboseDebug($"{recipie.Output.Quantity}* '{outputItem.Code}' -> {setVoxels}x '{inputObject.Code}' voxel = ~{setVoxels*ingotVoxelEquivalent:F1} metal Units");
131+ Mod.Logger.VerboseDebug($"{recipie.Output.Quantity}* '{outputItem.Code}' -> {setVoxels}x '{inputObject.Code}' voxel = ~{setVoxels * ingotVoxelEquivalent:F1} metal Units");
131132 #endif
132133
133- }
134+ if (outputItem.Tool.HasValue)
135+ {
136+ itemToVoxelLookup.Add(outputItem.Code.Clone( ), (( uint )(setVoxels / recipie.Output.Quantity)));
137+ #if DEBUG
138+ Mod.Logger.VerboseDebug($"Mapped: (tool) '{outputItem.Code}' -> (tool) '{outputItem.Code}'");
139+ #endif
140+ }
141+ else
142+ {
143+ //Tool-head map to Tool item
144+ var itemToolCode = ServerAPI.World.GridRecipes.FirstOrDefault(gr => gr.Ingredients.Any(crg => crg.Value.Code.Equals(outputItem.Code)) && gr.Enabled && gr.Output.Type == EnumItemClass.Item)?.Output.Code;
145+ if (itemToolCode != null)
146+ {
147+ var itemTool = ServerAPI.World.GetItem(itemToolCode);
148+ if (itemTool.Tool.HasValue)
149+ {
150+ itemToVoxelLookup.Add(itemToolCode.Clone( ), (( uint )(setVoxels / recipie.Output.Quantity)));
151+ #if DEBUG
152+ Mod.Logger.VerboseDebug($"Mapped: (head) '{outputItem.Code}' -> (tool) '{itemToolCode}'");
153+ #endif
154+ }
155+ }
156+ }
157+ }
134158 }
135159
136160 }