First Machine Age's Mods (Combined repo.)
修订版 | 805ec5fd2154c0bbf23e660dc649b52d6c1fd5b7 (tree) |
---|---|
时间 | 2022-03-28 04:19:40 |
作者 | melchior <melchior@user...> |
Commiter | melchior |
AMR 0.1.17
3rd party Smithery mods API exposure; boog fxeis for Broken Metal
Fragments Tooltip
@@ -85,6 +85,7 @@ | ||
85 | 85 | <Compile Include="MetalRecoverySystem_Components.cs" /> |
86 | 86 | <Compile Include="Harmony\GenericItemMortalityDetector.cs" /> |
87 | 87 | <Compile Include="Data\AMR_Config.cs" /> |
88 | + <Compile Include="Data\RecoveryEntryTable.cs" /> | |
88 | 89 | </ItemGroup> |
89 | 90 | <ItemGroup> |
90 | 91 | <None Include="modinfo.json"> |
@@ -67,6 +67,7 @@ namespace AnvilMetalRecovery | ||
67 | 67 | |
68 | 68 | base.MarkDirty (false); |
69 | 69 | */ |
70 | + | |
70 | 71 | |
71 | 72 | if (splitTemp > 0 && this.WorkItemStack == null && this.SelectedRecipe == null) |
72 | 73 | { |
@@ -6,6 +6,7 @@ namespace AnvilMetalRecovery | ||
6 | 6 | { |
7 | 7 | public struct RecoveryEntry |
8 | 8 | { |
9 | + public readonly AssetLocation CollectableCode; | |
9 | 10 | public AssetLocation IngotCode; |
10 | 11 | /// <summary> |
11 | 12 | /// Metal Quantity (VOXELS) |
@@ -14,9 +15,10 @@ namespace AnvilMetalRecovery | ||
14 | 15 | public float Melting_Duration; |
15 | 16 | public int Melting_Point; |
16 | 17 | |
17 | - public RecoveryEntry(AssetLocation ig, uint qty, float dur, int point) | |
18 | + public RecoveryEntry(AssetLocation coll, AssetLocation ingot, uint qty, float dur, int point) | |
18 | 19 | { |
19 | - IngotCode = ig.Clone(); | |
20 | + CollectableCode = coll.Clone(); | |
21 | + IngotCode = ingot.Clone(); | |
20 | 22 | Quantity = qty; |
21 | 23 | Melting_Duration = dur; |
22 | 24 | Melting_Point = point; |
@@ -0,0 +1,34 @@ | ||
1 | +using System; | |
2 | +using System.Collections.Generic; | |
3 | +using System.Collections.ObjectModel; | |
4 | + | |
5 | +using Vintagestory.API.Common; | |
6 | + | |
7 | +namespace AnvilMetalRecovery | |
8 | +{ | |
9 | + public class RecoveryEntryTable : KeyedCollection<AssetLocation, RecoveryEntry> | |
10 | + { | |
11 | + protected override AssetLocation GetKeyForItem(RecoveryEntry item) => item.CollectableCode; | |
12 | + | |
13 | + public void AddReplace(RecoveryEntry entry) | |
14 | + { | |
15 | + if (Contains(entry.CollectableCode)) { Remove(entry.CollectableCode); } | |
16 | + Add(entry); | |
17 | + } | |
18 | + | |
19 | + public ICollection<AssetLocation> Keys | |
20 | + { | |
21 | + get | |
22 | + { | |
23 | + return this.Dictionary.Keys; | |
24 | + } | |
25 | + } | |
26 | + | |
27 | + public bool ContainsKey(AssetLocation code) | |
28 | + { | |
29 | + if (this.Dictionary == null || this.Dictionary.Keys == null ) return false; | |
30 | + return this.Dictionary.ContainsKey(code); | |
31 | + } | |
32 | + } | |
33 | +} | |
34 | + |
@@ -74,7 +74,7 @@ namespace AnvilMetalRecovery.Patches | ||
74 | 74 | return true; |
75 | 75 | } |
76 | 76 | |
77 | - Dictionary<AssetLocation, RecoveryEntry> itemToVoxelLookup = ( Dictionary<AssetLocation, RecoveryEntry> )world.Api.ObjectCache[MetalRecoverySystem.itemFilterListCacheKey]; | |
77 | + var itemToVoxelLookup = MetalRecoverySystem.GetCachedLookupTable(world); | |
78 | 78 | |
79 | 79 | if (itemToVoxelLookup.ContainsKey(that.Code)) return false; |
80 | 80 |
@@ -25,7 +25,7 @@ namespace AnvilMetalRecovery | ||
25 | 25 | internal IServerNetworkChannel _ConfigDownlink; |
26 | 26 | internal IClientNetworkChannel _ConfigUplink; |
27 | 27 | |
28 | - private Dictionary<AssetLocation, RecoveryEntry> itemToVoxelLookup = new Dictionary<AssetLocation, RecoveryEntry>();//Ammount & Material? | |
28 | + private RecoveryEntryTable itemToVoxelLookup = new RecoveryEntryTable();//Item Asset Code to: Ammount & Material | |
29 | 29 | |
30 | 30 | private ICoreAPI CoreAPI; |
31 | 31 | private ICoreServerAPI ServerAPI; |
@@ -48,13 +48,16 @@ namespace AnvilMetalRecovery | ||
48 | 48 | get { return CoreAPI.ModLoader.GetModSystem<RecipeRegistrySystem>( ).SmithingRecipes; } |
49 | 49 | } |
50 | 50 | |
51 | + public static RecoveryEntryTable GetCachedLookupTable(IWorldAccessor world ) | |
52 | + { | |
53 | + return ( RecoveryEntryTable )world.Api.ObjectCache[MetalRecoverySystem.itemFilterListCacheKey]; | |
54 | + } | |
51 | 55 | |
52 | - | |
53 | - /// <summary> | |
54 | - /// Valid Items that are 'recoverable' (Asset Codes) only | |
55 | - /// </summary> | |
56 | - /// <value>The item filter list.</value> | |
57 | - public List<AssetLocation> ItemFilterList { | |
56 | + /// <summary> | |
57 | + /// Valid Items that are 'recoverable' (Asset Codes) only | |
58 | + /// </summary> | |
59 | + /// <value>The item filter list.</value> | |
60 | + public List<AssetLocation> ItemFilterList { | |
58 | 61 | get |
59 | 62 | { |
60 | 63 | return itemToVoxelLookup.Keys.ToList( ); |
@@ -62,14 +65,18 @@ namespace AnvilMetalRecovery | ||
62 | 65 | } |
63 | 66 | |
64 | 67 | /// <summary> |
65 | - /// ALL Items that have were derivable from smithing recipies (and are tool / durable) | |
68 | + /// ALL Items that have were derivable from smithing recipies (and are 'tool' / have durability property) | |
66 | 69 | /// </summary>/ |
67 | 70 | /// <value>The item filter list.</value> |
68 | - public Dictionary<AssetLocation, RecoveryEntry> ItemRecoveryTable { | |
71 | + public RecoveryEntryTable ItemRecoveryTable { | |
69 | 72 | get |
70 | 73 | { |
71 | 74 | return itemToVoxelLookup; |
72 | 75 | } |
76 | + set | |
77 | + { | |
78 | + itemToVoxelLookup = value; | |
79 | + } | |
73 | 80 | } |
74 | 81 | |
75 | 82 | public override bool AllowRuntimeReload { |
@@ -126,8 +133,7 @@ namespace AnvilMetalRecovery | ||
126 | 133 | #if DEBUG |
127 | 134 | ServerAPI.RegisterCommand("durability", "edit durability of item", " (Held tool) and #", EditDurability, Privilege.give); |
128 | 135 | #endif |
129 | - | |
130 | - | |
136 | + | |
131 | 137 | } |
132 | 138 | |
133 | 139 | public override void StartClientSide(ICoreClientAPI api) |
@@ -56,7 +56,7 @@ namespace AnvilMetalRecovery | ||
56 | 56 | Mod.Logger.Warning($"Duplicate recipie '{recipie.Name}' output item: '{outputItem.Code.ToString()}'"); |
57 | 57 | } |
58 | 58 | else { |
59 | - itemToVoxelLookup.Add(outputItem.Code.Clone( ), new RecoveryEntry(metalObject.Code, | |
59 | + itemToVoxelLookup.Add(new RecoveryEntry(outputItem.Code, metalObject.Code, | |
60 | 60 | ( uint )(setVoxels / recipie.Output.Quantity), |
61 | 61 | metalObject.CombustibleProps.MeltingDuration, |
62 | 62 | metalObject.CombustibleProps.MeltingPoint) |
@@ -84,7 +84,7 @@ namespace AnvilMetalRecovery | ||
84 | 84 | Mod.Logger.Warning($"Duplicate recipie '{recipie.Name}' output tool-item: '{itemToolCode.ToString( )}'"); |
85 | 85 | } |
86 | 86 | else |
87 | - itemToVoxelLookup.Add(itemToolCode.Clone( ), new RecoveryEntry(metalObject.Code, | |
87 | + itemToVoxelLookup.Add( new RecoveryEntry(itemToolCode.Clone( ), metalObject.Code, | |
88 | 88 | ( uint )(setVoxels / recipie.Output.Quantity), |
89 | 89 | metalObject.CombustibleProps.MeltingDuration, |
90 | 90 | metalObject.CombustibleProps.MeltingPoint) |
@@ -99,7 +99,9 @@ namespace AnvilMetalRecovery | ||
99 | 99 | } |
100 | 100 | |
101 | 101 | //Cache list too |
102 | - ServerAPI.ObjectCache.Add(itemFilterListCacheKey, itemToVoxelLookup); | |
102 | + ServerAPI.ObjectCache.Add(itemFilterListCacheKey, itemToVoxelLookup); | |
103 | + | |
104 | + Mod.Logger.Event("tallied {0} smithables totaling {1} metal units from {2} smithing recipies!", itemToVoxelLookup.Count, itemToVoxelLookup.Sum(ie => ie.Quantity), this.SmithingRecipies.Count); | |
103 | 105 | } |
104 | 106 | |
105 | 107 | private bool SmithingRecipieValidator(SmithingRecipe aRecipie ) |
@@ -4,9 +4,9 @@ | ||
4 | 4 | "description" : "Get back lost scrap and smithing discards. Plus more.", |
5 | 5 | "authors": ["Melchior"], |
6 | 6 | "ModID":"metalrecovery", |
7 | - "version": "0.1.16", | |
7 | + "version": "0.1.17", | |
8 | 8 | "dependencies": { |
9 | - "game": "1.16.0", | |
9 | + "game": "1.16.4", | |
10 | 10 | "survival": "" |
11 | 11 | }, |
12 | 12 | "website": "http://nowebsite.nope" |