// Copyright (C) 2023 Nicholas Maltbie
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
// associated documentation files (the "Software"), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge, publish, distribute,
// sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
// BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
using UnityEngine;
namespace nickmaltbie.OpenKCC.Utils
{
///
/// Configuration for controlling KCC Movement.
///
public interface IKCCConfig
{
///
/// Maximum bounces when moving the player.
///
int MaxBounces { get; }
///
/// Vertical snap up distance the player can snap up.
///
float VerticalSnapUp { get; }
///
/// Minimum depth required for a stair when moving onto a step.
///
float StepUpDepth { get; }
///
/// Angle power for decaying momentum when bouncing off a surface.
///
float AnglePower { get; }
///
/// Can the player snap up steps during this movement.
///
bool CanSnapUp { get; }
///
/// Position to start player movement from.
///
Vector3 Up { get; }
///
/// Collider cast for checking what the player is colliding with.
///
IColliderCast ColliderCast { get; }
///
/// Get the layer mask for computing player collisions.
///
LayerMask LayerMask { get; }
///
/// The character's collision skin width.
///
/// This is dependant on the scale of the world, but should be a small, positive non zero value.
///
/// Reference: CharacterController.skinWidth, Unity Documentation - https://docs.unity3d.com/ScriptReference/CharacterController-skinWidth.html
/// Reference: Character Controllers: Character Volume, Nvidia PhysX SDK - https://docs.nvidia.com/gameworks/content/gameworkslibrary/physx/guide/Manual/CharacterControllers.html#character-volume
///
float SkinWidth { get; }
}
///
/// fixed configuration for controlling KCC Movement.
///
public class KCCConfig : IKCCConfig
{
///
public int MaxBounces { get; set; } = 5;
///
public float VerticalSnapUp { get; set; } = 0.3f;
///
public float StepUpDepth { get; set; } = 0.3f;
///
public float AnglePower { get; set; } = 0.8f;
///
public bool CanSnapUp { get; set; } = true;
///
public Vector3 Up { get; set; } = Vector3.up;
///
public IColliderCast ColliderCast { get; set; }
///
public LayerMask LayerMask { get; set; } = ~0;
///
public float SkinWidth { get; set; } = 0.01f;
}
}