Fencerotator
Overview
The Fencerotator component offers a Rotate method that adjusts the orientation of a target entity (typically a fence) by a specified delta angle, falls back to the default fence rotation tuning if no delta is provided, and triggers a visual effect and event upon completion.
Dependencies & Tags
- Uses
TUNING.FENCE_DEFAULT_ROTATIONfor default rotation delta. - Pushes the
"fencerotated"event on the owner instance. - Spawns the
"fence_rotator_fx"prefab at the target's world position.
No explicit component dependencies (e.g., AddComponent) are declared in the source.
Properties
No public properties are initialized in the constructor or elsewhere; the component only stores a reference to the owner instance.
Main Functions
Rotate(target, delta)
- Description: Rotates the
targetentity’s orientation bydeltadegrees (or the default fence rotation value ifdeltais omitted). Iftarget.SetOrientationexists, it is used; otherwise,target.Transform:SetRotationis called. After rotation, it triggers the"fencerotated"event and spawns a visual effect at the target’s position. - Parameters:
target: The entity to rotate. Must have aTransformcomponent and optionallySetOrientationor rely onTransform:SetRotation. Ifnil, the function exits early.delta(optional, number): The angular change to apply, in degrees. Defaults toTUNING.FENCE_DEFAULT_ROTATIONif omitted.
Events & Listeners
- Pushes event
"fencerotated"on the owner instance (self.inst) after rotation completes. - Listens to no events (no
inst:ListenForEventcalls present).