2024-07-25 05:40:31 +00:00
|
|
|
|
|
|
|
using Godot;
|
2025-02-12 16:48:15 +00:00
|
|
|
using System.Collections.Generic;
|
2024-07-25 05:40:31 +00:00
|
|
|
|
|
|
|
namespace Rokojori
|
|
|
|
{
|
2025-01-21 20:58:56 +00:00
|
|
|
[Tool]
|
|
|
|
[GlobalClass,Icon("res://addons/rokojori_action_library/Icons/SensorGroup.svg")]
|
2025-01-08 18:46:17 +00:00
|
|
|
public partial class CombineSensor : Sensor
|
2024-07-25 05:40:31 +00:00
|
|
|
{
|
|
|
|
[Export]
|
2025-02-12 16:48:15 +00:00
|
|
|
public Sensor[] sensors = new Sensor[ 0 ];
|
|
|
|
|
|
|
|
[ExportGroup("UI")]
|
|
|
|
[Export]
|
|
|
|
public bool showOnlyVisibleIcons = false;
|
|
|
|
|
|
|
|
[Export]
|
|
|
|
public int numVisible = 0;
|
2024-07-25 05:40:31 +00:00
|
|
|
|
2025-01-08 18:46:17 +00:00
|
|
|
protected override void UpdateValue()
|
2024-07-25 05:40:31 +00:00
|
|
|
{
|
|
|
|
var value = 0f;
|
|
|
|
|
|
|
|
for ( int i = 0; i < sensors.Length; i++ )
|
|
|
|
{
|
2025-01-08 18:46:17 +00:00
|
|
|
value = Mathf.Max( value, sensors[ i ].value );
|
2024-07-25 05:40:31 +00:00
|
|
|
}
|
|
|
|
|
2025-01-08 18:46:17 +00:00
|
|
|
SetFloatValue( value );
|
2024-07-25 05:40:31 +00:00
|
|
|
}
|
2025-02-12 16:48:15 +00:00
|
|
|
|
|
|
|
public override string ToString()
|
|
|
|
{
|
|
|
|
return RJLog.GetInfo( this, sensors );
|
|
|
|
}
|
|
|
|
|
|
|
|
[Export]
|
|
|
|
public InputIcon[] inputIcons = new InputIcon[ 0 ];
|
|
|
|
|
|
|
|
[Export]
|
|
|
|
public bool useInputIconsFromSensors = true;
|
|
|
|
|
|
|
|
public override List<InputIcon> GetInputIcons()
|
|
|
|
{
|
|
|
|
var list = Lists.From( inputIcons );
|
|
|
|
|
|
|
|
if ( useInputIconsFromSensors )
|
|
|
|
{
|
|
|
|
var visible = showOnlyVisibleIcons ? numVisible : sensors.Length;
|
|
|
|
|
|
|
|
for ( int i = 0; i < visible; i++ )
|
|
|
|
{
|
|
|
|
list.AddRange( sensors[ i ].GetInputIcons() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return list;
|
|
|
|
}
|
2024-07-25 05:40:31 +00:00
|
|
|
}
|
|
|
|
}
|