Tweaked some numbers to get a better "swarm"

This commit is contained in:
Douwe Ravers
2024-10-07 23:50:50 +02:00
parent af7a46cd23
commit 7f0591298a
27 changed files with 1403 additions and 26 deletions

BIN
.build/html.zip Normal file

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

View File

@@ -0,0 +1,213 @@
/**************************************************************************/
/* audio.worklet.js */
/**************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/**************************************************************************/
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
class RingBuffer {
constructor(p_buffer, p_state, p_threads) {
this.buffer = p_buffer;
this.avail = p_state;
this.threads = p_threads;
this.rpos = 0;
this.wpos = 0;
}
data_left() {
return this.threads ? Atomics.load(this.avail, 0) : this.avail;
}
space_left() {
return this.buffer.length - this.data_left();
}
read(output) {
const size = this.buffer.length;
let from = 0;
let to_write = output.length;
if (this.rpos + to_write > size) {
const high = size - this.rpos;
output.set(this.buffer.subarray(this.rpos, size));
from = high;
to_write -= high;
this.rpos = 0;
}
if (to_write) {
output.set(this.buffer.subarray(this.rpos, this.rpos + to_write), from);
}
this.rpos += to_write;
if (this.threads) {
Atomics.add(this.avail, 0, -output.length);
Atomics.notify(this.avail, 0);
} else {
this.avail -= output.length;
}
}
write(p_buffer) {
const to_write = p_buffer.length;
const mw = this.buffer.length - this.wpos;
if (mw >= to_write) {
this.buffer.set(p_buffer, this.wpos);
this.wpos += to_write;
if (mw === to_write) {
this.wpos = 0;
}
} else {
const high = p_buffer.subarray(0, mw);
const low = p_buffer.subarray(mw);
this.buffer.set(high, this.wpos);
this.buffer.set(low);
this.wpos = low.length;
}
if (this.threads) {
Atomics.add(this.avail, 0, to_write);
Atomics.notify(this.avail, 0);
} else {
this.avail += to_write;
}
}
}
class GodotProcessor extends AudioWorkletProcessor {
constructor() {
super();
this.threads = false;
this.running = true;
this.lock = null;
this.notifier = null;
this.output = null;
this.output_buffer = new Float32Array();
this.input = null;
this.input_buffer = new Float32Array();
this.port.onmessage = (event) => {
const cmd = event.data['cmd'];
const data = event.data['data'];
this.parse_message(cmd, data);
};
}
process_notify() {
if (this.notifier) {
Atomics.add(this.notifier, 0, 1);
Atomics.notify(this.notifier, 0);
}
}
parse_message(p_cmd, p_data) {
if (p_cmd === 'start' && p_data) {
const state = p_data[0];
let idx = 0;
this.threads = true;
this.lock = state.subarray(idx, ++idx);
this.notifier = state.subarray(idx, ++idx);
const avail_in = state.subarray(idx, ++idx);
const avail_out = state.subarray(idx, ++idx);
this.input = new RingBuffer(p_data[1], avail_in, true);
this.output = new RingBuffer(p_data[2], avail_out, true);
} else if (p_cmd === 'stop') {
this.running = false;
this.output = null;
this.input = null;
this.lock = null;
this.notifier = null;
} else if (p_cmd === 'start_nothreads') {
this.output = new RingBuffer(p_data[0], p_data[0].length, false);
} else if (p_cmd === 'chunk') {
this.output.write(p_data);
}
}
static array_has_data(arr) {
return arr.length && arr[0].length && arr[0][0].length;
}
process(inputs, outputs, parameters) {
if (!this.running) {
return false; // Stop processing.
}
if (this.output === null) {
return true; // Not ready yet, keep processing.
}
const process_input = GodotProcessor.array_has_data(inputs);
if (process_input) {
const input = inputs[0];
const chunk = input[0].length * input.length;
if (this.input_buffer.length !== chunk) {
this.input_buffer = new Float32Array(chunk);
}
if (!this.threads) {
GodotProcessor.write_input(this.input_buffer, input);
this.port.postMessage({ 'cmd': 'input', 'data': this.input_buffer });
} else if (this.input.space_left() >= chunk) {
GodotProcessor.write_input(this.input_buffer, input);
this.input.write(this.input_buffer);
} else {
// this.port.postMessage('Input buffer is full! Skipping input frame.'); // Uncomment this line to debug input buffer.
}
}
const process_output = GodotProcessor.array_has_data(outputs);
if (process_output) {
const output = outputs[0];
const chunk = output[0].length * output.length;
if (this.output_buffer.length !== chunk) {
this.output_buffer = new Float32Array(chunk);
}
if (this.output.data_left() >= chunk) {
this.output.read(this.output_buffer);
GodotProcessor.write_output(output, this.output_buffer);
if (!this.threads) {
this.port.postMessage({ 'cmd': 'read', 'data': chunk });
}
} else {
// this.port.postMessage('Output buffer has not enough frames! Skipping output frame.'); // Uncomment this line to debug output buffer.
}
}
this.process_notify();
return true;
}
static write_output(dest, source) {
const channels = dest.length;
for (let ch = 0; ch < channels; ch++) {
for (let sample = 0; sample < dest[ch].length; sample++) {
dest[ch][sample] = source[sample * channels + ch];
}
}
}
static write_input(dest, source) {
const channels = source.length;
for (let ch = 0; ch < channels; ch++) {
for (let sample = 0; sample < source[ch].length; sample++) {
dest[sample * channels + ch] = source[ch][sample];
}
}
}
}
registerProcessor('godot-processor', GodotProcessor);

199
.build/html/index.html Normal file
View File

@@ -0,0 +1,199 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0">
<title>RomAnts</title>
<style>
html, body, #canvas {
margin: 0;
padding: 0;
border: 0;
}
body {
color: white;
background-color: black;
overflow: hidden;
touch-action: none;
}
#canvas {
display: block;
}
#canvas:focus {
outline: none;
}
#status, #status-splash, #status-progress {
position: absolute;
left: 0;
right: 0;
}
#status, #status-splash {
top: 0;
bottom: 0;
}
#status {
background-color: #242424;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
visibility: hidden;
}
#status-splash {
max-height: 100%;
max-width: 100%;
margin: auto;
}
#status-progress, #status-notice {
display: none;
}
#status-progress {
bottom: 10%;
width: 50%;
margin: 0 auto;
}
#status-notice {
background-color: #5b3943;
border-radius: 0.5rem;
border: 1px solid #9b3943;
color: #e0e0e0;
font-family: 'Noto Sans', 'Droid Sans', Arial, sans-serif;
line-height: 1.3;
margin: 0 2rem;
overflow: hidden;
padding: 1rem;
text-align: center;
z-index: 1;
}
</style>
<link id="-gd-engine-icon" rel="icon" type="image/png" href="index.icon.png" />
<link rel="apple-touch-icon" href="index.apple-touch-icon.png"/>
</head>
<body>
<canvas id="canvas">
Your browser does not support the canvas tag.
</canvas>
<noscript>
Your browser does not support JavaScript.
</noscript>
<div id="status">
<img id="status-splash" src="index.png" alt="">
<progress id="status-progress"></progress>
<div id="status-notice"></div>
</div>
<script src="index.js"></script>
<script>
const GODOT_CONFIG = {"args":[],"canvasResizePolicy":2,"ensureCrossOriginIsolationHeaders":true,"executable":"index","experimentalVK":false,"fileSizes":{"index.pck":11490448,"index.wasm":35376909},"focusCanvas":true,"gdextensionLibs":[]};
const GODOT_THREADS_ENABLED = false;
const engine = new Engine(GODOT_CONFIG);
(function () {
const statusOverlay = document.getElementById('status');
const statusProgress = document.getElementById('status-progress');
const statusNotice = document.getElementById('status-notice');
let initializing = true;
let statusMode = '';
function setStatusMode(mode) {
if (statusMode === mode || !initializing) {
return;
}
if (mode === 'hidden') {
statusOverlay.remove();
initializing = false;
return;
}
statusOverlay.style.visibility = 'visible';
statusProgress.style.display = mode === 'progress' ? 'block' : 'none';
statusNotice.style.display = mode === 'notice' ? 'block' : 'none';
statusMode = mode;
}
function setStatusNotice(text) {
while (statusNotice.lastChild) {
statusNotice.removeChild(statusNotice.lastChild);
}
const lines = text.split('\n');
lines.forEach((line) => {
statusNotice.appendChild(document.createTextNode(line));
statusNotice.appendChild(document.createElement('br'));
});
}
function displayFailureNotice(err) {
console.error(err);
if (err instanceof Error) {
setStatusNotice(err.message);
} else if (typeof err === 'string') {
setStatusNotice(err);
} else {
setStatusNotice('An unknown error occured');
}
setStatusMode('notice');
initializing = false;
}
const missing = Engine.getMissingFeatures({
threads: GODOT_THREADS_ENABLED,
});
if (missing.length !== 0) {
if (GODOT_CONFIG['serviceWorker'] && GODOT_CONFIG['ensureCrossOriginIsolationHeaders'] && 'serviceWorker' in navigator) {
// There's a chance that installing the service worker would fix the issue
Promise.race([
navigator.serviceWorker.getRegistration().then((registration) => {
if (registration != null) {
return Promise.reject(new Error('Service worker already exists.'));
}
return registration;
}).then(() => engine.installServiceWorker()),
// For some reason, `getRegistration()` can stall
new Promise((resolve) => {
setTimeout(() => resolve(), 2000);
}),
]).catch((err) => {
console.error('Error while registering service worker:', err);
}).then(() => {
window.location.reload();
});
} else {
// Display the message as usual
const missingMsg = 'Error\nThe following features required to run Godot projects on the Web are missing:\n';
displayFailureNotice(missingMsg + missing.join('\n'));
}
} else {
setStatusMode('progress');
engine.startGame({
'onProgress': function (current, total) {
if (current > 0 && total > 0) {
statusProgress.value = current;
statusProgress.max = total;
} else {
statusProgress.removeAttribute('value');
statusProgress.removeAttribute('max');
}
},
}).then(() => {
setStatusMode('hidden');
}, displayFailureNotice);
}
}());
</script>
</body>
</html>

BIN
.build/html/index.icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 127 KiB

908
.build/html/index.js Normal file

File diff suppressed because one or more lines are too long

BIN
.build/html/index.pck Normal file

Binary file not shown.

BIN
.build/html/index.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

BIN
.build/html/index.wasm Normal file

Binary file not shown.

BIN
.build/linux.zip Normal file

Binary file not shown.

BIN
.build/linux/RomAnts.pck Normal file

Binary file not shown.

BIN
.build/linux/RomAnts.x86_64 Normal file

Binary file not shown.

BIN
.build/windows.zip Normal file

Binary file not shown.

BIN
.build/windows/RomAnts.exe Normal file

Binary file not shown.

BIN
.build/windows/RomAnts.pck Normal file

Binary file not shown.

View File

@@ -13,6 +13,7 @@ func _on_attack_timer_timeout() -> void:
if ant is EnemyAnt and other_ant is not EnemyAnt: if ant is EnemyAnt and other_ant is not EnemyAnt:
other_ant.hit(randi_range(0, ant.damage)) other_ant.hit(randi_range(0, ant.damage))
attack.emit() attack.emit()
if ant is SoldierAnt: return
for area in get_overlapping_areas(): for area in get_overlapping_areas():
if area.get_parent() is Building: if area.get_parent() is Building:
var building := area.get_parent() as Building var building := area.get_parent() as Building

View File

@@ -5,5 +5,5 @@ extends MeshInstance3D
func _process(delta: float) -> void: func _process(delta: float) -> void:
visible = ant.capacity > 0 and \ visible = ant.capacity > 0 and \
ant.target == PlayerCamp.instance and \ ant.target is PlayerCamp and \
ant.source_target.type == type ant.source_target.type == type

View File

@@ -15,8 +15,6 @@ height = 2.88419
axis_lock_angular_x = true axis_lock_angular_x = true
axis_lock_angular_z = true axis_lock_angular_z = true
script = ExtResource("1_kehry") script = ExtResource("1_kehry")
damage = 4
max_health = 15
speed = 3.0 speed = 3.0
[node name="CollisionShape3D" type="CollisionShape3D" parent="."] [node name="CollisionShape3D" type="CollisionShape3D" parent="."]
@@ -24,7 +22,7 @@ transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0, 1.4
shape = SubResource("CapsuleShape3D_bqyr6") shape = SubResource("CapsuleShape3D_bqyr6")
[node name="NavigationAgent3D" type="NavigationAgent3D" parent="."] [node name="NavigationAgent3D" type="NavigationAgent3D" parent="."]
target_desired_distance = 2.0 target_desired_distance = 3.0
avoidance_enabled = true avoidance_enabled = true
debug_path_custom_color = Color(0.3, 0.381667, 1, 1) debug_path_custom_color = Color(0.3, 0.381667, 1, 1)
@@ -38,9 +36,9 @@ texture = ExtResource("2_hdgws")
[node name="Skeleton3D" parent="enemy/EnemyAnt" index="0"] [node name="Skeleton3D" parent="enemy/EnemyAnt" index="0"]
bones/0/rotation = Quaternion(-0.151731, -0.023891, -0.015694, 0.988008) bones/0/rotation = Quaternion(-0.151731, -0.023891, -0.015694, 0.988008)
bones/1/rotation = Quaternion(-0.448048, 0.00344809, -0.000394401, 0.894003) bones/1/rotation = Quaternion(-0.453618, 0.00738223, -0.000844401, 0.891166)
bones/2/rotation = Quaternion(0.597894, 0.051707, -0.697194, 0.392135) bones/2/rotation = Quaternion(0.597894, 0.051707, -0.697194, 0.392135)
bones/3/rotation = Quaternion(-0.268977, 0.0602213, -0.581107, 0.765729) bones/3/rotation = Quaternion(-0.261701, 0.0566905, -0.585419, 0.765234)
bones/3/scale = Vector3(1, 1, 1) bones/3/scale = Vector3(1, 1, 1)
bones/4/rotation = Quaternion(-0.185361, 0.0767715, -0.304188, 0.931245) bones/4/rotation = Quaternion(-0.185361, 0.0767715, -0.304188, 0.931245)
bones/4/scale = Vector3(1, 1, 1) bones/4/scale = Vector3(1, 1, 1)
@@ -55,10 +53,10 @@ bones/8/rotation = Quaternion(0.731112, 0.216438, -0.270013, 0.587982)
bones/9/rotation = Quaternion(-0.147272, -0.690287, -0.291994, 0.64541) bones/9/rotation = Quaternion(-0.147272, -0.690287, -0.291994, 0.64541)
bones/10/rotation = Quaternion(0.035527, -0.0722718, -0.344413, 0.935358) bones/10/rotation = Quaternion(0.035527, -0.0722718, -0.344413, 0.935358)
bones/10/scale = Vector3(1, 1, 1) bones/10/scale = Vector3(1, 1, 1)
bones/11/rotation = Quaternion(0.582122, -0.384409, 0.688139, 0.199572) bones/11/rotation = Quaternion(0.58198, -0.38065, 0.688782, 0.204903)
bones/12/rotation = Quaternion(-0.275331, -0.0633099, 0.577289, 0.766108) bones/12/rotation = Quaternion(-0.275331, -0.0633099, 0.577289, 0.766108)
bones/12/scale = Vector3(1, 1, 1) bones/12/scale = Vector3(1, 1, 1)
bones/13/rotation = Quaternion(0.0216325, 0.352033, 0.113455, 0.928834) bones/13/rotation = Quaternion(0.0127256, 0.347415, 0.116465, 0.930364)
bones/13/scale = Vector3(1, 1, 1) bones/13/scale = Vector3(1, 1, 1)
bones/14/position = Vector3(-0.131012, 0.4206, 0.0209323) bones/14/position = Vector3(-0.131012, 0.4206, 0.0209323)
bones/14/rotation = Quaternion(0.311801, -0.156763, 0.515707, 0.782465) bones/14/rotation = Quaternion(0.311801, -0.156763, 0.515707, 0.782465)
@@ -71,7 +69,7 @@ bones/17/rotation = Quaternion(0.742166, -0.221688, 0.264848, 0.574369)
bones/18/rotation = Quaternion(-0.156224, 0.731565, 0.301322, 0.59128) bones/18/rotation = Quaternion(-0.156224, 0.731565, 0.301322, 0.59128)
bones/19/rotation = Quaternion(0.035527, 0.0722718, 0.344413, 0.935358) bones/19/rotation = Quaternion(0.035527, 0.0722718, 0.344413, 0.935358)
bones/19/scale = Vector3(1, 1, 1) bones/19/scale = Vector3(1, 1, 1)
bones/20/rotation = Quaternion(0.000485378, 0.711083, 0.703105, -0.00183471) bones/20/rotation = Quaternion(0.00103909, 0.715589, 0.69851, -0.00392773)
[node name="AnimationTree" type="AnimationTree" parent="enemy"] [node name="AnimationTree" type="AnimationTree" parent="enemy"]
tree_root = ExtResource("4_px4kn") tree_root = ExtResource("4_px4kn")

View File

@@ -76,9 +76,9 @@ stretch_mode = 4
[node name="Skeleton3D" parent="soldier/SoldierAnt" index="0"] [node name="Skeleton3D" parent="soldier/SoldierAnt" index="0"]
bones/0/rotation = Quaternion(-0.151731, -0.023891, -0.015694, 0.988008) bones/0/rotation = Quaternion(-0.151731, -0.023891, -0.015694, 0.988008)
bones/1/rotation = Quaternion(-0.454449, 0.00797132, -0.000911783, 0.890736) bones/1/rotation = Quaternion(-0.513811, 0.0510532, -0.00583962, 0.856363)
bones/2/rotation = Quaternion(0.597894, 0.051707, -0.697194, 0.392135) bones/2/rotation = Quaternion(0.597894, 0.051707, -0.697194, 0.392135)
bones/3/rotation = Quaternion(-0.26061, 0.0561613, -0.58606, 0.765155) bones/3/rotation = Quaternion(-0.179347, 0.0171244, -0.630019, 0.755392)
bones/3/scale = Vector3(1, 1, 1) bones/3/scale = Vector3(1, 1, 1)
bones/4/rotation = Quaternion(-0.185361, 0.0767715, -0.304188, 0.931245) bones/4/rotation = Quaternion(-0.185361, 0.0767715, -0.304188, 0.931245)
bones/4/scale = Vector3(1, 1, 1) bones/4/scale = Vector3(1, 1, 1)
@@ -93,10 +93,10 @@ bones/8/rotation = Quaternion(0.731112, 0.216438, -0.270013, 0.587982)
bones/9/rotation = Quaternion(-0.147272, -0.690287, -0.291994, 0.64541) bones/9/rotation = Quaternion(-0.147272, -0.690287, -0.291994, 0.64541)
bones/10/rotation = Quaternion(0.035527, -0.0722718, -0.344413, 0.935358) bones/10/rotation = Quaternion(0.035527, -0.0722718, -0.344413, 0.935358)
bones/10/scale = Vector3(1, 1, 1) bones/10/scale = Vector3(1, 1, 1)
bones/11/rotation = Quaternion(0.581957, -0.380086, 0.688875, 0.2057) bones/11/rotation = Quaternion(0.578724, -0.337804, 0.693925, 0.263507)
bones/12/rotation = Quaternion(-0.275331, -0.0633099, 0.577289, 0.766108) bones/12/rotation = Quaternion(-0.275331, -0.0633099, 0.577289, 0.766108)
bones/12/scale = Vector3(1, 1, 1) bones/12/scale = Vector3(1, 1, 1)
bones/13/rotation = Quaternion(0.0113916, 0.34672, 0.116915, 0.930584) bones/13/rotation = Quaternion(-0.0864303, 0.293427, 0.149054, 0.940326)
bones/13/scale = Vector3(1, 1, 1) bones/13/scale = Vector3(1, 1, 1)
bones/14/position = Vector3(-0.131012, 0.4206, 0.0209323) bones/14/position = Vector3(-0.131012, 0.4206, 0.0209323)
bones/14/rotation = Quaternion(0.311801, -0.156763, 0.515707, 0.782465) bones/14/rotation = Quaternion(0.311801, -0.156763, 0.515707, 0.782465)
@@ -109,7 +109,7 @@ bones/17/rotation = Quaternion(0.742166, -0.221688, 0.264848, 0.574369)
bones/18/rotation = Quaternion(-0.156224, 0.731565, 0.301322, 0.59128) bones/18/rotation = Quaternion(-0.156224, 0.731565, 0.301322, 0.59128)
bones/19/rotation = Quaternion(0.035527, 0.0722718, 0.344413, 0.935358) bones/19/rotation = Quaternion(0.035527, 0.0722718, 0.344413, 0.935358)
bones/19/scale = Vector3(1, 1, 1) bones/19/scale = Vector3(1, 1, 1)
bones/20/rotation = Quaternion(0.001122, 0.716261, 0.697819, -0.00424113) bones/20/rotation = Quaternion(0.00718503, 0.763404, 0.64531, -0.0271591)
[node name="AnimationTree" type="AnimationTree" parent="soldier"] [node name="AnimationTree" type="AnimationTree" parent="soldier"]
tree_root = ExtResource("5_c6ikb") tree_root = ExtResource("5_c6ikb")

View File

@@ -43,3 +43,23 @@ func _on_target_reached() -> void:
capacity = 0 capacity = 0
target = source_target target = source_target
go_to(target.global_position) go_to(target.global_position)
func _on_area_3d_area_entered(area: Area3D) -> void:
if area.get_parent() is CollectableResource:
var resource := area.get_parent() as CollectableResource
capacity = resource.collect(5)
target = PlayerCamp.instance
go_to(target.global_position)
elif area.get_parent() is PlayerCamp:
var camp := area.get_parent() as PlayerCamp
match source_target.type:
CollectableResource.ResourceType.FOOD:
camp.food_capacity += capacity
CollectableResource.ResourceType.WOOD:
camp.wood_capacity += capacity
CollectableResource.ResourceType.STONE:
camp.stone_capacity += capacity
capacity = 0
target = source_target
go_to(target.global_position)

View File

@@ -1,4 +1,4 @@
[gd_scene load_steps=23 format=4 uid="uid://cbc61u4p4mn05"] [gd_scene load_steps=24 format=4 uid="uid://cbc61u4p4mn05"]
[ext_resource type="Script" path="res://entities/ants/worker_ant.gd" id="1_hmrg3"] [ext_resource type="Script" path="res://entities/ants/worker_ant.gd" id="1_hmrg3"]
[ext_resource type="PackedScene" uid="uid://v2kcdfr5npqb" path="res://assets/fbx/base_ant.fbx" id="2_b8awe"] [ext_resource type="PackedScene" uid="uid://v2kcdfr5npqb" path="res://assets/fbx/base_ant.fbx" id="2_b8awe"]
@@ -123,6 +123,9 @@ fill_to = Vector2(1, 1)
[sub_resource type="StyleBoxTexture" id="StyleBoxTexture_uj2kw"] [sub_resource type="StyleBoxTexture" id="StyleBoxTexture_uj2kw"]
texture = SubResource("GradientTexture2D_upbt3") texture = SubResource("GradientTexture2D_upbt3")
[sub_resource type="BoxShape3D" id="BoxShape3D_6s5hc"]
size = Vector3(3, 3, 3)
[node name="WorkerAnt" type="CharacterBody3D"] [node name="WorkerAnt" type="CharacterBody3D"]
axis_lock_angular_x = true axis_lock_angular_x = true
axis_lock_angular_z = true axis_lock_angular_z = true
@@ -136,7 +139,7 @@ shape = SubResource("CapsuleShape3D_bqyr6")
[node name="Skeleton3D" parent="base_ant/BaseAnt" index="0"] [node name="Skeleton3D" parent="base_ant/BaseAnt" index="0"]
bones/0/rotation = Quaternion(9.9051e-05, -8.31996e-29, 6.6946e-17, 1) bones/0/rotation = Quaternion(9.9051e-05, -8.31996e-29, 6.6946e-17, 1)
bones/1/rotation = Quaternion(0.0811275, 0.000963642, -0.206745, 0.975025) bones/1/rotation = Quaternion(0.0536049, -3.59708e-18, -7.87621e-17, 0.998562)
bones/3/rotation = Quaternion(0.541099, 0.16567, -0.351117, 0.745978) bones/3/rotation = Quaternion(0.541099, 0.16567, -0.351117, 0.745978)
bones/4/rotation = Quaternion(-0.275331, 0.0633099, -0.577289, 0.766108) bones/4/rotation = Quaternion(-0.275331, 0.0633099, -0.577289, 0.766108)
bones/7/rotation = Quaternion(0.674429, 0.240017, -0.247256, 0.652994) bones/7/rotation = Quaternion(0.674429, 0.240017, -0.247256, 0.652994)
@@ -152,7 +155,7 @@ bones/24/rotation = Quaternion(0.0469251, 0.0954517, 0.66037, 0.74337)
bones/27/rotation = Quaternion(0, 0, 1, 0) bones/27/rotation = Quaternion(0, 0, 1, 0)
[node name="BoneAttachment3D" type="BoneAttachment3D" parent="base_ant/BaseAnt/Skeleton3D" index="0"] [node name="BoneAttachment3D" type="BoneAttachment3D" parent="base_ant/BaseAnt/Skeleton3D" index="0"]
transform = Transform3D(0.914511, 0.40332, -0.0316663, -0.403001, 0.901318, -0.158797, -0.0355045, 0.157983, 0.986803, 1.16994e-19, 0.00431615, 0.00552689) transform = Transform3D(1, 2.3791e-17, -1.2808e-18, -2.37911e-17, 0.994232, -0.107253, -1.27823e-18, 0.107253, 0.994232, 1.16994e-19, 0.00431615, 0.00552689)
bone_name = "Head" bone_name = "Head"
bone_idx = 1 bone_idx = 1
@@ -189,7 +192,7 @@ anim_player = NodePath("../AnimationPlayer")
parameters/blend_position = 0.0 parameters/blend_position = 0.0
[node name="NavigationAgent3D" type="NavigationAgent3D" parent="."] [node name="NavigationAgent3D" type="NavigationAgent3D" parent="."]
target_desired_distance = 2.0 target_desired_distance = 3.0
avoidance_enabled = true avoidance_enabled = true
debug_path_custom_color = Color(0.3, 0.381667, 1, 1) debug_path_custom_color = Color(0.3, 0.381667, 1, 1)
@@ -224,9 +227,17 @@ texture = ExtResource("6_l4m2r")
[node name="Node3D" parent="." instance=ExtResource("8_th62q")] [node name="Node3D" parent="." instance=ExtResource("8_th62q")]
[node name="Area3D" type="Area3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.672495, -2.70862)
monitorable = false
[node name="CollisionShape3D" type="CollisionShape3D" parent="Area3D"]
shape = SubResource("BoxShape3D_6s5hc")
[connection signal="mouse_entered" from="." to="base_ant/BaseAnt/Skeleton3D/Head2" method="_on_mouse_entered"] [connection signal="mouse_entered" from="." to="base_ant/BaseAnt/Skeleton3D/Head2" method="_on_mouse_entered"]
[connection signal="mouse_exited" from="." to="base_ant/BaseAnt/Skeleton3D/Head2" method="_on_mouse_exited"] [connection signal="mouse_exited" from="." to="base_ant/BaseAnt/Skeleton3D/Head2" method="_on_mouse_exited"]
[connection signal="navigation_finished" from="NavigationAgent3D" to="." method="_on_target_reached"] [connection signal="navigation_finished" from="NavigationAgent3D" to="." method="_on_target_reached"]
[connection signal="velocity_computed" from="NavigationAgent3D" to="." method="_on_velocity_computed"] [connection signal="velocity_computed" from="NavigationAgent3D" to="." method="_on_velocity_computed"]
[connection signal="area_entered" from="Area3D" to="." method="_on_area_3d_area_entered"]
[editable path="base_ant"] [editable path="base_ant"]

View File

@@ -3,8 +3,8 @@ class_name PlayerCamp extends Building
static var instance:PlayerCamp static var instance:PlayerCamp
var food_capacity:=100 var food_capacity:=100
var wood_capacity:=100 var wood_capacity:=40
var stone_capacity:=100 var stone_capacity:=40
var active_indicator:Indicator var active_indicator:Indicator
@@ -24,7 +24,7 @@ func on_interact(object:CollisionObject3D, point:Vector3)->void:
buy_ant(40, point, soldier_scene) buy_ant(40, point, soldier_scene)
if active_indicator.type == Indicator.IndicatorType.BUILDING_BALISTA: if active_indicator.type == Indicator.IndicatorType.BUILDING_BALISTA:
var ballista_scene := load("res://entities/buildings/ballista.tscn") as PackedScene var ballista_scene := load("res://entities/buildings/ballista.tscn") as PackedScene
buy_building(40, 40, point, ballista_scene) buy_building(20, 20, point, ballista_scene)
func _on_worker_pressed() -> void: func _on_worker_pressed() -> void:
if active_indicator != null: active_indicator.queue_free() if active_indicator != null: active_indicator.queue_free()

View File

@@ -54,7 +54,7 @@ script/source = "extends Panel
func _process(delta: float) -> void: func _process(delta: float) -> void:
$HBoxContainer/Worker/Worker.disabled = PlayerCamp.instance.food_capacity < 20 $HBoxContainer/Worker/Worker.disabled = PlayerCamp.instance.food_capacity < 20
$HBoxContainer/Soldier/Soldier.disabled = PlayerCamp.instance.food_capacity < 40 $HBoxContainer/Soldier/Soldier.disabled = PlayerCamp.instance.food_capacity < 40
$HBoxContainer/Balista/AspectRatioContainer/balista.disabled = PlayerCamp.instance.stone_capacity < 40 or PlayerCamp.instance.wood_capacity < 40 $HBoxContainer/Balista/AspectRatioContainer/balista.disabled = PlayerCamp.instance.stone_capacity < 20 or PlayerCamp.instance.wood_capacity < 20
" "
[sub_resource type="StyleBoxTexture" id="StyleBoxTexture_hx5fy"] [sub_resource type="StyleBoxTexture" id="StyleBoxTexture_hx5fy"]
@@ -261,7 +261,7 @@ expand_mode = 2
[node name="Label" type="Label" parent="RecruitOptions/HBoxContainer/Balista/HBoxContainer"] [node name="Label" type="Label" parent="RecruitOptions/HBoxContainer/Balista/HBoxContainer"]
layout_mode = 2 layout_mode = 2
text = "40" text = "20"
horizontal_alignment = 1 horizontal_alignment = 1
[node name="Healthbar" parent="." instance=ExtResource("13_0oymu")] [node name="Healthbar" parent="." instance=ExtResource("13_0oymu")]

View File

@@ -16,4 +16,4 @@ func collect(amount:int)->int:
func _on_tick() -> void: func _on_tick() -> void:
if capacity < 100: return if capacity < 100: return
capacity += 1 capacity += 10

View File

@@ -34,6 +34,13 @@ layers = 2
billboard = 1 billboard = 1
texture = ExtResource("4_w3ttc") texture = ExtResource("4_w3ttc")
[node name="Area3D" type="Area3D" parent="."]
monitoring = false
[node name="CollisionShape3D2" type="CollisionShape3D" parent="Area3D"]
transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0, 0.442429, 0)
shape = SubResource("SphereShape3D_g8vog")
[connection signal="mouse_entered" from="." to="food/Food" method="_on_mouse_entered"] [connection signal="mouse_entered" from="." to="food/Food" method="_on_mouse_entered"]
[connection signal="mouse_exited" from="." to="food/Food" method="_on_mouse_exited"] [connection signal="mouse_exited" from="." to="food/Food" method="_on_mouse_exited"]
[connection signal="timeout" from="Timer" to="." method="_on_tick"] [connection signal="timeout" from="Timer" to="." method="_on_tick"]

View File

@@ -1,4 +1,4 @@
[gd_scene load_steps=5 format=3 uid="uid://kslywe6neejo"] [gd_scene load_steps=6 format=3 uid="uid://kslywe6neejo"]
[ext_resource type="Script" path="res://entities/resources/collectable_resource.gd" id="1_ybx4f"] [ext_resource type="Script" path="res://entities/resources/collectable_resource.gd" id="1_ybx4f"]
[ext_resource type="PackedScene" uid="uid://rheyik3n6qia" path="res://assets/fbx/rock.fbx" id="2_uwrg3"] [ext_resource type="PackedScene" uid="uid://rheyik3n6qia" path="res://assets/fbx/rock.fbx" id="2_uwrg3"]
@@ -7,6 +7,9 @@
[sub_resource type="SphereShape3D" id="SphereShape3D_2ifhi"] [sub_resource type="SphereShape3D" id="SphereShape3D_2ifhi"]
radius = 1.9217 radius = 1.9217
[sub_resource type="SphereShape3D" id="SphereShape3D_gjw2c"]
radius = 2.0
[node name="StoneResource" type="StaticBody3D" groups=["NavmeshTargets"]] [node name="StoneResource" type="StaticBody3D" groups=["NavmeshTargets"]]
script = ExtResource("1_ybx4f") script = ExtResource("1_ybx4f")
type = 1 type = 1
@@ -27,6 +30,13 @@ layers = 2
billboard = 1 billboard = 1
texture = ExtResource("3_uq1d7") texture = ExtResource("3_uq1d7")
[node name="Area3D" type="Area3D" parent="."]
monitoring = false
[node name="CollisionShape3D2" type="CollisionShape3D" parent="Area3D"]
transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0, 0.442429, 0)
shape = SubResource("SphereShape3D_gjw2c")
[connection signal="timeout" from="Timer" to="." method="_on_tick"] [connection signal="timeout" from="Timer" to="." method="_on_tick"]
[editable path="rock"] [editable path="rock"]

View File

@@ -1,4 +1,4 @@
[gd_scene load_steps=6 format=3 uid="uid://kh5xmgawk26n"] [gd_scene load_steps=7 format=3 uid="uid://kh5xmgawk26n"]
[ext_resource type="Script" path="res://entities/resources/collectable_resource.gd" id="1_khlta"] [ext_resource type="Script" path="res://entities/resources/collectable_resource.gd" id="1_khlta"]
[ext_resource type="PackedScene" uid="uid://87uikru2r8pc" path="res://assets/fbx/plant.fbx" id="2_u6krj"] [ext_resource type="PackedScene" uid="uid://87uikru2r8pc" path="res://assets/fbx/plant.fbx" id="2_u6krj"]
@@ -10,6 +10,9 @@ radius = 2.49866
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_do68j"] [sub_resource type="StandardMaterial3D" id="StandardMaterial3D_do68j"]
albedo_color = Color(0.53, 0.366053, 0.1908, 1) albedo_color = Color(0.53, 0.366053, 0.1908, 1)
[sub_resource type="SphereShape3D" id="SphereShape3D_gc3ak"]
radius = 2.0
[node name="WoodResource" type="StaticBody3D" groups=["NavmeshTargets"]] [node name="WoodResource" type="StaticBody3D" groups=["NavmeshTargets"]]
script = ExtResource("1_khlta") script = ExtResource("1_khlta")
type = 2 type = 2
@@ -34,6 +37,13 @@ layers = 2
billboard = 1 billboard = 1
texture = ExtResource("3_i5i26") texture = ExtResource("3_i5i26")
[node name="Area3D" type="Area3D" parent="."]
monitoring = false
[node name="CollisionShape3D2" type="CollisionShape3D" parent="Area3D"]
transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0, 0.442429, 0)
shape = SubResource("SphereShape3D_gc3ak")
[connection signal="timeout" from="Timer" to="." method="_on_tick"] [connection signal="timeout" from="Timer" to="." method="_on_tick"]
[editable path="plant"] [editable path="plant"]