2026-06-13 04:56:50 +01:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
2020-12-22 03:13:43 +00:00
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
|
|
using System;
|
2020-05-26 01:12:06 +01:00
|
|
|
using System.Linq;
|
|
|
|
|
using MessagePack;
|
2026-06-13 04:56:50 +01:00
|
|
|
[Inspectable, MessagePackObject, Order(-22)]
|
2020-05-26 01:12:06 +01:00
|
|
|
public class ThermotoggleData : BehaviorData
|
|
|
|
|
{
|
2026-06-13 04:56:50 +01:00
|
|
|
[InspectableTemperature, Key(1)]
|
2020-05-26 01:12:06 +01:00
|
|
|
public float TargetTemperature;
|
2026-06-13 04:56:50 +01:00
|
|
|
|
|
|
|
|
[Inspectable, Key(2)]
|
2020-05-26 01:12:06 +01:00
|
|
|
public bool HighPass;
|
2021-04-12 04:20:52 +01:00
|
|
|
|
2026-06-13 04:56:50 +01:00
|
|
|
[Inspectable, Key(3)]
|
2021-04-12 04:20:52 +01:00
|
|
|
public bool Adjustable;
|
2026-06-13 04:56:50 +01:00
|
|
|
|
2021-04-18 05:13:20 +01:00
|
|
|
public override Behavior CreateInstance(EquippedItem item)
|
|
|
|
|
{
|
|
|
|
|
return new Thermotoggle(this, item);
|
|
|
|
|
}
|
|
|
|
|
public override Behavior CreateInstance(ConsumableItemEffect item)
|
2020-05-26 01:12:06 +01:00
|
|
|
{
|
2021-04-12 04:20:52 +01:00
|
|
|
return new Thermotoggle(this, item);
|
2020-05-26 01:12:06 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-18 05:13:20 +01:00
|
|
|
public class Thermotoggle : Behavior
|
2020-05-26 01:12:06 +01:00
|
|
|
{
|
2020-06-07 03:21:47 +01:00
|
|
|
public float TargetTemperature;
|
2020-05-26 01:12:06 +01:00
|
|
|
private ThermotoggleData _data;
|
|
|
|
|
|
2021-04-12 04:20:52 +01:00
|
|
|
public ThermotoggleData ThermotoggleData => _data;
|
2020-05-26 01:12:06 +01:00
|
|
|
|
2021-04-18 05:13:20 +01:00
|
|
|
public Thermotoggle(ThermotoggleData data, EquippedItem item) : base(data, item)
|
|
|
|
|
{
|
|
|
|
|
_data = data;
|
|
|
|
|
TargetTemperature = data.TargetTemperature;
|
|
|
|
|
}
|
|
|
|
|
public Thermotoggle(ThermotoggleData data, ConsumableItemEffect item) : base(data, item)
|
2020-05-26 01:12:06 +01:00
|
|
|
{
|
|
|
|
|
_data = data;
|
2020-06-07 03:21:47 +01:00
|
|
|
TargetTemperature = data.TargetTemperature;
|
2020-05-26 01:12:06 +01:00
|
|
|
}
|
|
|
|
|
|
2021-04-18 05:13:20 +01:00
|
|
|
public override bool Execute(float dt)
|
2020-05-26 01:12:06 +01:00
|
|
|
{
|
2021-04-18 05:13:20 +01:00
|
|
|
return Temperature < TargetTemperature ^ _data.HighPass;
|
2020-05-26 01:12:06 +01:00
|
|
|
}
|
|
|
|
|
}
|