dev console
This commit is contained in:
parent
263a787c14
commit
3b039c177b
28 changed files with 254 additions and 815 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -3,4 +3,6 @@
|
|||
/android/
|
||||
node_modules/
|
||||
*.js
|
||||
*.map.js
|
||||
**/*.js
|
||||
**/*.map.js
|
||||
|
|
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
[submodule "addons/enumerable-ts"]
|
||||
path = addons/enumerable-ts
|
||||
url = https://git.kitsu.cafe/rowan/enumerable-ts.git
|
|
@ -1,43 +1,81 @@
|
|||
import { Callable, Callable1, LineEdit, Variant } from 'godot'
|
||||
import { Callable, Callable1, InputEvent, LineEdit, Variant } from 'godot'
|
||||
import { export_, onready } from 'godot.annotations'
|
||||
import { Enumerable, IEnumerable } from '../enumerable-ts/src/index'
|
||||
import { Action } from './dev_console'
|
||||
|
||||
export default class AutocompleteLine extends LineEdit {
|
||||
@export_(Variant.Type.TYPE_BOOL)
|
||||
private auto_suggest: boolean = true
|
||||
@export_(Variant.Type.TYPE_BOOL)
|
||||
private auto_suggest: boolean = true
|
||||
|
||||
@onready("SuggestionLine")
|
||||
private suggestion!: LineEdit
|
||||
@onready("Suggestion")
|
||||
private suggestion!: LineEdit
|
||||
|
||||
autocomplete_list: string[] = []
|
||||
last_autocomplete: number = -1
|
||||
autocomplete_list: string[] = []
|
||||
current_suggestions: string[] = []
|
||||
suggestion_index: number = -1
|
||||
suppress_focus_change: boolean = true
|
||||
|
||||
_on_text_changed!: Callable1<string>
|
||||
_on_text_changed!: Callable1<string>
|
||||
|
||||
_ready(): void {
|
||||
this._on_text_changed = Callable.create(this, this.suggest)
|
||||
_ready(): void {
|
||||
this._on_text_changed = Callable.create(this, this.suggest)
|
||||
|
||||
if (this.auto_suggest) {
|
||||
this.text_changed.connect(this._on_text_changed)
|
||||
}
|
||||
}
|
||||
if (this.auto_suggest) {
|
||||
this.text_changed.connect(this._on_text_changed)
|
||||
}
|
||||
}
|
||||
|
||||
suggest(value: string): boolean {
|
||||
const item = this.fuzzy_find(value)
|
||||
_input(event: InputEvent): void {
|
||||
if (this.has_focus() && this.suppress_focus_change && event.is_action_pressed(Action.FocusNext)) {
|
||||
this.accept_event()
|
||||
this.autocomplete()
|
||||
}
|
||||
}
|
||||
|
||||
if (item > -1) {
|
||||
this.suggestion.text = this.autocomplete_list[item]
|
||||
return true
|
||||
}
|
||||
suggest(value: string): boolean {
|
||||
this.reset()
|
||||
|
||||
return false
|
||||
}
|
||||
if (value == '') {
|
||||
return false
|
||||
}
|
||||
|
||||
autocomplete(value?: string) {
|
||||
this.text = value || this.suggestion.text
|
||||
this.suggestion.clear()
|
||||
}
|
||||
this.current_suggestions = this.fuzzy_find(value)
|
||||
|
||||
fuzzy_find(value: string): number {
|
||||
return this.autocomplete_list.findIndex(text => text.startsWith(value))
|
||||
}
|
||||
if (this.current_suggestions.length > 0) {
|
||||
const suggestion = this.current_suggestions[0]
|
||||
if (suggestion != null) {
|
||||
// create the illusion that the text is autocompleting
|
||||
// by replacing the already typed characters with spaces
|
||||
const padded = suggestion.slice(value.length).padStart(suggestion.length, ' ')
|
||||
this.suggestion.text = padded
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
this.suggestion.text = ''
|
||||
return false
|
||||
}
|
||||
|
||||
set_caret_to_end() {
|
||||
this.caret_column = this.text.length + 1
|
||||
}
|
||||
|
||||
autocomplete() {
|
||||
if (this.current_suggestions.length > 0) {
|
||||
this.suggestion_index = (this.suggestion_index + 1) % this.current_suggestions.length
|
||||
this.text = this.current_suggestions.at(this.suggestion_index) || ''
|
||||
this.suggestion.clear()
|
||||
this.set_caret_to_end()
|
||||
}
|
||||
}
|
||||
|
||||
fuzzy_find(value: string): string[] {
|
||||
return this.autocomplete_list.filter(text => text != null && text.startsWith(value))
|
||||
}
|
||||
|
||||
reset() {
|
||||
this.current_suggestions = []
|
||||
this.suggestion_index = -1
|
||||
this.suggestion.text = ''
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
[gd_scene load_steps=3 format=3 uid="uid://b8xytvsmqsf55"]
|
||||
[gd_scene load_steps=4 format=3 uid="uid://b8xytvsmqsf55"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/dev_console/dev_console.ts" id="1_3ukun"]
|
||||
[ext_resource type="Theme" uid="uid://cj1yqavvbe331" path="res://addons/dev_console/monospace.tres" id="2_0wrae"]
|
||||
[ext_resource type="Script" path="res://addons/dev_console/autocomplete_line.ts" id="2_fq41p"]
|
||||
|
||||
[node name="CanvasLayer" type="CanvasLayer"]
|
||||
|
@ -45,13 +46,15 @@ selection_enabled = true
|
|||
|
||||
[node name="Input" type="LineEdit" parent="Container/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
theme = ExtResource("2_0wrae")
|
||||
caret_blink = true
|
||||
script = ExtResource("2_fq41p")
|
||||
|
||||
[node name="Input2" type="LineEdit" parent="Container/VBoxContainer/Input"]
|
||||
[node name="Suggestion" type="LineEdit" parent="Container/VBoxContainer/Input"]
|
||||
layout_mode = 2
|
||||
offset_right = 1152.0
|
||||
offset_bottom = 31.0
|
||||
theme = ExtResource("2_0wrae")
|
||||
editable = false
|
||||
context_menu_enabled = false
|
||||
virtual_keyboard_enabled = false
|
||||
|
|
|
@ -1,13 +1,17 @@
|
|||
import { Callable, Callable1, CanvasLayer, Expression, GArray, GDictionary, GError, InputEvent, LineEdit, RichTextLabel } from 'godot'
|
||||
import { Callable, Callable1, CanvasLayer, Expression, GArray, GDictionary, GError, InputEvent, RichTextLabel } from 'godot'
|
||||
import { onready } from 'godot.annotations'
|
||||
import AutocompleteLine from './autocomplete_line'
|
||||
import { GArrayEnumerator } from '../../src/collection/enumerable'
|
||||
import { Enumerable } from '../enumerable-ts/src/index'
|
||||
|
||||
const Action = {
|
||||
export const Action = {
|
||||
Toggle: '_dev_console_toggle',
|
||||
Cancel: 'ui_cancel',
|
||||
Up: 'ui_up',
|
||||
Down: 'ui_down',
|
||||
TextComplete: 'ui_text_completion_replace'
|
||||
TextComplete: 'ui_text_completion_replace',
|
||||
FocusNext: 'ui_focus_next',
|
||||
FocusPrevious: 'ui_focus_prev',
|
||||
} as const
|
||||
|
||||
export default class DevConsole extends CanvasLayer {
|
||||
|
@ -25,8 +29,11 @@ export default class DevConsole extends CanvasLayer {
|
|||
|
||||
_ready(): void {
|
||||
this._toggle()
|
||||
const method_names = this.get_method_list().map(Callable.create((x: GDictionary) => x.get('name')))
|
||||
this.input.autocomplete_list = method_names
|
||||
const method_names = Enumerable.from(new GArrayEnumerator(this.get_method_list()))
|
||||
.map((x: GDictionary) => x.get('name'))
|
||||
.filter((x: string) => !x.startsWith('_'))
|
||||
|
||||
this.input.autocomplete_list = method_names.toArray()
|
||||
this.parse_callable = Callable.create(
|
||||
this,
|
||||
this.submit_command
|
||||
|
@ -47,9 +54,9 @@ export default class DevConsole extends CanvasLayer {
|
|||
if (event.is_action_pressed(Action.Cancel)) {
|
||||
this._cancel()
|
||||
} else if (event.is_action_pressed(Action.Up)) {
|
||||
this._previous_command()
|
||||
} else if (event.is_action_pressed(Action.TextComplete)) {
|
||||
//this._try_autocomplete()
|
||||
this._move_history(-1)
|
||||
} else if (event.is_action_pressed(Action.Down)) {
|
||||
this._move_history(1)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -67,13 +74,20 @@ export default class DevConsole extends CanvasLayer {
|
|||
}
|
||||
}
|
||||
|
||||
_previous_command() {
|
||||
async _move_history(direction: (-1 | 1)) {
|
||||
this.history_index = (this.history_index + direction) % this.history.length
|
||||
|
||||
if (this.history_index < 0) {
|
||||
this.history_index = this.history.length
|
||||
this.history_index = this.history.length - 1
|
||||
}
|
||||
|
||||
this.history_index -= 1
|
||||
this.input.text = this.history[this.history_index]
|
||||
await this.get_tree().process_frame.as_promise()
|
||||
this.input.set_caret_to_end()
|
||||
}
|
||||
|
||||
_autocomplete() {
|
||||
this.input.autocomplete()
|
||||
}
|
||||
|
||||
async _show() {
|
||||
|
|
7
addons/dev_console/monospace.tres
Normal file
7
addons/dev_console/monospace.tres
Normal file
|
@ -0,0 +1,7 @@
|
|||
[gd_resource type="Theme" load_steps=2 format=3 uid="uid://cj1yqavvbe331"]
|
||||
|
||||
[sub_resource type="SystemFont" id="SystemFont_2h66v"]
|
||||
font_names = PackedStringArray("Monospace")
|
||||
|
||||
[resource]
|
||||
LineEdit/fonts/font = SubResource("SystemFont_2h66v")
|
1
addons/enumerable-ts
Submodule
1
addons/enumerable-ts
Submodule
|
@ -0,0 +1 @@
|
|||
Subproject commit 79755d60cc55f9abd7e8f45238da05b750b177e4
|
2
package-lock.json
generated
2
package-lock.json
generated
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"name": "signalis",
|
||||
"name": "xsivgnazlixs",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
|
|
|
@ -1,33 +0,0 @@
|
|||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const godot_1 = require("godot");
|
||||
const godot_annotations_1 = require("godot.annotations");
|
||||
const player_1 = __importDefault(require("./player"));
|
||||
const message_bus_1 = __importDefault(require("./message_bus"));
|
||||
class CameraTrigger extends godot_1.Area3D {
|
||||
_ready() {
|
||||
this._camera = this.get_node(this.camera);
|
||||
}
|
||||
_on_body_entered(body) {
|
||||
var _a;
|
||||
if (body instanceof player_1.default) {
|
||||
(_a = this._camera) === null || _a === void 0 ? void 0 : _a.make_current();
|
||||
console.log(message_bus_1.default.instance.active_camera_changed);
|
||||
message_bus_1.default.instance.active_camera_changed.emit(this._camera);
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.default = CameraTrigger;
|
||||
__decorate([
|
||||
(0, godot_annotations_1.export_)(godot_1.Variant.Type.TYPE_NODE_PATH)
|
||||
], CameraTrigger.prototype, "camera", void 0);
|
||||
//# sourceMappingURL=camera_trigger.js.map
|
|
@ -1 +0,0 @@
|
|||
{"version":3,"file":"camera_trigger.js","sourceRoot":"../../../","sources":["src/camera_trigger.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,iCAA0E;AAC1E,yDAA2C;AAC3C,sDAA6B;AAC7B,gEAAsC;AAEtC,MAAqB,aAAc,SAAQ,cAAM;IAK/C,MAAM;QACJ,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAa,CAAA;IACvD,CAAC;IAED,gBAAgB,CAAC,IAAmB;;QAClC,IAAI,IAAI,YAAY,gBAAM,EAAE,CAAC;YAC3B,MAAA,IAAI,CAAC,OAAO,0CAAE,YAAY,EAAE,CAAA;YAC5B,OAAO,CAAC,GAAG,CAAC,qBAAU,CAAC,QAAQ,CAAC,qBAAqB,CAAC,CAAA;YACtD,qBAAU,CAAC,QAAQ,CAAC,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QAC9D,CAAC;IACH,CAAC;CACF;AAhBD,gCAgBC;AAdC;IADC,IAAA,2BAAO,EAAC,eAAO,CAAC,IAAI,CAAC,cAAc,CAAC;6CACpB"}
|
55
src/collection/enumerable.ts
Normal file
55
src/collection/enumerable.ts
Normal file
|
@ -0,0 +1,55 @@
|
|||
import { IArrayEnumerator } from '../../addons/enumerable-ts/src/index'
|
||||
|
||||
import { GArray } from 'godot'
|
||||
|
||||
type Nullable<T> = T | null | undefined
|
||||
|
||||
const DoneIteratorResult = Object.freeze({ value: undefined, done: true })
|
||||
|
||||
export class GArrayEnumerator<T> implements IArrayEnumerator<T>, Iterator<T>, Iterable<T> {
|
||||
private _array: GArray<T>
|
||||
private _index: number = -1
|
||||
|
||||
get current(): Nullable<T> {
|
||||
return this._array.get_indexed(this._index)
|
||||
}
|
||||
|
||||
constructor(array: GArray<T>) {
|
||||
this._array = array
|
||||
}
|
||||
|
||||
[Symbol.iterator](): Iterator<T> {
|
||||
return this._array[Symbol.iterator]() as Iterator<T>
|
||||
}
|
||||
|
||||
setIndex(index: number): void {
|
||||
this._index = index
|
||||
}
|
||||
|
||||
moveNext(): boolean {
|
||||
this._index += 1
|
||||
return this._index < this._array.size()
|
||||
}
|
||||
|
||||
reset(): void {
|
||||
this._index = -1
|
||||
}
|
||||
|
||||
toIterator<T>(): Iterator<T> {
|
||||
return this._array[Symbol.iterator]() as Iterator<T>
|
||||
}
|
||||
|
||||
next(...[_value]: [] | [any]): IteratorResult<T> {
|
||||
const next = this.moveNext()
|
||||
return { value: this.current, done: !next } as IteratorResult<T>
|
||||
}
|
||||
|
||||
return?(_value?: any): IteratorResult<T, any> {
|
||||
return DoneIteratorResult
|
||||
}
|
||||
|
||||
throw?(_e?: any): IteratorResult<T, any> {
|
||||
return DoneIteratorResult
|
||||
}
|
||||
}
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const godot_1 = require("godot");
|
||||
class DebugDraw extends godot_1.Node {
|
||||
static get instance() {
|
||||
return DebugDraw._inst;
|
||||
}
|
||||
_ready() {
|
||||
DebugDraw._inst = this;
|
||||
}
|
||||
draw_line(begin, end, color = godot_1.Color.CYAN) {
|
||||
const instance = new godot_1.GeometryInstance3D();
|
||||
this.add_child(instance);
|
||||
const geom = new godot_1.ImmediateMesh();
|
||||
geom.surface_begin(godot_1.ImmediateMesh.PrimitiveType.PRIMITIVE_LINES);
|
||||
geom.surface_add_vertex(begin);
|
||||
geom.surface_add_vertex(end);
|
||||
geom.surface_set_color(color);
|
||||
geom.surface_end();
|
||||
}
|
||||
}
|
||||
exports.default = DebugDraw;
|
||||
//# sourceMappingURL=debug_draw.js.map
|
|
@ -1 +0,0 @@
|
|||
{"version":3,"file":"debug_draw.js","sourceRoot":"../../../","sources":["src/debug_draw.ts"],"names":[],"mappings":";;AAAA,iCAA+E;AAE/E,MAAqB,SAAU,SAAQ,YAAI;IAGzC,MAAM,KAAK,QAAQ;QACjB,OAAO,SAAS,CAAC,KAAK,CAAA;IACxB,CAAC;IAED,MAAM;QACJ,SAAS,CAAC,KAAK,GAAG,IAAI,CAAA;IACxB,CAAC;IAED,SAAS,CAAC,KAAc,EAAE,GAAY,EAAE,QAAe,aAAK,CAAC,IAAI;QAC/D,MAAM,QAAQ,GAAG,IAAI,0BAAkB,EAAE,CAAA;QACzC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAA;QAExB,MAAM,IAAI,GAAG,IAAI,qBAAa,EAAE,CAAA;QAChC,IAAI,CAAC,aAAa,CAAC,qBAAa,CAAC,aAAa,CAAC,eAAe,CAAC,CAAA;QAC/D,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAA;QAC9B,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAA;QAC5B,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAA;QAC7B,IAAI,CAAC,WAAW,EAAE,CAAA;IACpB,CAAC;CACF;AAtBD,4BAsBC"}
|
|
@ -1,552 +0,0 @@
|
|||
import { GArray } from 'godot'
|
||||
|
||||
const DoneIteratorResult = Object.freeze({ value: undefined, done: true })
|
||||
|
||||
type Nullable<T> = T | null | undefined
|
||||
|
||||
export interface Predicate<T> {
|
||||
(value: Nullable<T>, index: number): boolean
|
||||
}
|
||||
|
||||
export interface Reducer<T, U = T> {
|
||||
(accumulator: U, value: Nullable<T>, index: number): U
|
||||
}
|
||||
|
||||
export interface Morphism<T, U = T> {
|
||||
(value: Nullable<T>, index: number): U
|
||||
}
|
||||
|
||||
interface IEnumeratorFactory<T> {
|
||||
(iterator: Iterator<T>): IEnumerator<T>
|
||||
}
|
||||
|
||||
export interface IEnumerator<T> {
|
||||
get current(): Nullable<T>
|
||||
moveNext(): boolean
|
||||
reset(): void
|
||||
toIterator<T>(): Iterator<T>
|
||||
}
|
||||
|
||||
export interface IEnumerable<T> {
|
||||
enumerator(): IEnumerator<T>
|
||||
}
|
||||
|
||||
export function isIterable(value: any): value is Iterable<any> {
|
||||
return typeof value[Symbol.iterator] === 'function'
|
||||
}
|
||||
|
||||
export function isIterator(value: any): value is Iterator<any> {
|
||||
return typeof value.next === 'function'
|
||||
}
|
||||
|
||||
export function isBuffer(value: any): value is ArrayBufferLike {
|
||||
return ArrayBuffer.isView(value)
|
||||
}
|
||||
|
||||
export function isGArray(value: any): value is GArray {
|
||||
return typeof value.get_indexed === 'function'
|
||||
}
|
||||
|
||||
export function isArrayLike(value: any): value is ArrayLike<any> {
|
||||
return typeof value.length === 'number'
|
||||
}
|
||||
|
||||
class IteratorEnumerator<T> implements IEnumerator<T>, Iterator<T> {
|
||||
private _iterator: Iterator<T>
|
||||
private _consumed: boolean = false
|
||||
private _current: Nullable<T>
|
||||
|
||||
get current(): Nullable<T> {
|
||||
return this._current
|
||||
}
|
||||
|
||||
constructor(iterator: Iterator<T>) {
|
||||
this._iterator = iterator
|
||||
}
|
||||
|
||||
static from<T>(iterator: Iterator<T>): IteratorEnumerator<T> {
|
||||
return new IteratorEnumerator(iterator)
|
||||
}
|
||||
|
||||
moveNext(): boolean {
|
||||
if (!this._consumed) {
|
||||
const { value, done } = this._iterator.next()
|
||||
|
||||
this._current = value
|
||||
if (done) {
|
||||
this._consumed = true
|
||||
}
|
||||
|
||||
return !done
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
reset(): void { }
|
||||
|
||||
toIterator<T>(): Iterator<T> {
|
||||
return this as Iterator<T>
|
||||
}
|
||||
|
||||
next(...[_value]: [] | [any]): IteratorResult<T> {
|
||||
const done = this.moveNext()
|
||||
return { value: this.current, done } as IteratorResult<T>
|
||||
}
|
||||
|
||||
return(value?: any): IteratorResult<T, any> {
|
||||
return this._iterator.return?.(value) ?? DoneIteratorResult
|
||||
}
|
||||
|
||||
throw(e?: any): IteratorResult<T, any> {
|
||||
return this._iterator.throw?.(e) ?? DoneIteratorResult
|
||||
}
|
||||
}
|
||||
|
||||
class CachedIteratorEnumerator<T> implements IEnumerator<T>, Iterator<T> {
|
||||
private _iterator: IteratorEnumerator<T>
|
||||
private _cache: Nullable<T>[] = []
|
||||
private _index: number = -1
|
||||
|
||||
get current(): Nullable<T> {
|
||||
return this._cache[this._index]
|
||||
}
|
||||
|
||||
constructor(iterator: Iterator<T>) {
|
||||
this._iterator = new IteratorEnumerator(iterator)
|
||||
}
|
||||
|
||||
static from<T>(iterator: Iterator<T>): CachedIteratorEnumerator<T> {
|
||||
return new CachedIteratorEnumerator(iterator)
|
||||
}
|
||||
|
||||
moveNext(): boolean {
|
||||
this._index += 1
|
||||
|
||||
if (this._cache.length > this._index) {
|
||||
return true
|
||||
} else if (!this._iterator.moveNext()) {
|
||||
this._cache.push(this._iterator.current)
|
||||
|
||||
return !true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
reset(): void {
|
||||
this._index = -1
|
||||
}
|
||||
|
||||
toIterator<T>(): Iterator<T> {
|
||||
return this as Iterator<T>
|
||||
}
|
||||
|
||||
next(...[_value]: [] | [any]): IteratorResult<T> {
|
||||
const done = this.moveNext()
|
||||
return { value: this.current, done } as IteratorResult<T>
|
||||
}
|
||||
|
||||
return?(value?: any): IteratorResult<T, any> {
|
||||
return this._iterator.return(value)
|
||||
}
|
||||
|
||||
throw(e?: any): IteratorResult<T, any> {
|
||||
return this._iterator.throw(e)
|
||||
}
|
||||
}
|
||||
|
||||
export class IterableEnumerator<T> implements IEnumerator<T>, Iterator<T> {
|
||||
private _iterable: Iterable<T>
|
||||
private _factory: IEnumeratorFactory<T>
|
||||
private _enumerator: Nullable<IEnumerator<T>>
|
||||
|
||||
get current(): Nullable<T> {
|
||||
return this._enumerator?.current
|
||||
}
|
||||
|
||||
constructor(iterable: Iterable<T>, factory: IEnumeratorFactory<T> = IteratorEnumerator.from) {
|
||||
this._iterable = iterable
|
||||
this._factory = factory
|
||||
}
|
||||
|
||||
static fromIterable<T>(iterable: Iterable<T>, factory?: IEnumeratorFactory<T>): IEnumerator<T> {
|
||||
return new this(iterable, factory)
|
||||
}
|
||||
|
||||
moveNext(): boolean {
|
||||
return this._enumerator?.moveNext() ?? false
|
||||
}
|
||||
|
||||
_createIterator(): Iterator<T> {
|
||||
return this._iterable[Symbol.iterator]()
|
||||
}
|
||||
|
||||
_createEnumerator(): IEnumerator<T> {
|
||||
return this._factory(this._createIterator())
|
||||
}
|
||||
|
||||
reset(): void {
|
||||
this._enumerator = this._createEnumerator()
|
||||
}
|
||||
|
||||
toIterator<T>(): Iterator<T> {
|
||||
return this._createIterator() as Iterator<T>
|
||||
}
|
||||
|
||||
next(...[_value]: [] | [any]): IteratorResult<T, any> {
|
||||
const done = !this.moveNext()
|
||||
return { value: this.current, done } as IteratorResult<T, any>
|
||||
}
|
||||
|
||||
return?(value?: any): IteratorResult<T, any> {
|
||||
if (isIterator(this._enumerator)) {
|
||||
return this._enumerator?.return?.(value) || DoneIteratorResult
|
||||
} else {
|
||||
return DoneIteratorResult
|
||||
}
|
||||
}
|
||||
|
||||
throw?(e?: any): IteratorResult<T, any> {
|
||||
if (isIterator(this._enumerator)) {
|
||||
return this._enumerator?.throw?.(e) || DoneIteratorResult
|
||||
} else {
|
||||
return DoneIteratorResult
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class Enumerator<T> implements IEnumerator<T>, Iterator<T> {
|
||||
protected _enumerator: IEnumerator<T>
|
||||
protected _index: number = 0
|
||||
|
||||
get current(): Nullable<T> {
|
||||
return this._enumerator.current
|
||||
}
|
||||
|
||||
constructor(enumerator: IEnumerator<T>) {
|
||||
this._enumerator = enumerator
|
||||
}
|
||||
|
||||
static fromIterable<T>(iterable: Iterable<T>): IEnumerator<T> {
|
||||
return new this(new IterableEnumerator(iterable))
|
||||
}
|
||||
|
||||
static fromIterator<T>(iterator: Iterator<T>, cache: boolean = true): IEnumerator<T> {
|
||||
if (cache) {
|
||||
return new CachedIteratorEnumerator(iterator)
|
||||
} else {
|
||||
return new IteratorEnumerator(iterator)
|
||||
}
|
||||
}
|
||||
|
||||
static toIterator<T>(enumerator: IEnumerator<T>): Iterator<T> {
|
||||
return new this(enumerator)
|
||||
}
|
||||
|
||||
[Symbol.iterator]() {
|
||||
return this.toIterator()
|
||||
}
|
||||
|
||||
toIterator<T>(): Iterator<T> {
|
||||
return Enumerator.toIterator(this) as Iterator<T>
|
||||
}
|
||||
|
||||
moveNext(): boolean {
|
||||
this._index += 1
|
||||
return this._enumerator.moveNext()
|
||||
}
|
||||
|
||||
reset(): void {
|
||||
this._enumerator.reset()
|
||||
}
|
||||
|
||||
next(...[_value]: [] | [any]): IteratorResult<T, any> {
|
||||
const done = this.moveNext()
|
||||
|
||||
return { value: this.current, done } as IteratorResult<T>
|
||||
}
|
||||
|
||||
return?(_value?: any): IteratorResult<T, any> {
|
||||
return DoneIteratorResult
|
||||
}
|
||||
|
||||
throw?(_e?: any): IteratorResult<T, any> {
|
||||
return DoneIteratorResult
|
||||
}
|
||||
}
|
||||
|
||||
class DropEnumerator<T> extends Enumerator<T> {
|
||||
private _limit: number
|
||||
|
||||
constructor(enumerator: IEnumerator<T>, limit: number) {
|
||||
super(enumerator)
|
||||
this._limit = limit
|
||||
}
|
||||
|
||||
moveNext(): boolean {
|
||||
for (let i = 0; i < this._limit; i++) {
|
||||
if (!super.moveNext()) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
class FilterEnumerator<T> extends Enumerator<T> {
|
||||
private _filter: Predicate<T>
|
||||
|
||||
constructor(enumerator: IEnumerator<T>, filter: Predicate<T>) {
|
||||
super(enumerator)
|
||||
this._filter = filter
|
||||
}
|
||||
|
||||
moveNext(): boolean {
|
||||
let done = super.moveNext()
|
||||
|
||||
while (!done && !this._filter(this.current, this._index)) {
|
||||
done = super.moveNext()
|
||||
}
|
||||
|
||||
return done
|
||||
}
|
||||
}
|
||||
|
||||
class FlatMapEnumerator<T, U = T> implements IEnumerator<U> {
|
||||
private _enumerator: IEnumerator<T>
|
||||
private _flatMap: Morphism<T, IEnumerator<U>>
|
||||
private _inner?: IEnumerator<U>
|
||||
private _index: number = -1
|
||||
|
||||
constructor(enumerator: IEnumerator<T>, flatMap: Morphism<T, IEnumerator<U>>) {
|
||||
this._enumerator = enumerator
|
||||
this._flatMap = flatMap
|
||||
}
|
||||
|
||||
get current(): Nullable<U> {
|
||||
return this._inner?.current
|
||||
}
|
||||
|
||||
moveNext(): boolean {
|
||||
if (this._inner && this._inner.moveNext()) {
|
||||
return true
|
||||
}
|
||||
|
||||
const done = this._enumerator.moveNext()
|
||||
|
||||
if (done) {
|
||||
return false
|
||||
}
|
||||
|
||||
this._index += 1
|
||||
this._inner = this._flatMap(this._enumerator.current, this._index)
|
||||
return this._inner.moveNext()
|
||||
}
|
||||
|
||||
reset(): void {
|
||||
this._index = -1
|
||||
this._inner = undefined
|
||||
this._enumerator.reset()
|
||||
}
|
||||
|
||||
toIterator<T>(): Iterator<T> {
|
||||
return Enumerator.toIterator(this) as Iterator<T>
|
||||
}
|
||||
}
|
||||
|
||||
class MapEnumerator<T, U = T> implements IEnumerator<U> {
|
||||
private _enumerator: IEnumerator<T>
|
||||
private _map: Morphism<T, U>
|
||||
private _current!: U
|
||||
private _index: number = -1
|
||||
|
||||
get current(): U {
|
||||
return this._current
|
||||
}
|
||||
|
||||
constructor(enumerator: IEnumerator<T>, map: Morphism<T, U>) {
|
||||
this._enumerator = enumerator
|
||||
this._map = map
|
||||
}
|
||||
|
||||
toIterator<U>(): Iterator<U> {
|
||||
return Enumerator.toIterator(this) as Iterator<U>
|
||||
}
|
||||
|
||||
moveNext(): boolean {
|
||||
this._index += 1
|
||||
const done = this._enumerator.moveNext()
|
||||
|
||||
if (!done) {
|
||||
this._current = this._map(this._enumerator.current, this._index)
|
||||
}
|
||||
|
||||
return done
|
||||
}
|
||||
|
||||
reset(): void {
|
||||
this._enumerator.reset()
|
||||
}
|
||||
}
|
||||
|
||||
class TakeEnumerator<T> extends Enumerator<T> {
|
||||
private _limit: number
|
||||
|
||||
constructor(enumerator: IEnumerator<T>, limit: number) {
|
||||
super(enumerator)
|
||||
this._limit = limit
|
||||
}
|
||||
|
||||
moveNext(): boolean {
|
||||
if (this._limit < 0) {
|
||||
return false
|
||||
} else {
|
||||
this._limit -= 1
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class FusedEnumerator<T> implements IEnumerator<T> {
|
||||
private _enumerators: IEnumerator<T>[]
|
||||
private _index: number = 0
|
||||
|
||||
private _cur() {
|
||||
return this._enumerators[this._index]
|
||||
}
|
||||
|
||||
private _done() {
|
||||
return this._index < this._enumerators.length
|
||||
}
|
||||
|
||||
get current(): Nullable<T> {
|
||||
return this._cur().current
|
||||
}
|
||||
|
||||
constructor(enumerators: IEnumerator<T>[]) {
|
||||
this._enumerators = enumerators
|
||||
}
|
||||
|
||||
toIterator<T>(): Iterator<T> {
|
||||
return Enumerator.toIterator(this) as Iterator<T>
|
||||
}
|
||||
|
||||
moveNext(): boolean {
|
||||
while (!this._done()) {
|
||||
if (this._cur().moveNext()) {
|
||||
return true
|
||||
}
|
||||
|
||||
this._index += 1
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
reset(): void {
|
||||
const len = this._enumerators.length
|
||||
|
||||
for (let i = 0; i < len; i++) {
|
||||
this._enumerators[i].reset()
|
||||
}
|
||||
|
||||
this._index = 0
|
||||
}
|
||||
}
|
||||
|
||||
export class Enumerable<T> implements IEnumerable<T>, Iterable<T> {
|
||||
private _enumerator: IEnumerator<T>
|
||||
|
||||
constructor(enumerator: IEnumerator<T>) {
|
||||
this._enumerator = enumerator
|
||||
}
|
||||
|
||||
static from<T>(enumerator: IEnumerator<T>) {
|
||||
return new this(enumerator)
|
||||
}
|
||||
|
||||
[Symbol.iterator](): Iterator<T> {
|
||||
return this._enumerator.toIterator()
|
||||
}
|
||||
|
||||
at(index: number): Nullable<T> {
|
||||
for (let i = 0; i < index; i++) {
|
||||
if (!this._enumerator.moveNext()) {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
const value = this._enumerator.current
|
||||
this._enumerator.reset()
|
||||
return value
|
||||
}
|
||||
|
||||
atOrDefault(index: number, defaultValue: T) {
|
||||
const value = this.at(index)
|
||||
return value || defaultValue
|
||||
}
|
||||
|
||||
atOrElse(index: number, defaultValue: () => T) {
|
||||
const value = this.at(index)
|
||||
return value || defaultValue()
|
||||
}
|
||||
|
||||
concat(other: IEnumerator<T>): FusedEnumerator<T> {
|
||||
return new FusedEnumerator([this._enumerator, other])
|
||||
}
|
||||
|
||||
|
||||
drop(limit: number) {
|
||||
return new Enumerable(new DropEnumerator(this._enumerator, limit))
|
||||
}
|
||||
|
||||
enumerator(): IEnumerator<T> {
|
||||
return this._enumerator
|
||||
}
|
||||
|
||||
every(predicate: Predicate<T>): boolean {
|
||||
let index = 0
|
||||
while (this._enumerator.moveNext()) {
|
||||
if (!predicate(this._enumerator.current, index)) {
|
||||
return false
|
||||
}
|
||||
|
||||
index += 1
|
||||
}
|
||||
|
||||
this._enumerator.reset()
|
||||
return true
|
||||
}
|
||||
|
||||
filter(predicate: Predicate<T>): IEnumerable<T> {
|
||||
return new Enumerable(new FilterEnumerator(this._enumerator, predicate))
|
||||
}
|
||||
|
||||
flatMap<U>(fn: Morphism<T, IEnumerator<U>>): IEnumerable<U> {
|
||||
return new Enumerable(new FlatMapEnumerator(this._enumerator, fn))
|
||||
}
|
||||
|
||||
map<U>(fn: Morphism<T, U>): IEnumerable<U> {
|
||||
return new Enumerable(new MapEnumerator(this._enumerator, fn))
|
||||
}
|
||||
|
||||
some(predicate: Predicate<T>): boolean {
|
||||
let index = 0
|
||||
while (this._enumerator.moveNext()) {
|
||||
if (predicate(this._enumerator.current, index)) {
|
||||
return true
|
||||
}
|
||||
|
||||
index += 1
|
||||
}
|
||||
|
||||
this._enumerator.reset()
|
||||
return false
|
||||
}
|
||||
|
||||
take(limit: number): IEnumerable<T> {
|
||||
return new Enumerable(new TakeEnumerator(this._enumerator, limit))
|
||||
}
|
||||
}
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const godot_1 = require("godot");
|
||||
const godot_annotations_1 = require("godot.annotations");
|
||||
class MessageBus extends godot_1.Node {
|
||||
static get instance() {
|
||||
return MessageBus._inst;
|
||||
}
|
||||
_ready() {
|
||||
MessageBus._inst = this;
|
||||
}
|
||||
}
|
||||
exports.default = MessageBus;
|
||||
__decorate([
|
||||
(0, godot_annotations_1.signal)()
|
||||
], MessageBus.prototype, "active_camera_changed", void 0);
|
||||
//# sourceMappingURL=message_bus.js.map
|
|
@ -1 +0,0 @@
|
|||
{"version":3,"file":"message_bus.js","sourceRoot":"../../../","sources":["src/message_bus.ts"],"names":[],"mappings":";;;;;;;;AAAA,iCAA+C;AAC/C,yDAA0C;AAE1C,MAAqB,UAAW,SAAQ,YAAI;IAG1C,MAAM,KAAK,QAAQ;QACjB,OAAO,UAAU,CAAC,KAAK,CAAA;IACzB,CAAC;IAKD,MAAM;QACJ,UAAU,CAAC,KAAK,GAAG,IAAI,CAAA;IACzB,CAAC;CACF;AAbD,6BAaC;AALC;IADC,IAAA,0BAAM,GAAE;yDACgC"}
|
|
@ -1,77 +0,0 @@
|
|||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const godot_1 = require("godot");
|
||||
const godot_annotations_1 = require("godot.annotations");
|
||||
const message_bus_1 = __importDefault(require("./message_bus"));
|
||||
class Player extends godot_1.CharacterBody3D {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
this.gravity = godot_1.ProjectSettings.get_setting('physics/3d/default_gravity');
|
||||
this.walk_speed = 3;
|
||||
this.walk_backward_speed = 2;
|
||||
this.run_speed = 6;
|
||||
this.turn_speed = 1;
|
||||
this._rotation_speed = 2 * Math.PI;
|
||||
}
|
||||
_ready() {
|
||||
this._rotation_speed = this.turn_speed * 2 * Math.PI;
|
||||
this._player_input = this.get_node(this.player_input);
|
||||
this._camera = this.get_viewport().get_camera_3d();
|
||||
message_bus_1.default.instance.active_camera_changed.connect(godot_1.Callable.create(this, this.on_camera_changed));
|
||||
}
|
||||
get_movement(delta) {
|
||||
const input = this._player_input.movement_input;
|
||||
return godot_1.Vector3.MULTIPLY(this.walk_speed, new godot_1.Vector3(input.x, 0, input.y));
|
||||
}
|
||||
//get_translation(_delta: float64): Vector3 {
|
||||
// const forward = Vector3.MULTIPLY(-1, this.transform.basis.z)
|
||||
// return Vector3.MULTIPLY(forward, this.get_movement())
|
||||
//}
|
||||
get_gravitational_force(delta) {
|
||||
return -this.gravity * delta;
|
||||
}
|
||||
relative_to(target, vec) {
|
||||
return vec.rotated(godot_1.Vector3.UP, target.rotation.y);
|
||||
}
|
||||
on_camera_changed(camera) {
|
||||
this._camera = camera;
|
||||
}
|
||||
_physics_process(delta) {
|
||||
const movement = this.relative_to(this._camera, this.get_movement(delta));
|
||||
if (!movement.is_zero_approx()) {
|
||||
this.look_at(godot_1.Vector3.NEGATE(godot_1.Vector3.ADD(this.position, movement)), godot_1.Vector3.UP);
|
||||
}
|
||||
this.velocity = new godot_1.Vector3(movement.x, this.velocity.y + this.get_gravitational_force(delta), movement.z);
|
||||
this.move_and_slide();
|
||||
}
|
||||
}
|
||||
exports.default = Player;
|
||||
__decorate([
|
||||
(0, godot_annotations_1.export_)(godot_1.Variant.Type.TYPE_NODE_PATH)
|
||||
], Player.prototype, "player_input", void 0);
|
||||
__decorate([
|
||||
(0, godot_annotations_1.help)('Forward walk speed in units per second'),
|
||||
(0, godot_annotations_1.export_)(godot_1.Variant.Type.TYPE_FLOAT)
|
||||
], Player.prototype, "walk_speed", void 0);
|
||||
__decorate([
|
||||
(0, godot_annotations_1.help)('Backward walk speed in units per second'),
|
||||
(0, godot_annotations_1.export_)(godot_1.Variant.Type.TYPE_FLOAT)
|
||||
], Player.prototype, "walk_backward_speed", void 0);
|
||||
__decorate([
|
||||
(0, godot_annotations_1.help)('Run speed in units per second'),
|
||||
(0, godot_annotations_1.export_)(godot_1.Variant.Type.TYPE_FLOAT)
|
||||
], Player.prototype, "run_speed", void 0);
|
||||
__decorate([
|
||||
(0, godot_annotations_1.help)('Turn speed in rotations per second'),
|
||||
(0, godot_annotations_1.export_)(godot_1.Variant.Type.TYPE_FLOAT)
|
||||
], Player.prototype, "turn_speed", void 0);
|
||||
//# sourceMappingURL=player.js.map
|
|
@ -1 +0,0 @@
|
|||
{"version":3,"file":"player.js","sourceRoot":"../../../","sources":["src/player.ts"],"names":[],"mappings":"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"}
|
|
@ -1,13 +0,0 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const godot_1 = require("godot");
|
||||
class PlayerAnimation extends godot_1.AnimationTree {
|
||||
_ready() {
|
||||
this.player = this.get_parent();
|
||||
this.player_input = this.player.get_node(this.player.player_input);
|
||||
}
|
||||
}
|
||||
PlayerAnimation.Interact = 'parameters/interact';
|
||||
PlayerAnimation.WalkSpeed = 'parameters/Walk/blend_position';
|
||||
exports.default = PlayerAnimation;
|
||||
//# sourceMappingURL=player_animation.js.map
|
|
@ -1 +0,0 @@
|
|||
{"version":3,"file":"player_animation.js","sourceRoot":"../../../","sources":["src/player_animation.ts"],"names":[],"mappings":";;AAAA,iCAAqC;AAIrC,MAAqB,eAAgB,SAAQ,qBAAa;IAOxD,MAAM;QACJ,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,UAAU,EAAY,CAAA;QACzC,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,YAAa,CAAgB,CAAA;IACpF,CAAC;;AATc,wBAAQ,GAAG,qBAAqB,CAAA;AAChC,yBAAS,GAAG,gCAAgC,CAAA;kBAFxC,eAAe"}
|
|
@ -1,30 +0,0 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const godot_1 = require("godot");
|
||||
var Device;
|
||||
(function (Device) {
|
||||
Device[Device["KeyboardMouse"] = 0] = "KeyboardMouse";
|
||||
Device[Device["Gamepad"] = 1] = "Gamepad";
|
||||
})(Device || (Device = {}));
|
||||
class PlayerInput extends godot_1.Node3D {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
this._last_known_device = Device.KeyboardMouse;
|
||||
this._movement_input = godot_1.Vector2.ZERO;
|
||||
}
|
||||
get last_known_device() { return this._last_known_device; }
|
||||
get movement_input() { return this._movement_input; }
|
||||
_process(delta) {
|
||||
this._movement_input = godot_1.Input.get_vector('move_left', 'move_right', 'move_forward', 'move_back');
|
||||
}
|
||||
_input(event) {
|
||||
if (event instanceof godot_1.InputEventKey || event instanceof godot_1.InputEventMouse) {
|
||||
this._last_known_device = Device.KeyboardMouse;
|
||||
}
|
||||
else if (event instanceof godot_1.InputEventJoypadButton || event instanceof godot_1.InputEventJoypadMotion) {
|
||||
this._last_known_device = Device.Gamepad;
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.default = PlayerInput;
|
||||
//# sourceMappingURL=player_input.js.map
|
|
@ -1 +0,0 @@
|
|||
{"version":3,"file":"player_input.js","sourceRoot":"../../../","sources":["src/player_input.ts"],"names":[],"mappings":";;AAAA,iCAAmJ;AAEnJ,IAAK,MAGJ;AAHD,WAAK,MAAM;IACT,qDAAiB,CAAA;IACjB,yCAAW,CAAA;AACb,CAAC,EAHI,MAAM,KAAN,MAAM,QAGV;AAED,MAAqB,WAAY,SAAQ,cAAM;IAA/C;;QACE,uBAAkB,GAAG,MAAM,CAAC,aAAa,CAAA;QAGzC,oBAAe,GAAY,eAAO,CAAC,IAAI,CAAA;IAczC,CAAC;IAhBC,IAAI,iBAAiB,KAAK,OAAO,IAAI,CAAC,kBAAkB,CAAA,CAAC,CAAC;IAG1D,IAAI,cAAc,KAAK,OAAO,IAAI,CAAC,eAAe,CAAA,CAAC,CAAC;IAEpD,QAAQ,CAAC,KAAc;QACrB,IAAI,CAAC,eAAe,GAAG,aAAK,CAAC,UAAU,CAAC,WAAW,EAAE,YAAY,EAAE,cAAc,EAAE,WAAW,CAAC,CAAA;IACjG,CAAC;IAED,MAAM,CAAC,KAAiB;QACtB,IAAI,KAAK,YAAY,qBAAa,IAAI,KAAK,YAAY,uBAAe,EAAE,CAAC;YACvE,IAAI,CAAC,kBAAkB,GAAG,MAAM,CAAC,aAAa,CAAA;QAChD,CAAC;aAAM,IAAI,KAAK,YAAY,8BAAsB,IAAI,KAAK,YAAY,8BAAsB,EAAE,CAAC;YAC9F,IAAI,CAAC,kBAAkB,GAAG,MAAM,CAAC,OAAO,CAAA;QAC1C,CAAC;IACH,CAAC;CACF;AAlBD,8BAkBC"}
|
|
@ -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": true, /* Only output d.ts files and not JavaScript files. */
|
||||
"emitDeclarationOnly": false, /* 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": true, /* Disable emitting files from a compilation. */
|
||||
"noEmit": false, /* 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. */
|
||||
|
|
3
typings/godot1.gen.d.ts
vendored
3
typings/godot1.gen.d.ts
vendored
|
@ -8312,6 +8312,9 @@ declare module "godot" {
|
|||
class CanvasItemEditorPlugin extends EditorPlugin {
|
||||
constructor(identifier?: any)
|
||||
}
|
||||
class CanvasItemEditorSelectedItem extends Object {
|
||||
constructor(identifier?: any)
|
||||
}
|
||||
class CanvasItemEditorViewport extends Control {
|
||||
constructor(identifier?: any)
|
||||
}
|
||||
|
|
67
typings/godot2.gen.d.ts
vendored
67
typings/godot2.gen.d.ts
vendored
|
@ -84,6 +84,14 @@ declare module "godot" {
|
|||
get color_regions(): GDictionary
|
||||
set color_regions(value: GDictionary)
|
||||
}
|
||||
class CodeTextEditor extends VBoxContainer {
|
||||
constructor(identifier?: any)
|
||||
readonly validate_script: Signal0
|
||||
readonly load_theme_settings: Signal0
|
||||
readonly show_errors_panel: Signal0
|
||||
readonly show_warnings_panel: Signal0
|
||||
readonly zoomed: Signal1<float64>
|
||||
}
|
||||
namespace CollisionObject2D {
|
||||
enum DisableMode {
|
||||
/** When [member Node.process_mode] is set to [constant Node.PROCESS_MODE_DISABLED], remove from the physics simulation to stop all physics interactions with this [CollisionObject2D].
|
||||
|
@ -1001,6 +1009,9 @@ declare module "godot" {
|
|||
class ConnectDialogBinds extends Object {
|
||||
constructor(identifier?: any)
|
||||
}
|
||||
class ConnectionInfoDialog extends AcceptDialog {
|
||||
constructor(identifier?: any)
|
||||
}
|
||||
class ConnectionsDock extends VBoxContainer {
|
||||
constructor(identifier?: any)
|
||||
update_tree(): void
|
||||
|
@ -1985,6 +1996,9 @@ declare module "godot" {
|
|||
class ControlEditorToolbar extends HBoxContainer {
|
||||
constructor(identifier?: any)
|
||||
}
|
||||
class ControlPositioningWarning extends MarginContainer {
|
||||
constructor(identifier?: any)
|
||||
}
|
||||
/** A 2D convex polygon shape used for physics collision.
|
||||
*
|
||||
* @link https://docs.godotengine.org/en/4.3/classes/class_convexpolygonshape2d.html
|
||||
|
@ -4606,6 +4620,10 @@ declare module "godot" {
|
|||
class EditorPackedScenePreviewPlugin extends EditorResourcePreviewGenerator {
|
||||
constructor(identifier?: any)
|
||||
}
|
||||
class EditorPaginator extends HBoxContainer {
|
||||
constructor(identifier?: any)
|
||||
readonly page_changed: Signal1<int64>
|
||||
}
|
||||
/** Editor-only singleton that returns paths to various OS-specific data folders and files.
|
||||
*
|
||||
* @link https://docs.godotengine.org/en/4.3/classes/class_editorpaths.html
|
||||
|
@ -4662,6 +4680,9 @@ declare module "godot" {
|
|||
class EditorPerformanceProfiler extends HSplitContainer {
|
||||
constructor(identifier?: any)
|
||||
}
|
||||
class EditorPlainTextSyntaxHighlighter extends EditorSyntaxHighlighter {
|
||||
constructor(identifier?: any)
|
||||
}
|
||||
namespace EditorPlugin {
|
||||
enum CustomControlContainer {
|
||||
/** Main editor toolbar, next to play buttons. */
|
||||
|
@ -5180,9 +5201,18 @@ declare module "godot" {
|
|||
/** Emitted when selected. Used internally. */
|
||||
readonly selected: Signal2<string, int64>
|
||||
}
|
||||
class EditorPropertyArray extends EditorProperty {
|
||||
constructor(identifier?: any)
|
||||
}
|
||||
class EditorPropertyArrayObject extends RefCounted {
|
||||
constructor(identifier?: any)
|
||||
}
|
||||
class EditorPropertyCheck extends EditorProperty {
|
||||
constructor(identifier?: any)
|
||||
}
|
||||
class EditorPropertyColor extends EditorProperty {
|
||||
constructor(identifier?: any)
|
||||
}
|
||||
class EditorPropertyDictionaryObject extends RefCounted {
|
||||
constructor(identifier?: any)
|
||||
}
|
||||
|
@ -5192,6 +5222,12 @@ declare module "godot" {
|
|||
class EditorPropertyFloat extends EditorProperty {
|
||||
constructor(identifier?: any)
|
||||
}
|
||||
class EditorPropertyFontNamesArray extends EditorPropertyArray {
|
||||
constructor(identifier?: any)
|
||||
}
|
||||
class EditorPropertyFontOTObject extends RefCounted {
|
||||
constructor(identifier?: any)
|
||||
}
|
||||
class EditorPropertyInteger extends EditorProperty {
|
||||
constructor(identifier?: any)
|
||||
}
|
||||
|
@ -5203,6 +5239,9 @@ declare module "godot" {
|
|||
readonly flag_changed: Signal1<int64>
|
||||
readonly rename_confirmed: Signal2<int64, string>
|
||||
}
|
||||
class EditorPropertyLocale extends EditorProperty {
|
||||
constructor(identifier?: any)
|
||||
}
|
||||
class EditorPropertyLocalizableString extends EditorProperty {
|
||||
constructor(identifier?: any)
|
||||
}
|
||||
|
@ -5212,22 +5251,40 @@ declare module "godot" {
|
|||
class EditorPropertyNameProcessor extends Node {
|
||||
constructor(identifier?: any)
|
||||
}
|
||||
class EditorPropertyNil extends EditorProperty {
|
||||
constructor(identifier?: any)
|
||||
}
|
||||
class EditorPropertyNodePath extends EditorProperty {
|
||||
constructor(identifier?: any)
|
||||
}
|
||||
class EditorPropertyOTFeatures extends EditorProperty {
|
||||
constructor(identifier?: any)
|
||||
}
|
||||
class EditorPropertyOTVariation extends EditorProperty {
|
||||
constructor(identifier?: any)
|
||||
}
|
||||
class EditorPropertyPath extends EditorProperty {
|
||||
constructor(identifier?: any)
|
||||
}
|
||||
class EditorPropertyResource extends EditorProperty {
|
||||
constructor(identifier?: any)
|
||||
}
|
||||
class EditorPropertySizeFlags extends EditorProperty {
|
||||
constructor(identifier?: any)
|
||||
}
|
||||
class EditorPropertyText extends EditorProperty {
|
||||
constructor(identifier?: any)
|
||||
}
|
||||
class EditorPropertyVector2i extends EditorPropertyVectorN {
|
||||
class EditorPropertyTextEnum extends EditorProperty {
|
||||
constructor(identifier?: any)
|
||||
}
|
||||
class EditorPropertyVector3 extends EditorPropertyVectorN {
|
||||
class EditorPropertyTransform2D extends EditorProperty {
|
||||
constructor(identifier?: any)
|
||||
}
|
||||
class EditorPropertyVector2 extends EditorPropertyVectorN {
|
||||
constructor(identifier?: any)
|
||||
}
|
||||
class EditorPropertyVector2i extends EditorPropertyVectorN {
|
||||
constructor(identifier?: any)
|
||||
}
|
||||
class EditorPropertyVectorN extends EditorProperty {
|
||||
|
@ -5685,6 +5742,9 @@ declare module "godot" {
|
|||
/** Emitted when the value form loses focus. */
|
||||
readonly value_focus_exited: Signal0
|
||||
}
|
||||
class EditorStandardSyntaxHighlighter extends EditorSyntaxHighlighter {
|
||||
constructor(identifier?: any)
|
||||
}
|
||||
/** Base class for [SyntaxHighlighter] used by the [ScriptEditor].
|
||||
*
|
||||
* @link https://docs.godotengine.org/en/4.3/classes/class_editorsyntaxhighlighter.html
|
||||
|
@ -7934,6 +7994,9 @@ declare module "godot" {
|
|||
get opentype_feature_overrides(): GDictionary
|
||||
set opentype_feature_overrides(value: GDictionary)
|
||||
}
|
||||
class FontPreview extends Control {
|
||||
constructor(identifier?: any)
|
||||
}
|
||||
/** A variation of a font with additional settings.
|
||||
*
|
||||
* @link https://docs.godotengine.org/en/4.3/classes/class_fontvariation.html
|
||||
|
|
9
typings/godot3.gen.d.ts
vendored
9
typings/godot3.gen.d.ts
vendored
|
@ -529,6 +529,9 @@ declare module "godot" {
|
|||
class GodotPhysicsServer3D extends PhysicsServer3D {
|
||||
constructor(identifier?: any)
|
||||
}
|
||||
class GotoLineDialog extends ConfirmationDialog {
|
||||
constructor(identifier?: any)
|
||||
}
|
||||
namespace Gradient {
|
||||
enum InterpolationMode {
|
||||
/** Linear interpolation. */
|
||||
|
@ -6598,12 +6601,6 @@ declare module "godot" {
|
|||
get multimesh(): MultiMesh
|
||||
set multimesh(value: MultiMesh)
|
||||
}
|
||||
class MultiNodeEdit extends RefCounted {
|
||||
constructor(identifier?: any)
|
||||
_hide_script_from_inspector(): boolean
|
||||
_hide_metadata_from_inspector(): boolean
|
||||
_get_editor_name(): string
|
||||
}
|
||||
namespace MultiplayerAPI {
|
||||
enum RPCMode {
|
||||
/** Used with [method Node.rpc_config] to disable a method or property for all RPC calls, making it unavailable. Default for all methods. */
|
||||
|
|
3
typings/godot4.gen.d.ts
vendored
3
typings/godot4.gen.d.ts
vendored
|
@ -363,9 +363,6 @@ declare module "godot" {
|
|||
class Node3DEditorPlugin extends EditorPlugin {
|
||||
constructor(identifier?: any)
|
||||
}
|
||||
class Node3DEditorSelectedItem extends Object {
|
||||
constructor(identifier?: any)
|
||||
}
|
||||
class Node3DEditorViewport extends Control {
|
||||
constructor(identifier?: any)
|
||||
readonly toggle_maximize_view: Signal1<Object>
|
||||
|
|
13
typings/godot5.gen.d.ts
vendored
13
typings/godot5.gen.d.ts
vendored
|
@ -2131,6 +2131,10 @@ declare module "godot" {
|
|||
class ScriptEditorPlugin extends EditorPlugin {
|
||||
constructor(identifier?: any)
|
||||
}
|
||||
class ScriptEditorQuickOpen extends ConfirmationDialog {
|
||||
constructor(identifier?: any)
|
||||
readonly goto_line: Signal1<int64>
|
||||
}
|
||||
/** @link https://docs.godotengine.org/en/4.3/classes/class_scriptextension.html */
|
||||
class ScriptExtension extends Script {
|
||||
constructor(identifier?: any)
|
||||
|
@ -2295,6 +2299,9 @@ declare module "godot" {
|
|||
/* gdvirtual */ _handles_global_class_type(type: string): boolean
|
||||
/* gdvirtual */ _get_global_class_name(path: string): GDictionary
|
||||
}
|
||||
class ScriptTextEditor extends ScriptEditorBase {
|
||||
constructor(identifier?: any)
|
||||
}
|
||||
/** Abstract base class for scrollbars.
|
||||
*
|
||||
* @link https://docs.godotengine.org/en/4.3/classes/class_scrollbar.html
|
||||
|
@ -4722,6 +4729,12 @@ declare module "godot" {
|
|||
get constant_angular_velocity(): Vector3
|
||||
set constant_angular_velocity(value: Vector3)
|
||||
}
|
||||
class StaticRaycaster extends RefCounted {
|
||||
constructor(identifier?: any)
|
||||
}
|
||||
class StaticRaycasterEmbree extends StaticRaycaster {
|
||||
constructor(identifier?: any)
|
||||
}
|
||||
/** Application status indicator (aka notification area icon).
|
||||
*
|
||||
* **Note:** Status indicator is implemented on macOS and Windows.
|
||||
|
|
Loading…
Add table
Reference in a new issue