// ╔════════════════════════════════════════════════════════════════╗ // ║ Copyright © 2025 NWH Coding d.o.o. All rights reserved. ║ // ║ Licensed under Unity Asset Store Terms of Service: ║ // ║ https://unity.com/legal/as-terms ║ // ║ Use permitted only in compliance with the License. ║ // ║ Distributed "AS IS", without warranty of any kind. ║ // ╚════════════════════════════════════════════════════════════════╝ #region using System; using UnityEngine; #if UNITY_EDITOR using NWH.NUI; using NWH.DWP2.ShipController; using UnityEditor; #endif #endregion namespace NWH.DWP2.ShipController { /// /// Container for all ship input states. /// Stores current values for all ship controls including throttle, steering, thrusters, and special inputs. /// [Serializable] public struct ShipInputStates { /// /// Steering input from -1 (port/left) to 1 (starboard/right). /// [Range(-1, 1)] public float steering; /// /// Primary throttle from -1 (full reverse) to 1 (full forward). /// [Range(-1, 1)] public float throttle; /// /// Secondary throttle for independent engine control. /// [Range(-1, 1)] public float throttle2; /// /// Tertiary throttle for independent engine control. /// [Range(-1, 1)] public float throttle3; /// /// Quaternary throttle for independent engine control. /// [Range(-1, 1)] public float throttle4; /// /// Stern thruster input from -1 to 1. /// [Range(-1, 1)] public float sternThruster; /// /// Bow thruster input from -1 to 1. /// [Range(-1, 1)] public float bowThruster; /// /// Submarine depth control from 0 (surface) to 1 (dive). /// [Range(0, 1)] public float submarineDepth; /// /// Sail rotation input for sailing vessels. /// [Range(-1, 1)] public float rotateSail; /// /// Engine start/stop toggle state. /// public bool engineStartStop; /// /// Anchor drop/weigh toggle state. /// public bool anchor; /// /// Change ship input for demo scenes. /// public bool changeShip; /// /// Change camera input for demo scenes. /// public bool changeCamera; /// /// Resets all input states to default values. /// public void Reset() { throttle = 0; throttle2 = 0; throttle3 = 0; throttle4 = 0; sternThruster = 0; bowThruster = 0; submarineDepth = 0; engineStartStop = false; anchor = false; } } } #if UNITY_EDITOR namespace NWH.DWP2.WaterObjects { /// /// Property drawer for InputStates. /// [CustomPropertyDrawer(typeof(ShipInputStates))] public class ShipInputStatesDrawer : NUIPropertyDrawer { public override bool OnNUI(Rect position, SerializedProperty property, GUIContent label) { if (!base.OnNUI(position, property, label)) { return false; } drawer.Field("steering"); drawer.Field("throttle"); drawer.Field("throttle2"); drawer.Field("throttle3"); drawer.Field("throttle4"); drawer.Field("bowThruster"); drawer.Field("sternThruster"); drawer.Field("submarineDepth"); drawer.Field("rotateSail"); drawer.Field("engineStartStop"); drawer.Field("anchor"); drawer.EndProperty(); return true; } } } #endif