using System; using UnityEngine; namespace Unity.VisualScripting { #if MODULE_PHYSICS_2D_EXISTS /// /// Called when a joint attached to the same game object broke. /// [UnitCategory("Events/Physics 2D")] public sealed class OnJointBreak2D : GameObjectEventUnit { public override Type MessageListenerType => typeof(UnityOnJointBreak2DMessageListener); protected override string hookName => EventHooks.OnJointBreak2D; /// /// The force that needs to be applied for the joint that broke to break. /// [DoNotSerialize] public ValueOutput breakForce { get; private set; } /// /// The torque that needs to be applied for the joint that broke to break. /// [DoNotSerialize] public ValueOutput breakTorque { get; private set; } /// /// The 2D rigidbody to which the other end of the joint is attached (ie, the object without the joint component). /// [DoNotSerialize] public ValueOutput connectedBody { get; private set; } /// /// The reaction force of the joint that broke. /// [DoNotSerialize] public ValueOutput reactionForce { get; private set; } /// /// The reaction torque of the joint that broke. /// [DoNotSerialize] public ValueOutput reactionTorque { get; private set; } /// /// The joint that broke. /// [DoNotSerialize] public ValueOutput joint { get; private set; } protected override void Definition() { base.Definition(); breakForce = ValueOutput(nameof(breakForce)); breakTorque = ValueOutput(nameof(breakTorque)); connectedBody = ValueOutput(nameof(connectedBody)); reactionForce = ValueOutput(nameof(reactionForce)); reactionTorque = ValueOutput(nameof(reactionTorque)); joint = ValueOutput(nameof(joint)); } protected override void AssignArguments(Flow flow, Joint2D joint) { flow.SetValue(breakForce, joint.breakForce); flow.SetValue(breakTorque, joint.breakTorque); flow.SetValue(connectedBody, joint.connectedBody); flow.SetValue(reactionForce, joint.reactionForce); flow.SetValue(reactionTorque, joint.reactionTorque); flow.SetValue(this.joint, joint); } } #endif }