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-03 22:24:08 +02:00
var pc_occupied = [ 0 , 0 , 0 ]
2024-08-02 00:55:56 +02:00
var pc_body = [ 0 , 0 , 0 ]
func _ready ( ) :
Game . computers += 1
func _on_computer_tick_timeout ( ) :
2024-08-04 13:41:19 +02:00
if Server . is_server :
2024-08-02 22:30:30 +02:00
current += ( pc_occupied [ 0 ] + pc_occupied [ 1 ] + pc_occupied [ 2 ] )
Server . sync_computers . rpc ( name , 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-05 22:35:50 +02:00
if pc_occupied [ 0 ] == 0 and body is CharacterBody3D and ! body . beast :
2024-08-02 00:55:56 +02:00
pc_occupied [ 0 ] = 1
pc_body [ 0 ] = body
func _on_pc_2_area_body_entered ( body ) :
2024-08-05 22:35:50 +02:00
if pc_occupied [ 1 ] == 0 and body is CharacterBody3D and ! body . beast :
2024-08-02 00:55:56 +02:00
pc_occupied [ 1 ] = 1
pc_body [ 1 ] = body
func _on_pc_3_area_body_entered ( body ) :
2024-08-05 22:35:50 +02:00
if pc_occupied [ 2 ] == 0 and body is CharacterBody3D and ! body . beast :
2024-08-02 00:55:56 +02:00
pc_occupied [ 2 ] = 1
pc_body [ 2 ] = body
func _on_pc_1_area_body_exited ( body ) :
2024-08-05 22:35:50 +02:00
if pc_occupied [ 0 ] == 1 and body is CharacterBody3D and body == pc_body [ 0 ] :
2024-08-02 00:55:56 +02:00
pc_occupied [ 0 ] = 0
pc_body [ 0 ] = 0
func _on_pc_2_area_body_exited ( body ) :
2024-08-05 22:35:50 +02:00
if pc_occupied [ 1 ] == 1 and body is CharacterBody3D and body == pc_body [ 1 ] :
2024-08-02 00:55:56 +02:00
pc_occupied [ 1 ] = 0
pc_body [ 1 ] = 0
func _on_pc_3_area_body_exited ( body ) :
2024-08-05 22:35:50 +02:00
if pc_occupied [ 2 ] == 1 and body is CharacterBody3D and body == pc_body [ 2 ] :
2024-08-02 00:55:56 +02:00
pc_occupied [ 2 ] = 0
pc_body [ 2 ] = 0