First Machine Age's Mods (Combined repo.)
Revisão | 298c75d5f431d9923380c32300afaf1d57b1e595 (tree) |
---|---|
Hora | 2022-07-08 07:36:59 |
Autor | melchior <melchior@user...> |
Commiter | melchior |
WIP New features
@@ -86,6 +86,7 @@ | ||
86 | 86 | <Compile Include="Harmony\GenericItemMortalityDetector.cs" /> |
87 | 87 | <Compile Include="Data\AMR_Config.cs" /> |
88 | 88 | <Compile Include="Data\RecoveryEntryTable.cs" /> |
89 | + <Compile Include="CollectableBehaviors\DirectSprayCooler_Behavior.cs" /> | |
89 | 90 | </ItemGroup> |
90 | 91 | <ItemGroup> |
91 | 92 | <None Include="modinfo.json"> |
@@ -125,6 +126,9 @@ | ||
125 | 126 | <None Include="assets\fma\lang\ru.json"> |
126 | 127 | <CopyToOutputDirectory>Always</CopyToOutputDirectory> |
127 | 128 | </None> |
129 | + <None Include="assets\fma\patches\wateringcan_behavior.json"> | |
130 | + <CopyToOutputDirectory>Always</CopyToOutputDirectory> | |
131 | + </None> | |
128 | 132 | </ItemGroup> |
129 | 133 | <ItemGroup> |
130 | 134 | <Folder Include="assets\" /> |
@@ -146,6 +150,7 @@ | ||
146 | 150 | <Folder Include="Data\" /> |
147 | 151 | <Folder Include="Items\" /> |
148 | 152 | <Folder Include="Harmony\" /> |
153 | + <Folder Include="CollectableBehaviors\" /> | |
149 | 154 | </ItemGroup> |
150 | 155 | <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> |
151 | 156 | </Project> |
\ No newline at end of file |
@@ -13,13 +13,15 @@ namespace AnvilMetalRecovery | ||
13 | 13 | public AMRConfig( ) |
14 | 14 | { |
15 | 15 | ToolFragmentRecovery = true; |
16 | - VoxelEquivalentValue = MetalRecoverySystem.IngotVoxelDefault; | |
16 | + VoxelEquivalentValue = MetalRecoverySystem.IngotVoxelDefault; | |
17 | + ToolRecoveryRate = 1.0f; | |
17 | 18 | } |
18 | 19 | |
19 | - public AMRConfig(bool setDefaultBL) | |
20 | + public AMRConfig(bool setDefaultBL) | |
20 | 21 | { |
21 | 22 | ToolFragmentRecovery = true; |
22 | 23 | VoxelEquivalentValue = MetalRecoverySystem.IngotVoxelDefault; |
24 | + ToolRecoveryRate = 1.0f; | |
23 | 25 | if (setDefaultBL) { |
24 | 26 | BlackList = new List<AssetLocation> { |
25 | 27 | new AssetLocation(@"game:metalplate"), |
@@ -42,13 +44,16 @@ namespace AnvilMetalRecovery | ||
42 | 44 | [ProtoMember(3)] |
43 | 45 | public List<AssetLocation> BlackList; |
44 | 46 | |
45 | - | |
47 | + [ProtoMember(4)] | |
48 | + public float ToolRecoveryRate; | |
46 | 49 | |
47 | 50 | |
48 | 51 | [ProtoAfterDeserialization] |
49 | 52 | private void ClampRange( ) |
50 | 53 | { |
51 | 54 | VoxelEquivalentValue = Math.Max(1f, Math.Min(VoxelEquivalentValue, MetalRecoverySystem.IngotVoxelDefault)); |
55 | + ToolRecoveryRate = Math.Min(1f, ToolRecoveryRate); | |
56 | + ToolRecoveryRate = Math.Max(0.1f, ToolRecoveryRate); | |
52 | 57 | } |
53 | 58 | |
54 | 59 |
@@ -101,9 +101,9 @@ namespace AnvilMetalRecovery | ||
101 | 101 | //virtual bool CanBePlacedInto(ItemStack stack, ItemSlot slot) //? |
102 | 102 | //virtual void OnModifiedInInventorySlot //Only for new-Inserts (?) |
103 | 103 | |
104 | - public void ApplyMetalProperties(RecoveryEntry recoveryData, ref ItemStack contStack) | |
104 | + public void ApplyMetalProperties(RecoveryEntry recoveryData, ref ItemStack contStack, float percentAdjust = 1.0f) | |
105 | 105 | { |
106 | - contStack.Attributes.SetInt(metalQuantityKey, ( int )recoveryData.Quantity); | |
106 | + contStack.Attributes.SetInt(metalQuantityKey, ( int )(recoveryData.Quantity * percentAdjust)); | |
107 | 107 | contStack.Attributes.SetString(metalIngotCodeKey, recoveryData.IngotCode.ToString( )); |
108 | 108 | |
109 | 109 | RegenerateCombustablePropsFromStack(contStack); |
@@ -7,10 +7,16 @@ using HarmonyLib; | ||
7 | 7 | using Vintagestory.API.Client; |
8 | 8 | using Vintagestory.API.Common; |
9 | 9 | using Vintagestory.API.Server; |
10 | +using Vintagestory.API.Util; | |
10 | 11 | using Vintagestory.Client.NoObf; |
11 | 12 | using Vintagestory.GameContent; |
12 | 13 | using Vintagestory.Server; |
13 | 14 | |
15 | +/* IDEAS / ISSUES | |
16 | + * # Watering Can (molten-metal state) Ingot Cooling *Tssss* | |
17 | + * # Ingot breaks -> Metal fragments / bits (or a blob?) | |
18 | + * # Tool-break configurable ratio | |
19 | +*/ | |
14 | 20 | namespace AnvilMetalRecovery |
15 | 21 | { |
16 | 22 | public partial class MetalRecoverySystem : ModSystem |
@@ -20,9 +26,12 @@ namespace AnvilMetalRecovery | ||
20 | 26 | internal const string metalFragmentsCode = @"fma:metal_fragments"; |
21 | 27 | internal const string metalShavingsCode = @"metal_shaving"; |
22 | 28 | internal const string itemFilterListCacheKey = @"AMR_ItemFilters"; |
29 | + | |
23 | 30 | public const float IngotVoxelDefault = 2.38f; |
24 | 31 | public const string ItemDamageChannelName = @"ItemDamageEvents"; |
25 | 32 | |
33 | + | |
34 | + | |
26 | 35 | internal IServerNetworkChannel _ConfigDownlink; |
27 | 36 | internal IClientNetworkChannel _ConfigUplink; |
28 | 37 |
@@ -101,6 +110,7 @@ namespace AnvilMetalRecovery | ||
101 | 110 | this.CoreAPI = api; |
102 | 111 | |
103 | 112 | RegisterItemMappings( ); |
113 | + RegisterBlockBehaviors( ); | |
104 | 114 | |
105 | 115 | #if DEBUG |
106 | 116 | //Harmony.DEBUG = true; |
@@ -127,9 +137,8 @@ namespace AnvilMetalRecovery | ||
127 | 137 | PrepareDownlinkChannel( ); |
128 | 138 | ServerAPI.Event.PlayerJoin += SendClientConfigMessage; |
129 | 139 | ServerAPI.Event.ServerRunPhase(EnumServerRunPhase.Shutdown, PersistServersideConfig); |
130 | - ServerAPI.Event.ServerRunPhase(EnumServerRunPhase.GameReady, MaterialDataGathering); | |
131 | - //ServerAPI.Event.ServerRunPhase(EnumServerRunPhase.WorldReady, CacheRecoveryDataTable);//This does not appear to work?! | |
132 | - ServerAPI.Event.ServerRunPhase(EnumServerRunPhase.RunGame, CacheRecoveryDataTable); | |
140 | + ServerAPI.Event.ServerRunPhase(EnumServerRunPhase.GameReady, MaterialDataGathering); | |
141 | + ServerAPI.Event.ServerRunPhase(EnumServerRunPhase.RunGame, CacheRecoveryDataTable); | |
133 | 142 | |
134 | 143 | SetupGeneralObservers( ); |
135 | 144 |
@@ -152,7 +161,7 @@ namespace AnvilMetalRecovery | ||
152 | 161 | Mod.Logger.Error("Cannot access 'ClientCoreAPI' class: API (implimentation) has changed, Contact Developer!"); |
153 | 162 | return; |
154 | 163 | } |
155 | - | |
164 | + | |
156 | 165 | ListenForServerConfigMessage( ); |
157 | 166 | Mod.Logger.VerboseDebug("Anvil Metal Recovery - should be installed..."); |
158 | 167 | } |
@@ -164,7 +173,13 @@ namespace AnvilMetalRecovery | ||
164 | 173 | this.CoreAPI.RegisterItemClass(@"SmartSmeltableItem", typeof(SmartSmeltableItem)); |
165 | 174 | } |
166 | 175 | |
167 | - | |
176 | + private void RegisterBlockBehaviors() | |
177 | + { | |
178 | + #if DEBUG | |
179 | + Mod.Logger.Debug("RegisterBlockBehaviors"); | |
180 | + #endif | |
181 | + this.CoreAPI.RegisterBlockBehaviorClass(DirectSprayCooler_Behavior.ClassName, typeof(DirectSprayCooler_Behavior)); | |
182 | + } | |
168 | 183 | |
169 | 184 | private void SetupGeneralObservers( ){ |
170 | 185 | ServerCore.Event.RegisterEventBusListener(Item_DamageEventReciever, 1.0f, ItemDamageChannelName); |
@@ -146,7 +146,7 @@ namespace AnvilMetalRecovery | ||
146 | 146 | |
147 | 147 | VariableMetalItem variableMetal = ServerAPI.World.GetItem(new AssetLocation(metalFragmentsCode)) as VariableMetalItem; |
148 | 148 | ItemStack metalFragmentsStack = new ItemStack(variableMetal, 1); |
149 | - variableMetal.ApplyMetalProperties(rec, ref metalFragmentsStack); | |
149 | + variableMetal.ApplyMetalProperties(rec, ref metalFragmentsStack, CachedConfiguration.ToolRecoveryRate); | |
150 | 150 | hotSlot.Itemstack = metalFragmentsStack; |
151 | 151 | hotSlot.Itemstack.ResolveBlockOrItem(ServerAPI.World); |
152 | 152 | hotSlot.MarkDirty( ); |
@@ -160,7 +160,7 @@ namespace AnvilMetalRecovery | ||
160 | 160 | |
161 | 161 | VariableMetalItem variableMetal = ServerAPI.World.GetItem(new AssetLocation(metalFragmentsCode)) as VariableMetalItem; |
162 | 162 | ItemStack metalFragmentsStack = new ItemStack(variableMetal, 1); |
163 | - variableMetal.ApplyMetalProperties(rec, ref metalFragmentsStack); | |
163 | + variableMetal.ApplyMetalProperties(rec, ref metalFragmentsStack, CachedConfiguration.ToolRecoveryRate); | |
164 | 164 | if (spim.TryGiveItemstack(metalFragmentsStack, true) == false) |
165 | 165 | { |
166 | 166 | //Player with full Inv. |
@@ -8,7 +8,7 @@ | ||
8 | 8 | "textureSizes": { |
9 | 9 | }, |
10 | 10 | "textures": { |
11 | - "metal": "block/metal/ingot/lead" | |
11 | + "metal": "game:block/metal/ingot/lead" | |
12 | 12 | }, |
13 | 13 | "elements": [ |
14 | 14 | { |