移除水

This commit is contained in:
2025-06-21 21:58:06 +08:00
parent d61516a576
commit e9f76d0f11
1566 changed files with 9218 additions and 300913 deletions

View File

@@ -1,9 +0,0 @@
// Crest Water System
// Copyright © 2024 Wave Harmonic. All rights reserved.
using System.Runtime.CompilerServices;
[assembly: InternalsVisibleTo("WaveHarmonic.Crest.Watercraft.Editor")]
// Define empty namespaces for when assemblies are not present.
namespace UnityEngine.InputSystem { }

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 1bffa516b4213411d9773d8f0213b3fa
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,108 +0,0 @@
// Crest Water System
// Copyright © 2024 Wave Harmonic. All rights reserved.
using UnityEngine;
using WaveHarmonic.Crest.Internal;
namespace WaveHarmonic.Crest.Watercraft
{
/// <summary>
/// A simple watercraft controlller.
/// </summary>
[@HelpURL("Manual/FloatingObjects.html#movement-controller")]
[AddComponentMenu(Constants.k_MenuPrefixPhysics + "Watercraft Controller")]
public sealed partial class Controller : ManagedBehaviour<WaterRenderer>
{
[SerializeField, HideInInspector]
#pragma warning disable 414
int _Version = 0;
#pragma warning restore 414
[Tooltip("The accompanied buoyancy script.")]
[@GenerateAPI]
[@DecoratedField, SerializeField]
FloatingObject _FloatingObject;
[Tooltip("The accompanied control script to take input from.")]
[@GenerateAPI]
[@DecoratedField, SerializeField]
Control _Control;
[Tooltip("Vertical offset from the center of mass for where move force should be applied.")]
[@GenerateAPI]
[@DecoratedField, SerializeField]
float _ForceHeightOffset;
[Tooltip("How quickly the watercraft moves from thrust.")]
[@GenerateAPI]
[@DecoratedField, SerializeField]
float _ThrustPower = 10f;
[Tooltip("How quickly the watercraft turns from steering.")]
[@GenerateAPI]
[@DecoratedField, SerializeField]
float _SteerPower = 1f;
[Tooltip("Rolls the watercraft when turning.")]
[@Range(0, 1)]
[@GenerateAPI]
[SerializeField]
float _TurningHeel = 0.35f;
[Tooltip("Applies a curve to buoyancy changes.")]
[@GenerateAPI]
[@DecoratedField, SerializeField]
AnimationCurve _BuoyancyCurveFactor = new(new Keyframe[] { new(0, 0, 0.01267637f, 0.01267637f),
new(0.6626424f, 0.1791001f, 0.8680198f, 0.8680198f), new(1, 1, 3.38758f, 3.38758f) });
float _BuoyancyFactor = 1f;
private protected override void OnStart()
{
base.OnStart();
if (_Control == null) _Control = GetComponent<Control>();
if (_FloatingObject == null) _FloatingObject = GetComponent<FloatingObject>();
}
private protected override System.Action<WaterRenderer> OnFixedUpdateMethod => OnFixedUpdate;
void OnFixedUpdate(WaterRenderer water)
{
if (!_FloatingObject.InWater) return;
UnityEngine.Profiling.Profiler.BeginSample("WaveHarmonic.Crest.Watercraft.Controller.FixedUpdate");
var input = _Control.Input;
var rb = _FloatingObject.RigidBody;
// Thrust
var forcePosition = rb.worldCenterOfMass + _ForceHeightOffset * Vector3.up;
rb.AddForceAtPosition(_ThrustPower * input.z * transform.forward, forcePosition, ForceMode.Acceleration);
// Steer
var rotation = transform.up + _TurningHeel * transform.forward;
rb.AddTorque(_SteerPower * input.x * rotation, ForceMode.Acceleration);
if (input.y > 0f)
{
if (_BuoyancyFactor < 1f)
{
_BuoyancyFactor += Time.deltaTime * 0.1f;
_BuoyancyFactor = Mathf.Clamp(_BuoyancyFactor, 0f, 1f);
_FloatingObject.BuoyancyForceStrength = _BuoyancyCurveFactor.Evaluate(_BuoyancyFactor);
}
}
else if (input.y < 0f)
{
if (_BuoyancyFactor > 0f)
{
_BuoyancyFactor -= Time.deltaTime * 0.1f;
_BuoyancyFactor = Mathf.Clamp(_BuoyancyFactor, 0f, 1f);
_FloatingObject.BuoyancyForceStrength = _BuoyancyCurveFactor.Evaluate(_BuoyancyFactor);
}
}
UnityEngine.Profiling.Profiler.EndSample();
}
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 9310a3e8fdd024e06bb9d6970db822d2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 71af4d3eb2cd144ac8e2485d50a7a191
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,19 +0,0 @@
// Crest Water System
// Copyright © 2024 Wave Harmonic. All rights reserved.
using UnityEngine;
namespace WaveHarmonic.Crest.Watercraft
{
/// <summary>
/// Controls provide input whether from the player or otherwise. Extend to
/// implement a control. See derived classes for examples.
/// </summary>
public abstract class Control : MonoBehaviour
{
/// <summary>
/// Provides input for controllers. XYZ is steer, float and drive respectively.
/// </summary>
public abstract Vector3 Input { get; }
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 5fd02b3521bc4486ea93e5a060580a53
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,35 +0,0 @@
// Crest Water System
// Copyright © 2024 Wave Harmonic. All rights reserved.
using UnityEngine;
namespace WaveHarmonic.Crest.Watercraft
{
/// <summary>
/// Constantly moves/turns.
/// </summary>
[AddComponentMenu(Constants.k_MenuPrefixPhysics + "Watercraft Control (Constant)")]
public sealed partial class FixedControl : Control
{
[SerializeField, HideInInspector]
#pragma warning disable 414
int _Version = 0;
#pragma warning restore 414
[@GenerateAPI]
[Tooltip("Constantly move."), SerializeField]
float _Move = 0;
[@GenerateAPI]
[Tooltip("Constantly turn."), SerializeField]
float _Turn = 0;
#pragma warning disable UNT0001
// Here to force the checkbox to show.
void Start() { }
#pragma warning restore UNT0001
/// <inheritdoc/>
public override Vector3 Input => isActiveAndEnabled ? new(_Turn, 0f, _Move) : Vector3.zero;
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 3a0773b7cb9424ddb87749b40d94c1ce
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: