2024-08-05 22:35:50 +02:00
## freeftf
## Copyright (C) 2024 Patrick_Pluto
2024-08-02 22:38:08 +02:00
##
2024-08-05 22:35:50 +02:00
## This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
2024-08-02 22:38:08 +02:00
##
2024-08-05 22:35:50 +02:00
## This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
2024-08-02 22:38:08 +02:00
##
2024-08-05 22:35:50 +02:00
## You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
2024-08-02 22:38:08 +02:00
2024-08-02 00:55:56 +02:00
extends StaticBody3D
const TARGET = 100
var current = 0
2024-08-13 20:43:54 +02:00
var pc_occupied = 0
2024-08-02 00:55:56 +02:00
2024-08-13 20:43:54 +02:00
var pc_body = [ ]
2024-08-02 00:55:56 +02:00
func _ready ( ) :
Game . computers += 1
func _on_computer_tick_timeout ( ) :
2024-08-08 21:49:24 +02:00
if Game . is_server :
2024-08-13 20:43:54 +02:00
current += pc_occupied
2024-08-08 21:49:24 +02:00
for id in Game . player_list :
2024-08-13 22:12:37 +02:00
Client . rpc_id ( id , " sync_computers " , get_path ( ) , current )
2024-08-02 00:55:56 +02:00
if current > = TARGET :
current = " Complete "
$ computer_tick . stop ( )
Game . computers -= 1
$ pc_1 / Label3D . text = str ( current )
$ pc_2 / Label3D . text = str ( current )
$ pc_3 / Label3D . text = str ( current )
func _on_pc_1_area_body_entered ( body ) :
2024-08-13 20:43:54 +02:00
if pc_occupied < 3 and body is CharacterBody3D and ! body . beast and body not in pc_body :
pc_occupied += 1
pc_body . append ( body )
2024-08-02 00:55:56 +02:00
func _on_pc_1_area_body_exited ( body ) :
2024-08-13 20:43:54 +02:00
if pc_occupied < 3 and body is CharacterBody3D and body in pc_body :
pc_occupied -= 1
pc_body . erase ( body )