First Machine Age's Mods (Combined repo.)
Revisão | b0c6c8ef6b4707bd5565eafb2c8a61516429da49 (tree) |
---|---|
Hora | 2022-07-09 07:31:37 |
Autor | melchior <melchior@user...> |
Commiter | melchior |
More WIP behavior stuff
@@ -1,6 +1,7 @@ | ||
1 | 1 | using System; |
2 | 2 | |
3 | 3 | using Vintagestory.API.Common; |
4 | +using Vintagestory.API.Datastructures; | |
4 | 5 | using Vintagestory.API.MathTools; |
5 | 6 | using Vintagestory.GameContent; |
6 | 7 | using Vintagestory.Server; |
@@ -14,41 +15,55 @@ namespace AnvilMetalRecovery | ||
14 | 15 | /// <remarks>*TSSSSS!*</remarks> |
15 | 16 | public class DirectSprayCooler_Behavior : BlockBehavior |
16 | 17 | { |
17 | - public const string ClassName = @"directspraycooler_behavior"; | |
18 | - private const float coolRate = 0.5f; | |
18 | + public const string ClassName = @"directspraycooler"; | |
19 | + private const string coolRateKey = @"coolRate"; | |
20 | + private const float coolRateDefault = 0.5f; | |
19 | 21 | private BlockWateringCan WateringCan; |
20 | 22 | protected ICoreAPI CoreAPI { get; set; } |
23 | + public float CoolRate { get; private set;} | |
21 | 24 | |
22 | 25 | public DirectSprayCooler_Behavior(Block block) : base(block) |
23 | 26 | { |
24 | 27 | |
25 | 28 | } |
26 | 29 | |
30 | + public override void OnLoaded(ICoreAPI api) | |
31 | + { | |
32 | + #if DEBUG | |
33 | + api.Logger.VerboseDebug("DirectSprayCooler_Behavior::OnLoaded..."); | |
34 | + #endif | |
35 | + base.OnLoaded(api); | |
36 | + CoreAPI = api; | |
27 | 37 | |
28 | - internal void coolContents(ItemStack itemStack) | |
38 | + WateringCan = block as BlockWateringCan; | |
39 | + if (WateringCan == null) { throw new InvalidOperationException(string.Format("Block with code '{0}' does not inherit from BlockWateringCan, which is required", block.Code)); } | |
40 | + | |
41 | + } | |
42 | + | |
43 | + | |
44 | + public override void Initialize(JsonObject properties) | |
29 | 45 | { |
30 | - var temperature = itemStack.Collectible.GetTemperature(CoreAPI.World, itemStack); | |
31 | - if (temperature > 25f)//TODO: USE local AMBIENT Temp | |
32 | - itemStack.Collectible.SetTemperature(CoreAPI.World, itemStack, (temperature - coolRate), false); | |
33 | 46 | #if DEBUG |
34 | - CoreAPI.Logger.VerboseDebug("Reduced Molten metal temp: {0:F1} ", temperature); | |
47 | + CoreAPI.Logger.VerboseDebug("DirectSprayCooler_Behavior::Initialize..."); | |
35 | 48 | #endif |
49 | + | |
50 | + CoolRate = properties[coolRateKey].AsFloat(coolRateDefault); | |
51 | + | |
52 | + base.Initialize(properties); | |
36 | 53 | } |
37 | 54 | |
38 | - public override void OnLoaded(ICoreAPI api) | |
55 | + | |
56 | + internal void coolContents(ItemStack itemStack) | |
39 | 57 | { |
58 | + var temperature = itemStack.Collectible.GetTemperature(CoreAPI.World, itemStack); | |
59 | + if (temperature > 25f)//TODO: USE local AMBIENT Temp | |
60 | + itemStack.Collectible.SetTemperature(CoreAPI.World, itemStack, (temperature - CoolRate), false); | |
40 | 61 | #if DEBUG |
41 | - api.Logger.VerboseDebug("DirectSprayCooler_Behavior::OnLoaded..."); | |
62 | + CoreAPI.Logger.VerboseDebug("Reduced Molten metal temp: {0:F1} ", temperature); | |
42 | 63 | #endif |
43 | - base.OnLoaded(api); | |
44 | - CoreAPI = api; | |
45 | - /* | |
46 | - WateringCan = block as BlockWateringCan; | |
47 | - if (WateringCan == null) | |
48 | - { throw new InvalidOperationException(string.Format("Block with code '{0}' does not inherit from BlockWateringCan, which is required", block.Code)); } | |
49 | - */ | |
50 | 64 | } |
51 | 65 | |
66 | + | |
52 | 67 | public override bool OnHeldInteractStep(float secondsUsed, ItemSlot slot, EntityAgent byEntity, BlockSelection blockSel, EntitySelection entitySel, ref EnumHandling handling) |
53 | 68 | { |
54 | 69 | #if DEBUG |
@@ -4,7 +4,7 @@ | ||
4 | 4 | "path": "/behaviorsByType/*-burned", |
5 | 5 | "value": [ |
6 | 6 | { |
7 | - "name": "directspraycooler_behavior" | |
7 | + name: "directspraycooler", properties: { coolRate: 1.0 } | |
8 | 8 | } |
9 | 9 | ], |
10 | 10 | "file": "game:blocktypes/clay/wateringcan.json" |
@@ -1,12 +1,12 @@ | ||
1 | 1 | { |
2 | 2 | "type": "code", |
3 | 3 | "name": "Anvil Metal Recovery+", |
4 | - "description" : "Get back lost scrap and smithing discards. Plus more.", | |
4 | + "description" : "Get back smithing discards and broken tool scrap! Plus lots more.", | |
5 | 5 | "authors": ["Melchior"], |
6 | 6 | "ModID":"metalrecovery", |
7 | - "version": "0.1.17", | |
7 | + "version": "0.1.18-pre.0", | |
8 | 8 | "dependencies": { |
9 | - "game": "1.16.4", | |
9 | + "game": "1.16.5", | |
10 | 10 | "survival": "" |
11 | 11 | }, |
12 | 12 | "website": "http://nowebsite.nope" |