fuck this thing is fragile; damage/health/weapons working
This commit is contained in:
parent
98d61b0b0b
commit
d7e7a6156a
39 changed files with 61546 additions and 53877 deletions
|
@ -4,10 +4,12 @@
|
|||
|
||||
[resource]
|
||||
script = ExtResource("1_bp18i")
|
||||
name = &""
|
||||
name = &"Handgun"
|
||||
description = ""
|
||||
max_quantity = 99
|
||||
scene = "uid://ddgak6clk2i2p"
|
||||
range = 100.0
|
||||
fire_rate = 0.5
|
||||
capacity = 9
|
||||
damage = 1.0
|
||||
metadata/_custom_type_script = "uid://tv71bu1y658n"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=16 format=3 uid="uid://dl8pjf2esflbr"]
|
||||
[gd_scene load_steps=18 format=3 uid="uid://dl8pjf2esflbr"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://cersx8w4ps2sr" path="res://scenes/player.tscn" id="1_uum5p"]
|
||||
[ext_resource type="Script" uid="uid://cgbd6grygtxvj" path="res://src/main_camera.ts" id="2_0n32s"]
|
||||
|
@ -7,6 +7,7 @@
|
|||
[ext_resource type="Script" uid="uid://1w0aiix6vgbc" path="res://src/interactable/door.ts" id="3_imxmk"]
|
||||
[ext_resource type="Resource" uid="uid://5odv3n0dp2nn" path="res://resources/items/key.tres" id="4_3rynd"]
|
||||
[ext_resource type="Script" uid="uid://c7s3k1qy8pg3s" path="res://src/item_pickup.ts" id="6_qe67v"]
|
||||
[ext_resource type="Script" uid="uid://bccrrtp3mlw5i" path="res://src/health.ts" id="8_cptob"]
|
||||
|
||||
[sub_resource type="WorldBoundaryShape3D" id="WorldBoundaryShape3D_y41n8"]
|
||||
|
||||
|
@ -26,6 +27,8 @@ albedo_color = Color(0.490196, 0, 0.686275, 1)
|
|||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_l2jpa"]
|
||||
albedo_color = Color(1, 0, 0, 1)
|
||||
|
||||
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_cptob"]
|
||||
|
||||
[node name="Node3D" type="Node3D"]
|
||||
|
||||
[node name="level" parent="." instance=ExtResource("2_i3oty")]
|
||||
|
@ -98,12 +101,19 @@ text = "door key"
|
|||
font_size = 128
|
||||
outline_size = 32
|
||||
|
||||
[node name="Target" type="Node3D" parent="."]
|
||||
[node name="Target" type="StaticBody3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -6, 1, -6)
|
||||
|
||||
[node name="Health" type="Node" parent="Target"]
|
||||
script = ExtResource("8_cptob")
|
||||
metadata/_custom_type_script = "uid://bccrrtp3mlw5i"
|
||||
|
||||
[node name="MeshInstance3D" type="MeshInstance3D" parent="Target"]
|
||||
mesh = SubResource("CapsuleMesh_8d4wu")
|
||||
surface_material_override/0 = SubResource("StandardMaterial3D_l2jpa")
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="Target"]
|
||||
shape = SubResource("CapsuleShape3D_cptob")
|
||||
|
||||
[connection signal="interacted" from="Door/Interactable" to="Door" method="open"]
|
||||
[connection signal="interacted" from="DoorKey/Area3D" to="DoorKey" method="add_to_inventory"]
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
[ext_resource type="Script" uid="uid://hm6oqbvcmigk" path="res://src/player_animation.ts" id="3_26yay"]
|
||||
[ext_resource type="Script" uid="uid://ny0p0jkmlrv8" path="res://src/player_input.ts" id="3_x6527"]
|
||||
[ext_resource type="Script" uid="uid://kjthk4tj8qof" path="res://src/interactor.ts" id="5_uk7c1"]
|
||||
[ext_resource type="Script" uid="uid://dkvbawcldnok5" path="res://src/equipped_weapon.ts" id="6_eg2om"]
|
||||
[ext_resource type="Script" uid="uid://dkvbawcldnok5" path="res://src/equipped_weapon.ts" id="6_fjrip"]
|
||||
[ext_resource type="Script" uid="uid://dbrjcvaqkca21" path="res://src/inventory.ts" id="6_jscba"]
|
||||
[ext_resource type="PackedScene" uid="uid://sgc1gxq4osag" path="res://scenes/player_mesh3.tscn" id="7_fjrip"]
|
||||
|
||||
|
@ -131,63 +131,8 @@ script = ExtResource("2_pdrhn")
|
|||
|
||||
[node name="Mesh" parent="." instance=ExtResource("7_fjrip")]
|
||||
|
||||
[node name="Skeleton3D" parent="Mesh/AuxScene/Scene/Armature" index="0"]
|
||||
bones/0/position = Vector3(-1.34296, 99.233, 1.4959)
|
||||
bones/0/rotation = Quaternion(0.0438457, -0.453154, -0.0426107, 0.889333)
|
||||
bones/2/rotation = Quaternion(-0.0580086, 0.0574482, 0.0299733, 0.996211)
|
||||
bones/4/rotation = Quaternion(0.023142, 0.0682831, 0.00805779, 0.997365)
|
||||
bones/6/rotation = Quaternion(0.0366486, 0.0685247, 0.00561944, 0.99696)
|
||||
bones/8/rotation = Quaternion(-0.412947, 0.510846, -0.570029, -0.493537)
|
||||
bones/10/rotation = Quaternion(0.366708, 0.091387, -0.824325, 0.421499)
|
||||
bones/12/rotation = Quaternion(-3.39933e-08, 5.02926e-08, -0.244577, 0.96963)
|
||||
bones/14/rotation = Quaternion(-0.218999, 0.389096, 0.162682, 0.879874)
|
||||
bones/16/rotation = Quaternion(0.491661, 0.0186145, 0.04132, 0.869607)
|
||||
bones/18/rotation = Quaternion(0.583947, 9.22009e-08, 0.0475734, 0.810396)
|
||||
bones/20/rotation = Quaternion(0.435138, -7.46222e-08, 0.03545, 0.899666)
|
||||
bones/24/rotation = Quaternion(0.430214, -0.0354484, 0.142206, 0.89075)
|
||||
bones/26/rotation = Quaternion(0.825171, 1.546e-07, 0.0672255, 0.560868)
|
||||
bones/28/rotation = Quaternion(0.16276, -6.10016e-08, 0.0132598, 0.986577)
|
||||
bones/32/rotation = Quaternion(0.478969, 0.00176994, 0.0701699, 0.875021)
|
||||
bones/34/rotation = Quaternion(0.753736, -9.22009e-08, 0.0614057, 0.654303)
|
||||
bones/36/rotation = Quaternion(0.4171, 5.03496e-09, 0.0339805, 0.908225)
|
||||
bones/40/rotation = Quaternion(0.21981, 0.00370957, 0.0385759, 0.974773)
|
||||
bones/42/rotation = Quaternion(0.420375, -1.93715e-07, 0.0342473, 0.906704)
|
||||
bones/44/rotation = Quaternion(0.430986, -3.23344e-08, 0.0351118, 0.901675)
|
||||
bones/48/rotation = Quaternion(0.349343, 0.0283774, -0.150582, 0.92438)
|
||||
bones/50/rotation = Quaternion(-0.112075, -0.188988, 0.210821, 0.952511)
|
||||
bones/52/rotation = Quaternion(-0.271577, -0.018948, 0.408217, 0.871347)
|
||||
bones/56/rotation = Quaternion(0.103598, 0.0666441, -0.0240849, 0.992092)
|
||||
bones/58/rotation = Quaternion(0.00749621, 0.164595, 0.0896287, 0.982252)
|
||||
bones/61/rotation = Quaternion(-0.515646, -0.558738, 0.572809, -0.306285)
|
||||
bones/63/rotation = Quaternion(0.255191, -0.248185, 0.504518, 0.786602)
|
||||
bones/65/rotation = Quaternion(-4.35393e-08, 4.86605e-09, 0.655273, 0.755392)
|
||||
bones/67/rotation = Quaternion(-0.18199, -0.388089, -0.336697, 0.838393)
|
||||
bones/69/rotation = Quaternion(0.128107, -0.173846, 0.152522, 0.964419)
|
||||
bones/71/rotation = Quaternion(-0.0940495, 0.0712352, 0.0315575, 0.992514)
|
||||
bones/73/rotation = Quaternion(0.0268879, 0.0186427, 0.218404, 0.97531)
|
||||
bones/77/rotation = Quaternion(0.271488, -0.0129037, -0.019735, 0.962153)
|
||||
bones/79/rotation = Quaternion(0.51229, -8.40984e-07, -0.0524978, 0.857207)
|
||||
bones/81/rotation = Quaternion(0.207034, -1.16677e-07, -0.0212163, 0.978104)
|
||||
bones/85/rotation = Quaternion(0.354152, -0.0251767, -0.00660215, 0.934826)
|
||||
bones/87/rotation = Quaternion(0.500314, -8.10251e-07, -0.0512706, 0.864325)
|
||||
bones/89/rotation = Quaternion(0.335131, -4.84986e-07, -0.0343432, 0.941546)
|
||||
bones/93/rotation = Quaternion(0.420833, -0.0472764, 0.0235745, 0.905598)
|
||||
bones/95/rotation = Quaternion(0.50818, -8.50763e-07, -0.0520767, 0.859675)
|
||||
bones/97/rotation = Quaternion(0.173011, 1.41736e-08, -0.0177296, 0.98476)
|
||||
bones/101/rotation = Quaternion(0.324573, -0.049477, 0.0773928, 0.94139)
|
||||
bones/103/rotation = Quaternion(0.491491, -5.96046e-07, -0.0503663, 0.869425)
|
||||
bones/105/rotation = Quaternion(0.273046, -6.9337e-07, -0.0279808, 0.961594)
|
||||
bones/109/rotation = Quaternion(-0.127311, 0.113785, 0.983303, 0.0629229)
|
||||
bones/111/rotation = Quaternion(-0.199275, -0.0738388, 0.000908459, 0.977157)
|
||||
bones/113/rotation = Quaternion(0.503553, 0.125908, 0.0705691, 0.851823)
|
||||
bones/115/rotation = Quaternion(0.335242, -6.35498e-08, 2.67434e-07, 0.942132)
|
||||
bones/119/rotation = Quaternion(0.124542, 0.250518, 0.945838, -0.164682)
|
||||
bones/121/rotation = Quaternion(-0.248302, -0.0864232, 0.020511, 0.964602)
|
||||
bones/123/rotation = Quaternion(0.421959, -0.0804281, -0.0458337, 0.901877)
|
||||
bones/125/rotation = Quaternion(0.335241, -2.57727e-08, 5.75265e-09, 0.942132)
|
||||
|
||||
[node name="RightHand" parent="Mesh/AuxScene/Scene/Armature/Skeleton3D" index="2"]
|
||||
transform = Transform3D(0.288251, 0.477446, -0.830034, 0.9427, 0.0105974, 0.333473, 0.168011, -0.878596, -0.447034, -2.98473, 141.91, 59.327)
|
||||
transform = Transform3D(0.678924, 0.327226, -0.657255, 0.571861, 0.325755, 0.752899, 0.460473, -0.88702, 0.0340353, -5.60212, 89.2255, 32.2557)
|
||||
|
||||
[node name="Node3D" type="Node3D" parent="Mesh/AuxScene/Scene/Armature/Skeleton3D/RightHand" index="0"]
|
||||
|
||||
|
@ -211,14 +156,6 @@ shape = SubResource("SphereShape3D_64co4")
|
|||
[node name="Inventory" type="Node" parent="."]
|
||||
script = ExtResource("6_jscba")
|
||||
|
||||
[node name="EquippedWeapon" type="Node" parent="."]
|
||||
script = ExtResource("6_eg2om")
|
||||
starting_weapon = "uid://c15pu3ela0g6k"
|
||||
_transform_parent = NodePath("../Mesh/AuxScene/Scene/Armature/Skeleton3D/RightHand/Node3D")
|
||||
|
||||
[node name="FireRate" type="Timer" parent="EquippedWeapon"]
|
||||
one_shot = true
|
||||
|
||||
[node name="AnimationTree" type="AnimationTree" parent="."]
|
||||
root_node = NodePath("../Mesh")
|
||||
tree_root = SubResource("AnimationNodeStateMachine_5lvsk")
|
||||
|
@ -230,4 +167,14 @@ parameters/Unarmed/blend_position = 0.872134
|
|||
script = ExtResource("3_26yay")
|
||||
move_speed_expression = "move_speed()"
|
||||
|
||||
[node name="EquippedWeapon" type="Node3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.5, 0.5)
|
||||
script = ExtResource("6_fjrip")
|
||||
starting_weapon = "uid://c15pu3ela0g6k"
|
||||
_transform_parent = NodePath("../Mesh/AuxScene/Scene/Armature/Skeleton3D/RightHand/Node3D")
|
||||
metadata/_custom_type_script = "uid://dkvbawcldnok5"
|
||||
|
||||
[node name="FireRate" type="Timer" parent="EquippedWeapon"]
|
||||
one_shot = true
|
||||
|
||||
[editable path="Mesh"]
|
||||
|
|
|
@ -5,10 +5,11 @@ const get_node_from_key = (key: string, node: Node) => {
|
|||
const path = node.get(key)
|
||||
|
||||
if (path == null) {
|
||||
throw new Error(`${key} is null`)
|
||||
console.warn(`${node.get_name()}::${key} is null, can't export node`)
|
||||
return
|
||||
}
|
||||
|
||||
return node.get_node(path)
|
||||
return node.get_node_or_null(path)
|
||||
}
|
||||
|
||||
export function export_scene() {
|
||||
|
@ -26,7 +27,7 @@ export function export_expression() {
|
|||
export function export_node<T extends Node>(defaultNode?: string) {
|
||||
return function(target: T, key: string) {
|
||||
const meta_key = `_${key}`
|
||||
//Reflect.set(target, meta_key, defaultNode || '')
|
||||
Reflect.set(target, meta_key, defaultNode || '')
|
||||
|
||||
export_(Variant.Type.TYPE_NODE_PATH)(target, meta_key)
|
||||
onready((node: Node) => get_node_from_key(meta_key, node))(target, key)
|
||||
|
@ -57,7 +58,7 @@ export function onready<T extends Node, ValueType>(
|
|||
Reflect.defineProperty(target, '_ready', {
|
||||
value: function() {
|
||||
for (const { evaluator, property } of handlers) {
|
||||
this[property] = evaluator(this)
|
||||
this[property] = evaluator?.(this)
|
||||
}
|
||||
|
||||
old_ready.call(this)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { BaseMaterial3D, Color, ImmediateMesh, Mesh, MeshInstance3D, Node, Node3D, PackedVector3Array, StandardMaterial3D, Vector3 } from 'godot'
|
||||
import { BaseMaterial3D, Color, ImmediateMesh, Mesh, MeshInstance3D, Node, Node3D, PackedVector3Array, PhysicsRayQueryParameters3D, StandardMaterial3D, Vector3 } from 'godot'
|
||||
|
||||
function createDefaultMaterial(): StandardMaterial3D {
|
||||
const material = new StandardMaterial3D()
|
||||
|
@ -84,6 +84,10 @@ export default class DebugDraw extends Node {
|
|||
DebugDraw.instance._draw_lines(points, color)
|
||||
}
|
||||
|
||||
static draw_ray(query: PhysicsRayQueryParameters3D, color: Color = Color.CYAN) {
|
||||
DebugDraw.draw_line(query.from, query.to, color)
|
||||
}
|
||||
|
||||
_draw_lines(points: PackedVector3Array, color: Color = Color.CYAN) {
|
||||
const instance = this.pool.get()
|
||||
const mesh = instance.instance.mesh as ImmediateMesh
|
||||
|
@ -94,7 +98,7 @@ export default class DebugDraw extends Node {
|
|||
|
||||
const len = points.size()
|
||||
for (let i = 0; i < len; i++) {
|
||||
mesh.surface_add_vertex(points.get_indexed(i))
|
||||
mesh.surface_add_vertex(points.get(i))
|
||||
}
|
||||
|
||||
mesh.surface_end()
|
||||
|
|
1
src/entity.ts.uid
Normal file
1
src/entity.ts.uid
Normal file
|
@ -0,0 +1 @@
|
|||
uid://dk1oc431swny1
|
|
@ -1,16 +1,22 @@
|
|||
import { GArray, Node, Node3D, PackedScene, Signal1, Timer, Vector3 } from 'godot'
|
||||
import { Color, GArray, Node, Node3D, PackedScene, PhysicsBody3D, PhysicsRayQueryParameters3D, Signal1, Timer, Vector3 } from 'godot'
|
||||
import { export_file, signal } from 'godot.annotations'
|
||||
import { export_node, onready } from './annotations'
|
||||
import Weapon from './weapon'
|
||||
import AsyncResourceLoader from './async_resource_loader'
|
||||
import { forward } from './vec'
|
||||
import DebugDraw from './debug_draw'
|
||||
import { find_in_anscestors, find_in_descendents, implements_interface } from './node'
|
||||
import { Damageable } from './health'
|
||||
|
||||
export default class EquippedWeapon extends Node {
|
||||
const { MULTIPLY: mul, ADD: add } = Vector3
|
||||
|
||||
export default class EquippedWeapon extends Node3D {
|
||||
@export_file('*.tres')
|
||||
starting_weapon?: string
|
||||
_starting_weapon?: Weapon
|
||||
|
||||
@export_node()
|
||||
transform_parent!: Node
|
||||
transform_parent!: Node3D
|
||||
|
||||
_equipped_weapon?: Weapon
|
||||
_has_equipped_weapon: boolean = false
|
||||
|
@ -69,8 +75,24 @@ export default class EquippedWeapon extends Node {
|
|||
}
|
||||
|
||||
fire(): boolean {
|
||||
if (this._fire_rate_timer.time_left <= 0) {
|
||||
if (this._equipped_weapon && this._fire_rate_timer.time_left <= 0) {
|
||||
this._fire_rate_timer.start()
|
||||
const space_state = this.get_world_3d().direct_space_state
|
||||
const origin = this.global_position
|
||||
const end = add(origin, mul(forward(this.global_transform), this._equipped_weapon.range))
|
||||
const query = PhysicsRayQueryParameters3D.create(origin, end)
|
||||
const result = space_state.intersect_ray(query)
|
||||
|
||||
if (!result.is_empty()) {
|
||||
DebugDraw.draw_ray(query, Color.DARK_RED)
|
||||
const root = find_in_anscestors(result.get('collider'), n => n instanceof PhysicsBody3D)
|
||||
const health = find_in_descendents<Node & Damageable>(root, n => implements_interface<Damageable>(['apply_damage'], n))
|
||||
if (health != null) {
|
||||
health.apply_damage(this, this._equipped_weapon.damage)
|
||||
}
|
||||
} else {
|
||||
DebugDraw.draw_ray(query, Color.DARK_GREEN)
|
||||
}
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
|
|
|
@ -16,6 +16,10 @@ export default class Health extends Node implements Damageable, Recoverable {
|
|||
@export_(Variant.Type.TYPE_FLOAT)
|
||||
private _current_health: number = 0
|
||||
|
||||
_ready() {
|
||||
this._current_health = this._max_health
|
||||
}
|
||||
|
||||
apply_damage(_source: any, amount: number): void {
|
||||
this._current_health = Math.max(0, this._current_health - amount)
|
||||
}
|
||||
|
|
48
src/node.ts
Normal file
48
src/node.ts
Normal file
|
@ -0,0 +1,48 @@
|
|||
import { GArray, Node, Object, StringName } from 'godot'
|
||||
|
||||
interface Predicate<T> {
|
||||
(value: T): boolean
|
||||
}
|
||||
|
||||
export function queue_free_children<T extends Node>(node: T) {
|
||||
const children: GArray<Node> = node.get_children()
|
||||
for (const child of children) {
|
||||
child.queue_free()
|
||||
}
|
||||
}
|
||||
|
||||
export function implements_interface<T>(method_names: StringName[], obj: Object): obj is Object & T {
|
||||
return method_names.every(name => obj.has_method(name))
|
||||
}
|
||||
|
||||
export function find_in_anscestors<T extends Node>(root: T | null | undefined, predicate: Predicate<Node>, height: number = Infinity): T | null | undefined {
|
||||
if (height < 0 || root == null) {
|
||||
return
|
||||
}
|
||||
|
||||
if (predicate(root)) {
|
||||
return root
|
||||
}
|
||||
|
||||
return find_in_anscestors(root.get_parent(), predicate, height - 1) as T
|
||||
}
|
||||
|
||||
export function find_in_descendents<T extends Node>(root: T, predicate: Predicate<Node>, depth: number = Infinity): T | null | undefined {
|
||||
if (depth < 0) {
|
||||
return
|
||||
}
|
||||
|
||||
if (predicate(root)) {
|
||||
return root
|
||||
}
|
||||
|
||||
const count = root.get_child_count()
|
||||
for (let i = 0; i < count; i++) {
|
||||
const child = root.get_child(i)
|
||||
const found = find_in_descendents(child, predicate, depth - 1)
|
||||
|
||||
if (found != null) {
|
||||
return found as T
|
||||
}
|
||||
}
|
||||
}
|
6
src/vec.ts
Normal file
6
src/vec.ts
Normal file
|
@ -0,0 +1,6 @@
|
|||
import { Transform3D, Vector3 } from 'godot'
|
||||
|
||||
export function forward(transform: Transform3D): Vector3 {
|
||||
return transform.basis.z
|
||||
}
|
||||
|
1
src/vec.ts.uid
Normal file
1
src/vec.ts.uid
Normal file
|
@ -0,0 +1 @@
|
|||
uid://gi1kkj5kpt63
|
|
@ -7,6 +7,12 @@ export default class Weapon extends Item {
|
|||
@export_scene()
|
||||
readonly scene!: string
|
||||
|
||||
@export_(Variant.Type.TYPE_FLOAT)
|
||||
readonly damage: number = 1
|
||||
|
||||
@export_(Variant.Type.TYPE_FLOAT)
|
||||
readonly range: number = 100
|
||||
|
||||
@export_(Variant.Type.TYPE_FLOAT)
|
||||
readonly fire_rate!: number
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
"target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
|
||||
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
|
||||
// "jsx": "preserve", /* Specify what JSX code is generated. */
|
||||
"experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */
|
||||
"experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */
|
||||
// "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
|
||||
// "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
|
||||
// "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
|
||||
|
@ -26,7 +26,7 @@
|
|||
|
||||
/* Modules */
|
||||
"module": "CommonJS", /* Specify what module code is generated. */
|
||||
"rootDir": "./", /* Specify the root folder within your source files. */
|
||||
"rootDir": "./", /* Specify the root folder within your source files. */
|
||||
// "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */
|
||||
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
|
||||
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
|
||||
|
@ -55,13 +55,13 @@
|
|||
/* Emit */
|
||||
// "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
|
||||
// "declarationMap": true, /* Create sourcemaps for d.ts files. */
|
||||
"emitDeclarationOnly": false, /* Only output d.ts files and not JavaScript files. */
|
||||
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
|
||||
"sourceMap": true, /* Create source map files for emitted JavaScript files. */
|
||||
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
|
||||
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
|
||||
"outDir": ".godot/GodotJS", /* Specify an output folder for all emitted files. */
|
||||
// "removeComments": true, /* Disable emitting comments. */
|
||||
"noEmit": false, /* Disable emitting files from a compilation. */
|
||||
// "noEmit": true, /* Disable emitting files from a compilation. */
|
||||
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
|
||||
// "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */
|
||||
// "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
|
||||
|
|
|
@ -8,7 +8,7 @@ declare module "godot" {
|
|||
{
|
||||
Output: RichTextLabel<
|
||||
{
|
||||
"@VScrollBar@46002": VScrollBar<{}>,
|
||||
"@VScrollBar@22678": VScrollBar<{}>,
|
||||
}
|
||||
>,
|
||||
Input: LineEdit<
|
||||
|
|
7
typings/addons/dev_console/output_line.nodes.gen.d.ts
vendored
Normal file
7
typings/addons/dev_console/output_line.nodes.gen.d.ts
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
declare module "godot" {
|
||||
interface SceneNodes {
|
||||
"addons/dev_console/output_line.tscn": {
|
||||
"@VScrollBar@22679": VScrollBar<{}>,
|
||||
},
|
||||
}
|
||||
}
|
13
typings/assets/Glock 17 Gen 4/Glock17.fbx
Normal file
13
typings/assets/Glock 17 Gen 4/Glock17.fbx
Normal file
|
@ -0,0 +1,13 @@
|
|||
declare module "godot" {
|
||||
interface SceneNodes {
|
||||
"assets/Glock 17 Gen 4/Glock17.fbx": {
|
||||
Slide: MeshInstance3D<{}>,
|
||||
Reference: Node3D<{}>,
|
||||
Receiver: MeshInstance3D<{}>,
|
||||
Trigger: MeshInstance3D<{}>,
|
||||
"Internal Chamber in Slide": MeshInstance3D<{}>,
|
||||
Cylinder: MeshInstance3D<{}>,
|
||||
Magazine: MeshInstance3D<{}>,
|
||||
},
|
||||
}
|
||||
}
|
8
typings/assets/Glock 17 Gen 4/MagazineOnly.blend
Normal file
8
typings/assets/Glock 17 Gen 4/MagazineOnly.blend
Normal file
|
@ -0,0 +1,8 @@
|
|||
declare module "godot" {
|
||||
interface SceneNodes {
|
||||
"assets/Glock 17 Gen 4/MagazineOnly.blend": {
|
||||
Reference: Node3D<{}>,
|
||||
Model_0: MeshInstance3D<{}>,
|
||||
},
|
||||
}
|
||||
}
|
8
typings/assets/Glock 17 Gen 4/MagazineOnly.fbx
Normal file
8
typings/assets/Glock 17 Gen 4/MagazineOnly.fbx
Normal file
|
@ -0,0 +1,8 @@
|
|||
declare module "godot" {
|
||||
interface SceneNodes {
|
||||
"assets/Glock 17 Gen 4/MagazineOnly.fbx": {
|
||||
Reference: Node3D<{}>,
|
||||
Model_0: MeshInstance3D<{}>,
|
||||
},
|
||||
}
|
||||
}
|
13
typings/assets/Glock 17 Gen 4/Main.blend
Normal file
13
typings/assets/Glock 17 Gen 4/Main.blend
Normal file
|
@ -0,0 +1,13 @@
|
|||
declare module "godot" {
|
||||
interface SceneNodes {
|
||||
"assets/Glock 17 Gen 4/Main.blend": {
|
||||
Slide: MeshInstance3D<{}>,
|
||||
Reference: Node3D<{}>,
|
||||
Receiver: MeshInstance3D<{}>,
|
||||
Trigger: MeshInstance3D<{}>,
|
||||
"Internal Chamber in Slide": MeshInstance3D<{}>,
|
||||
Cylinder: MeshInstance3D<{}>,
|
||||
Magazine: MeshInstance3D<{}>,
|
||||
},
|
||||
}
|
||||
}
|
13
typings/assets/Glock 17 Gen 4/Main.glb
Normal file
13
typings/assets/Glock 17 Gen 4/Main.glb
Normal file
|
@ -0,0 +1,13 @@
|
|||
declare module "godot" {
|
||||
interface SceneNodes {
|
||||
"assets/Glock 17 Gen 4/Main.glb": {
|
||||
Slide: MeshInstance3D<{}>,
|
||||
Reference: Node3D<{}>,
|
||||
Receiver: MeshInstance3D<{}>,
|
||||
Trigger: MeshInstance3D<{}>,
|
||||
"Internal Chamber in Slide": MeshInstance3D<{}>,
|
||||
Cylinder: MeshInstance3D<{}>,
|
||||
Magazine: MeshInstance3D<{}>,
|
||||
},
|
||||
}
|
||||
}
|
9
typings/assets/level.glb
Normal file
9
typings/assets/level.glb
Normal file
|
@ -0,0 +1,9 @@
|
|||
declare module "godot" {
|
||||
interface SceneNodes {
|
||||
"assets/level.glb": {
|
||||
Plane: MeshInstance3D<{}>,
|
||||
Cube: MeshInstance3D<{}>,
|
||||
Cube_001: MeshInstance3D<{}>,
|
||||
},
|
||||
}
|
||||
}
|
17
typings/assets/player.glb
Normal file
17
typings/assets/player.glb
Normal file
|
@ -0,0 +1,17 @@
|
|||
declare module "godot" {
|
||||
interface SceneNodes {
|
||||
"assets/player.glb": {
|
||||
Armature: Node3D<
|
||||
{
|
||||
Skeleton3D: Skeleton3D<
|
||||
{
|
||||
Beta_Joints: MeshInstance3D<{}>,
|
||||
Beta_Surface: MeshInstance3D<{}>,
|
||||
}
|
||||
>,
|
||||
}
|
||||
>,
|
||||
AnimationPlayer: AnimationPlayer<{}>,
|
||||
},
|
||||
}
|
||||
}
|
25
typings/assets/player2.glb
Normal file
25
typings/assets/player2.glb
Normal file
|
@ -0,0 +1,25 @@
|
|||
declare module "godot" {
|
||||
interface SceneNodes {
|
||||
"assets/player2.glb": {
|
||||
AuxScene: Node3D<
|
||||
{
|
||||
Scene: Node3D<
|
||||
{
|
||||
Armature: Node3D<
|
||||
{
|
||||
Skeleton3D: Skeleton3D<
|
||||
{
|
||||
Beta_Joints: MeshInstance3D<{}>,
|
||||
Beta_Surface: MeshInstance3D<{}>,
|
||||
}
|
||||
>,
|
||||
}
|
||||
>,
|
||||
}
|
||||
>,
|
||||
}
|
||||
>,
|
||||
AnimationPlayer: AnimationPlayer<{}>,
|
||||
},
|
||||
}
|
||||
}
|
73
typings/godot.mix.d.ts
vendored
73
typings/godot.mix.d.ts
vendored
|
@ -1,5 +1,8 @@
|
|||
/// <reference no-default-lib="true"/>
|
||||
declare module "godot" {
|
||||
export const IntegerType: unique symbol;
|
||||
export const FloatType: unique symbol;
|
||||
|
||||
/** A built-in type representing a method or a standalone function.
|
||||
*
|
||||
* @link https://docs.godotengine.org/en/4.2/classes/class_callable.html
|
||||
|
@ -183,4 +186,72 @@ declare module "godot" {
|
|||
as_promise(): Promise<T1>;
|
||||
}
|
||||
|
||||
}
|
||||
type NodePathMap = { [K in string]?: Node };
|
||||
|
||||
type StaticNodePath<Map extends NodePathMap> = (keyof Map & string) | {
|
||||
[K in keyof Map & string]: Map[K] extends Node<infer ChildMap>
|
||||
? `${K}/${StaticNodePath<ChildMap>}`
|
||||
: never
|
||||
}[keyof Map & string];
|
||||
|
||||
type ResolveNodePath<Map extends NodePathMap, Path extends string, Default = never> = Path extends keyof Map
|
||||
? Map[Path]
|
||||
: Path extends `${infer Key extends keyof Map & string}/${infer SubPath}`
|
||||
? Map[Key] extends Node<infer ChildMap>
|
||||
? ResolveNodePath<ChildMap, SubPath, Default>
|
||||
: Default
|
||||
: Default;
|
||||
|
||||
/**
|
||||
* GArray elements are exposed with a subset of JavaScript's standard Array API. Array indexes are exposed as
|
||||
* enumerable properties, thus if you want to perform more complex operations you can convert to a regular
|
||||
* JavaScript array with [...g_array.proxy()].
|
||||
*/
|
||||
class GArrayProxy<T> {
|
||||
[Symbol.iterator](): IteratorObject<GProxyValueWrap<T>>;
|
||||
/**
|
||||
* Gets the length of the array. This is a number one higher than the highest index in the array.
|
||||
*/
|
||||
get length(): number;
|
||||
/**
|
||||
* Removes the last element from an array and returns it.
|
||||
* If the array is empty, undefined is returned and the array is not modified.
|
||||
*/
|
||||
pop(): T | undefined;
|
||||
/**
|
||||
* Appends new elements to the end of an array, and returns the new length of the array.
|
||||
* @param items New elements to add to the array.
|
||||
*/
|
||||
push(...items: Array<T | GProxyValueWrap<T>>): number;
|
||||
/**
|
||||
* Returns the index of the first occurrence of a value in an array, or -1 if it is not present.
|
||||
* @param searchElement The value to locate in the array.
|
||||
* @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at index 0.
|
||||
*/
|
||||
indexOf(searchElement: T, fromIndex?: number): number;
|
||||
/**
|
||||
* Determines whether an array includes a certain element, returning true or false as appropriate.
|
||||
* @param searchElement The element to search for.
|
||||
*/
|
||||
includes(searchElement: T): boolean;
|
||||
toJSON(key?: any): any;
|
||||
toString(): string;
|
||||
[n: number]: T | GProxyValueWrap<T>; // More accurate get type blocked by https://github.com/microsoft/TypeScript/issues/43826
|
||||
}
|
||||
|
||||
// Ideally this would be a class, but TS currently doesn't provide a way to type a class with mapped properties.
|
||||
/**
|
||||
* GObject entries are exposed as enumerable properties, so Object.keys(), Object.entries() etc. will work.
|
||||
*/
|
||||
type GDictionaryProxy<T> = {
|
||||
[K in keyof T & string]: T[K] | GProxyValueWrap<T[K]>; // More accurate get type blocked by https://github.com/microsoft/TypeScript/issues/43826
|
||||
} & ('toString' extends keyof T ? {} : {
|
||||
toString(): string;
|
||||
});
|
||||
|
||||
type GProxyValueWrap<V> = V extends GArray<infer E>
|
||||
? GArrayProxy<E>
|
||||
: V extends GDictionary<infer T>
|
||||
? GDictionaryProxy<T>
|
||||
: V;
|
||||
}
|
||||
|
|
5535
typings/godot0.gen.d.ts
vendored
5535
typings/godot0.gen.d.ts
vendored
File diff suppressed because it is too large
Load diff
9299
typings/godot1.gen.d.ts
vendored
9299
typings/godot1.gen.d.ts
vendored
File diff suppressed because it is too large
Load diff
11065
typings/godot2.gen.d.ts
vendored
11065
typings/godot2.gen.d.ts
vendored
File diff suppressed because it is too large
Load diff
13090
typings/godot3.gen.d.ts
vendored
13090
typings/godot3.gen.d.ts
vendored
File diff suppressed because it is too large
Load diff
15391
typings/godot4.gen.d.ts
vendored
15391
typings/godot4.gen.d.ts
vendored
File diff suppressed because it is too large
Load diff
17323
typings/godot5.gen.d.ts
vendored
17323
typings/godot5.gen.d.ts
vendored
File diff suppressed because it is too large
Load diff
17974
typings/godot6.gen.d.ts
vendored
17974
typings/godot6.gen.d.ts
vendored
File diff suppressed because it is too large
Load diff
16689
typings/godot7.gen.d.ts
vendored
16689
typings/godot7.gen.d.ts
vendored
File diff suppressed because it is too large
Load diff
8552
typings/godot8.gen.d.ts
vendored
Normal file
8552
typings/godot8.gen.d.ts
vendored
Normal file
File diff suppressed because it is too large
Load diff
21
typings/jsb.editor.bundle.d.ts
vendored
21
typings/jsb.editor.bundle.d.ts
vendored
|
@ -36,7 +36,7 @@ declare module "jsb.editor.codegen" {
|
|||
make_return(method_info: jsb.editor.MethodBind, type_replacer?: (name: string) => string): string;
|
||||
make_signal_type(method_info: jsb.editor.MethodBind): string;
|
||||
}
|
||||
export default class TSDCodeGen {
|
||||
export class TSDCodeGen {
|
||||
private _split_index;
|
||||
private _outDir;
|
||||
private _splitter;
|
||||
|
@ -47,15 +47,24 @@ declare module "jsb.editor.codegen" {
|
|||
private split;
|
||||
private cleanup;
|
||||
has_class(name?: string): boolean;
|
||||
emit(): void;
|
||||
emit(): Promise<void>;
|
||||
private emit_utility;
|
||||
private emit_global;
|
||||
private emit_mock;
|
||||
private emit_singletons;
|
||||
private emit_utilities;
|
||||
private emit_globals;
|
||||
private emit_godot;
|
||||
private emit_singleton;
|
||||
private emit_godot_primitive;
|
||||
private emit_godot_class;
|
||||
}
|
||||
export class SceneTSDCodeGen {
|
||||
private _out_dir;
|
||||
private _scene_paths;
|
||||
private _types;
|
||||
constructor(out_dir: string, scene_paths: string[]);
|
||||
private make_path;
|
||||
emit(): Promise<void>;
|
||||
private emit_children_node_types;
|
||||
private emit_scene_node_types;
|
||||
}
|
||||
}
|
||||
declare module "jsb.editor.main" {
|
||||
import { PackedStringArray } from "godot";
|
||||
|
|
27
typings/jsb.runtime.bundle.d.ts
vendored
27
typings/jsb.runtime.bundle.d.ts
vendored
|
@ -1,6 +1,13 @@
|
|||
declare module "godot.annotations" {
|
||||
import { PropertyHint, PropertyUsageFlags, Variant, MultiplayerAPI, MultiplayerPeer } from "godot";
|
||||
import * as jsb from "godot-jsb";
|
||||
export interface EnumPlaceholder {
|
||||
}
|
||||
export interface TypePairPlaceholder {
|
||||
}
|
||||
export function EnumType(type: any): EnumPlaceholder;
|
||||
export function TypePair(key: ClassDescriptor, value: ClassDescriptor): TypePairPlaceholder;
|
||||
export type ClassDescriptor = Function | Symbol | EnumPlaceholder | TypePairPlaceholder;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
@ -14,8 +21,20 @@ declare module "godot.annotations" {
|
|||
export function export_global_file(filter: string): (target: any, key: string) => void;
|
||||
export function export_global_dir(filter: string): (target: any, key: string) => void;
|
||||
export function export_exp_easing(hint?: "" | "attenuation" | "positive_only" | "attenuation,positive_only"): (target: any, key: string) => void;
|
||||
/**
|
||||
* A Shortcut for `export_(Variant.Type.TYPE_ARRAY, { class_: clazz })`
|
||||
*/
|
||||
export function export_array(clazz: ClassDescriptor): (target: any, key: string) => void;
|
||||
/**
|
||||
* A Shortcut for `export_(Variant.Type.TYPE_DICTIONARY, { class_: [key_class, value_class] })`
|
||||
*/
|
||||
export function export_dictionary(key_class: ClassDescriptor, value_class: ClassDescriptor): (target: any, key: string) => void;
|
||||
export function export_object(class_: ClassDescriptor): (target: any, key: string) => void;
|
||||
/**
|
||||
* [low level export]
|
||||
*/
|
||||
export function export_(type: Variant.Type, details?: {
|
||||
class_?: Function;
|
||||
class_?: ClassDescriptor;
|
||||
hint?: PropertyHint;
|
||||
hint_string?: string;
|
||||
usage?: PropertyUsageFlags;
|
||||
|
@ -27,7 +46,7 @@ declare module "godot.annotations" {
|
|||
* Exporting is done by using the `@export_var` (or `@export_`) annotation.
|
||||
*/
|
||||
export function export_var(type: Variant.Type, details?: {
|
||||
class_?: Function;
|
||||
class_?: ClassDescriptor;
|
||||
hint?: PropertyHint;
|
||||
hint_string?: string;
|
||||
usage?: PropertyUsageFlags;
|
||||
|
@ -66,3 +85,7 @@ declare module "godot.typeloader" {
|
|||
export function on_type_loaded(type_name: string | string[], callback: TypeLoadedCallback): void;
|
||||
}
|
||||
declare module "jsb.core" { }
|
||||
declare const ProxyTarget: unique symbol;
|
||||
declare const proxy_unwrap: (value: any) => any;
|
||||
declare const proxyable_prototypes: any[];
|
||||
declare const proxy_wrap: (value: any) => any;
|
||||
|
|
24
typings/player.nodes.gen.d.ts
vendored
Normal file
24
typings/player.nodes.gen.d.ts
vendored
Normal file
|
@ -0,0 +1,24 @@
|
|||
declare module "godot" {
|
||||
interface SceneNodes {
|
||||
"player.tscn": {
|
||||
CollisionShape3D: CollisionShape3D<{}>,
|
||||
player: Node3D<
|
||||
{
|
||||
Armature: Node3D<
|
||||
{
|
||||
Skeleton3D: Skeleton3D<
|
||||
{
|
||||
Beta_Joints: MeshInstance3D<{}>,
|
||||
Beta_Surface: MeshInstance3D<{}>,
|
||||
}
|
||||
>,
|
||||
}
|
||||
>,
|
||||
AnimationPlayer: AnimationPlayer<{}>,
|
||||
}
|
||||
>,
|
||||
Input: Node<{}>,
|
||||
Animation: Node<{}>,
|
||||
},
|
||||
}
|
||||
}
|
8
typings/scenes/node_3d.nodes.gen.d.ts
vendored
8
typings/scenes/node_3d.nodes.gen.d.ts
vendored
|
@ -52,12 +52,12 @@ declare module "godot" {
|
|||
}
|
||||
>,
|
||||
Inventory: Node<{}>,
|
||||
EquippedWeapon: Node<
|
||||
AnimationTree: AnimationTree<{}>,
|
||||
EquippedWeapon: Node3D<
|
||||
{
|
||||
FireRate: Timer<{}>,
|
||||
}
|
||||
>,
|
||||
AnimationTree: AnimationTree<{}>,
|
||||
}
|
||||
>,
|
||||
DirectionalLight3D: DirectionalLight3D<{}>,
|
||||
|
@ -83,9 +83,11 @@ declare module "godot" {
|
|||
Label3D: Label3D<{}>,
|
||||
}
|
||||
>,
|
||||
Target: Node3D<
|
||||
Target: StaticBody3D<
|
||||
{
|
||||
Health: Node<{}>,
|
||||
MeshInstance3D: MeshInstance3D<{}>,
|
||||
CollisionShape3D: CollisionShape3D<{}>,
|
||||
}
|
||||
>,
|
||||
},
|
||||
|
|
4
typings/scenes/player.nodes.gen.d.ts
vendored
4
typings/scenes/player.nodes.gen.d.ts
vendored
|
@ -37,12 +37,12 @@ declare module "godot" {
|
|||
}
|
||||
>,
|
||||
Inventory: Node<{}>,
|
||||
EquippedWeapon: Node<
|
||||
AnimationTree: AnimationTree<{}>,
|
||||
EquippedWeapon: Node3D<
|
||||
{
|
||||
FireRate: Timer<{}>,
|
||||
}
|
||||
>,
|
||||
AnimationTree: AnimationTree<{}>,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
17
typings/scenes/player_mesh.nodes.gen.d.ts
vendored
Normal file
17
typings/scenes/player_mesh.nodes.gen.d.ts
vendored
Normal file
|
@ -0,0 +1,17 @@
|
|||
declare module "godot" {
|
||||
interface SceneNodes {
|
||||
"scenes/player_mesh.tscn": {
|
||||
Armature: Node3D<
|
||||
{
|
||||
Skeleton3D: Skeleton3D<
|
||||
{
|
||||
Beta_Joints: MeshInstance3D<{}>,
|
||||
Beta_Surface: MeshInstance3D<{}>,
|
||||
}
|
||||
>,
|
||||
}
|
||||
>,
|
||||
AnimationPlayer: AnimationPlayer<{}>,
|
||||
},
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue