
godot.gen.godot.NavigationObstacle2D.kt Maven / Gradle / Ivy
// THIS FILE IS GENERATED! DO NOT EDIT IT MANUALLY!
@file:Suppress("PackageDirectoryMismatch", "unused", "FunctionName", "RedundantModalityModifier",
"UNCHECKED_CAST", "JoinDeclarationAndAssignment", "USELESS_CAST",
"RemoveRedundantQualifierName", "NOTHING_TO_INLINE", "NON_FINAL_MEMBER_IN_OBJECT",
"RedundantVisibilityModifier", "RedundantUnitReturnType", "MemberVisibilityCanBePrivate")
package godot
import godot.`annotation`.CoreTypeHelper
import godot.`annotation`.CoreTypeLocalCopy
import godot.`annotation`.GodotBaseType
import godot.core.PackedVector2Array
import godot.core.RID
import godot.core.VariantType.BOOL
import godot.core.VariantType.DOUBLE
import godot.core.VariantType.LONG
import godot.core.VariantType.NIL
import godot.core.VariantType.PACKED_VECTOR2_ARRAY
import godot.core.VariantType.VECTOR2
import godot.core.VariantType._RID
import godot.core.Vector2
import godot.core.memory.TransferContext
import kotlin.Boolean
import kotlin.Double
import kotlin.Float
import kotlin.Int
import kotlin.Long
import kotlin.Suppress
import kotlin.Unit
/**
* 2D Obstacle used in navigation to constrain avoidance controlled agents outside or inside an area.
*
* Tutorials:
* [$DOCS_URL/tutorials/navigation/navigation_using_navigationobstacles.html]($DOCS_URL/tutorials/navigation/navigation_using_navigationobstacles.html)
*
* 2D Obstacle used in navigation to constrain avoidance controlled agents outside or inside an area. The obstacle needs a navigation map and outline vertices defined to work correctly.
*
* If the obstacle's vertices are winded in clockwise order, avoidance agents will be pushed in by the obstacle, otherwise, avoidance agents will be pushed out. Outlines must not cross or overlap.
*
* Obstacles are **not** a replacement for a (re)baked navigation mesh. Obstacles **don't** change the resulting path from the pathfinding, obstacles only affect the navigation avoidance agent movement by altering the suggested velocity of the avoidance agent.
*
* Obstacles using vertices can warp to a new position but should not moved every frame as each move requires a rebuild of the avoidance map.
*/
@GodotBaseType
public open class NavigationObstacle2D : Node2D() {
/**
* If `true` the obstacle affects avoidance using agents.
*/
public var avoidanceEnabled: Boolean
get() {
TransferContext.writeArguments()
TransferContext.callMethod(rawPtr,
ENGINEMETHOD_ENGINECLASS_NAVIGATIONOBSTACLE2D_GET_AVOIDANCE_ENABLED, BOOL)
return (TransferContext.readReturnValue(BOOL, false) as Boolean)
}
set(`value`) {
TransferContext.writeArguments(BOOL to value)
TransferContext.callMethod(rawPtr,
ENGINEMETHOD_ENGINECLASS_NAVIGATIONOBSTACLE2D_SET_AVOIDANCE_ENABLED, NIL)
}
/**
* Sets the wanted velocity for the obstacle so other agent's can better predict the obstacle if it is moved with a velocity regularly (every frame) instead of warped to a new position. Does only affect avoidance for the obstacles [radius]. Does nothing for the obstacles static vertices.
*/
@CoreTypeLocalCopy
public var velocity: Vector2
get() {
TransferContext.writeArguments()
TransferContext.callMethod(rawPtr, ENGINEMETHOD_ENGINECLASS_NAVIGATIONOBSTACLE2D_GET_VELOCITY,
VECTOR2)
return (TransferContext.readReturnValue(VECTOR2, false) as Vector2)
}
set(`value`) {
TransferContext.writeArguments(VECTOR2 to value)
TransferContext.callMethod(rawPtr, ENGINEMETHOD_ENGINECLASS_NAVIGATIONOBSTACLE2D_SET_VELOCITY,
NIL)
}
/**
* Sets the avoidance radius for the obstacle.
*/
public var radius: Float
get() {
TransferContext.writeArguments()
TransferContext.callMethod(rawPtr, ENGINEMETHOD_ENGINECLASS_NAVIGATIONOBSTACLE2D_GET_RADIUS,
DOUBLE)
return (TransferContext.readReturnValue(DOUBLE, false) as Double).toFloat()
}
set(`value`) {
TransferContext.writeArguments(DOUBLE to value.toDouble())
TransferContext.callMethod(rawPtr, ENGINEMETHOD_ENGINECLASS_NAVIGATIONOBSTACLE2D_SET_RADIUS,
NIL)
}
/**
* The outline vertices of the obstacle. If the vertices are winded in clockwise order agents will be pushed in by the obstacle, else they will be pushed out. Outlines can not be crossed or overlap. Should the vertices using obstacle be warped to a new position agent's can not predict this movement and may get trapped inside the obstacle.
*/
public var vertices: PackedVector2Array
get() {
TransferContext.writeArguments()
TransferContext.callMethod(rawPtr, ENGINEMETHOD_ENGINECLASS_NAVIGATIONOBSTACLE2D_GET_VERTICES,
PACKED_VECTOR2_ARRAY)
return (TransferContext.readReturnValue(PACKED_VECTOR2_ARRAY, false) as PackedVector2Array)
}
set(`value`) {
TransferContext.writeArguments(PACKED_VECTOR2_ARRAY to value)
TransferContext.callMethod(rawPtr, ENGINEMETHOD_ENGINECLASS_NAVIGATIONOBSTACLE2D_SET_VERTICES,
NIL)
}
/**
* A bitfield determining the avoidance layers for this obstacle. Agent's with a matching bit on the their avoidance mask will avoid this obstacle.
*/
public var avoidanceLayers: Long
get() {
TransferContext.writeArguments()
TransferContext.callMethod(rawPtr,
ENGINEMETHOD_ENGINECLASS_NAVIGATIONOBSTACLE2D_GET_AVOIDANCE_LAYERS, LONG)
return (TransferContext.readReturnValue(LONG, false) as Long)
}
set(`value`) {
TransferContext.writeArguments(LONG to value)
TransferContext.callMethod(rawPtr,
ENGINEMETHOD_ENGINECLASS_NAVIGATIONOBSTACLE2D_SET_AVOIDANCE_LAYERS, NIL)
}
public override fun new(scriptIndex: Int): Boolean {
callConstructor(ENGINECLASS_NAVIGATIONOBSTACLE2D, scriptIndex)
return true
}
/**
* Sets the wanted velocity for the obstacle so other agent's can better predict the obstacle if it is moved with a velocity regularly (every frame) instead of warped to a new position. Does only affect avoidance for the obstacles [radius]. Does nothing for the obstacles static vertices.
*
* This is a helper function to make dealing with local copies easier.
*
* For more information, see our
* [documentation](https://godot-kotl.in/en/stable/user-guide/api-differences/#core-types).
*
* Allow to directly modify the local copy of the property and assign it back to the Object.
*
* Prefer that over writing:
* ``````
* val myCoreType = navigationobstacle2d.velocity
* //Your changes
* navigationobstacle2d.velocity = myCoreType
* ``````
*/
@CoreTypeHelper
public open fun velocityMutate(block: Vector2.() -> Unit): Vector2 = velocity.apply{
block(this)
velocity = this
}
/**
* Returns the [RID] of this obstacle on the [godot.NavigationServer2D].
*/
public fun getRid(): RID {
TransferContext.writeArguments()
TransferContext.callMethod(rawPtr, ENGINEMETHOD_ENGINECLASS_NAVIGATIONOBSTACLE2D_GET_RID, _RID)
return (TransferContext.readReturnValue(_RID, false) as RID)
}
/**
* Sets the [RID] of the navigation map this NavigationObstacle node should use and also updates the `obstacle` on the NavigationServer.
*/
public fun setNavigationMap(navigationMap: RID): Unit {
TransferContext.writeArguments(_RID to navigationMap)
TransferContext.callMethod(rawPtr,
ENGINEMETHOD_ENGINECLASS_NAVIGATIONOBSTACLE2D_SET_NAVIGATION_MAP, NIL)
}
/**
* Returns the [RID] of the navigation map for this NavigationObstacle node. This function returns always the map set on the NavigationObstacle node and not the map of the abstract obstacle on the NavigationServer. If the obstacle map is changed directly with the NavigationServer API the NavigationObstacle node will not be aware of the map change. Use [setNavigationMap] to change the navigation map for the NavigationObstacle and also update the obstacle on the NavigationServer.
*/
public fun getNavigationMap(): RID {
TransferContext.writeArguments()
TransferContext.callMethod(rawPtr,
ENGINEMETHOD_ENGINECLASS_NAVIGATIONOBSTACLE2D_GET_NAVIGATION_MAP, _RID)
return (TransferContext.readReturnValue(_RID, false) as RID)
}
/**
* Based on [value], enables or disables the specified layer in the [avoidanceLayers] bitmask, given a [layerNumber] between 1 and 32.
*/
public fun setAvoidanceLayerValue(layerNumber: Int, `value`: Boolean): Unit {
TransferContext.writeArguments(LONG to layerNumber.toLong(), BOOL to value)
TransferContext.callMethod(rawPtr,
ENGINEMETHOD_ENGINECLASS_NAVIGATIONOBSTACLE2D_SET_AVOIDANCE_LAYER_VALUE, NIL)
}
/**
* Returns whether or not the specified layer of the [avoidanceLayers] bitmask is enabled, given a [layerNumber] between 1 and 32.
*/
public fun getAvoidanceLayerValue(layerNumber: Int): Boolean {
TransferContext.writeArguments(LONG to layerNumber.toLong())
TransferContext.callMethod(rawPtr,
ENGINEMETHOD_ENGINECLASS_NAVIGATIONOBSTACLE2D_GET_AVOIDANCE_LAYER_VALUE, BOOL)
return (TransferContext.readReturnValue(BOOL, false) as Boolean)
}
public companion object
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy