More WIP behavior stuff
This commit is contained in:
parent
298c75d5f4
commit
b0c6c8ef6b
3 changed files with 35 additions and 20 deletions
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
|
||||
using Vintagestory.API.Common;
|
||||
using Vintagestory.API.Datastructures;
|
||||
using Vintagestory.API.MathTools;
|
||||
using Vintagestory.GameContent;
|
||||
using Vintagestory.Server;
|
||||
|
|
@ -14,40 +15,54 @@ namespace AnvilMetalRecovery
|
|||
/// <remarks>*TSSSSS!*</remarks>
|
||||
public class DirectSprayCooler_Behavior : BlockBehavior
|
||||
{
|
||||
public const string ClassName = @"directspraycooler_behavior";
|
||||
private const float coolRate = 0.5f;
|
||||
public const string ClassName = @"directspraycooler";
|
||||
private const string coolRateKey = @"coolRate";
|
||||
private const float coolRateDefault = 0.5f;
|
||||
private BlockWateringCan WateringCan;
|
||||
protected ICoreAPI CoreAPI { get; set; }
|
||||
public float CoolRate { get; private set;}
|
||||
|
||||
public DirectSprayCooler_Behavior(Block block) : base(block)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void OnLoaded(ICoreAPI api)
|
||||
{
|
||||
#if DEBUG
|
||||
api.Logger.VerboseDebug("DirectSprayCooler_Behavior::OnLoaded...");
|
||||
#endif
|
||||
base.OnLoaded(api);
|
||||
CoreAPI = api;
|
||||
|
||||
WateringCan = block as BlockWateringCan;
|
||||
if (WateringCan == null) { throw new InvalidOperationException(string.Format("Block with code '{0}' does not inherit from BlockWateringCan, which is required", block.Code)); }
|
||||
|
||||
}
|
||||
|
||||
|
||||
public override void Initialize(JsonObject properties)
|
||||
{
|
||||
#if DEBUG
|
||||
CoreAPI.Logger.VerboseDebug("DirectSprayCooler_Behavior::Initialize...");
|
||||
#endif
|
||||
|
||||
CoolRate = properties[coolRateKey].AsFloat(coolRateDefault);
|
||||
|
||||
base.Initialize(properties);
|
||||
}
|
||||
|
||||
|
||||
internal void coolContents(ItemStack itemStack)
|
||||
{
|
||||
var temperature = itemStack.Collectible.GetTemperature(CoreAPI.World, itemStack);
|
||||
if (temperature > 25f)//TODO: USE local AMBIENT Temp
|
||||
itemStack.Collectible.SetTemperature(CoreAPI.World, itemStack, (temperature - coolRate), false);
|
||||
itemStack.Collectible.SetTemperature(CoreAPI.World, itemStack, (temperature - CoolRate), false);
|
||||
#if DEBUG
|
||||
CoreAPI.Logger.VerboseDebug("Reduced Molten metal temp: {0:F1} ", temperature);
|
||||
#endif
|
||||
}
|
||||
|
||||
public override void OnLoaded(ICoreAPI api)
|
||||
{
|
||||
#if DEBUG
|
||||
api.Logger.VerboseDebug("DirectSprayCooler_Behavior::OnLoaded...");
|
||||
#endif
|
||||
base.OnLoaded(api);
|
||||
CoreAPI = api;
|
||||
/*
|
||||
WateringCan = block as BlockWateringCan;
|
||||
if (WateringCan == null)
|
||||
{ throw new InvalidOperationException(string.Format("Block with code '{0}' does not inherit from BlockWateringCan, which is required", block.Code)); }
|
||||
*/
|
||||
}
|
||||
|
||||
public override bool OnHeldInteractStep(float secondsUsed, ItemSlot slot, EntityAgent byEntity, BlockSelection blockSel, EntitySelection entitySel, ref EnumHandling handling)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
"path": "/behaviorsByType/*-burned",
|
||||
"value": [
|
||||
{
|
||||
"name": "directspraycooler_behavior"
|
||||
name: "directspraycooler", properties: { coolRate: 1.0 }
|
||||
}
|
||||
],
|
||||
"file": "game:blocktypes/clay/wateringcan.json"
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"type": "code",
|
||||
"name": "Anvil Metal Recovery+",
|
||||
"description" : "Get back lost scrap and smithing discards. Plus more.",
|
||||
"description" : "Get back smithing discards and broken tool scrap! Plus lots more.",
|
||||
"authors": ["Melchior"],
|
||||
"ModID":"metalrecovery",
|
||||
"version": "0.1.17",
|
||||
"version": "0.1.18-pre.0",
|
||||
"dependencies": {
|
||||
"game": "1.16.4",
|
||||
"game": "1.16.5",
|
||||
"survival": ""
|
||||
},
|
||||
"website": "http://nowebsite.nope"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue