using System;
using UnityEngine;
namespace Unity.VisualScripting
{
#if MODULE_PHYSICS_EXISTS
///
/// Called when the controller hits a collider while performing a move.
///
[UnitCategory("Events/Physics")]
[TypeIcon(typeof(CharacterController))]
public sealed class OnControllerColliderHit : GameObjectEventUnit
{
public override Type MessageListenerType => typeof(UnityOnControllerColliderHitMessageListener);
protected override string hookName => EventHooks.OnControllerColliderHit;
///
/// The collider that was hit by the controller.
///
[DoNotSerialize]
public ValueOutput collider { get; private set; }
///
/// The controller that hit the collider.
///
[DoNotSerialize]
public ValueOutput controller { get; private set; }
///
/// The direction the CharacterController was moving in when the collision occured.
///
[DoNotSerialize]
public ValueOutput moveDirection { get; private set; }
///
/// How far the character has travelled until it hit the collider.
///
[DoNotSerialize]
public ValueOutput moveLength { get; private set; }
///
/// The normal of the surface we collided with in world space.
///
[DoNotSerialize]
public ValueOutput normal { get; private set; }
///
/// The impact point in world space.
///
[DoNotSerialize]
public ValueOutput point { get; private set; }
///
/// The impact point in world space.
///
[DoNotSerialize]
public ValueOutput data { get; private set; }
protected override void Definition()
{
base.Definition();
collider = ValueOutput(nameof(collider));
controller = ValueOutput(nameof(controller));
moveDirection = ValueOutput(nameof(moveDirection));
moveLength = ValueOutput(nameof(moveLength));
normal = ValueOutput(nameof(normal));
point = ValueOutput(nameof(point));
data = ValueOutput(nameof(data));
}
protected override void AssignArguments(Flow flow, ControllerColliderHit hitData)
{
flow.SetValue(collider, hitData.collider);
flow.SetValue(controller, hitData.controller);
flow.SetValue(moveDirection, hitData.moveDirection);
flow.SetValue(moveLength, hitData.moveLength);
flow.SetValue(normal, hitData.normal);
flow.SetValue(point, hitData.point);
flow.SetValue(data, hitData);
}
}
#endif
}