Import current DEMON v0.19 source, assets and development handoff
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
extends RefCounted
|
||||
const TIMEOUT=10.0
|
||||
const FINE=50
|
||||
const EXIT=Vector3(-5.3,0,7.8)
|
||||
var w
|
||||
var g
|
||||
var head=-1
|
||||
var waiting_time=0.0
|
||||
var departures=[]
|
||||
func setup(workshop):w=workshop;g=w.g
|
||||
func reset():
|
||||
for record in departures:
|
||||
if is_instance_valid(record.node):record.node.queue_free()
|
||||
departures.clear();head=-1;waiting_time=0
|
||||
func fine(at):
|
||||
var amount=mini(FINE,g.coins);g.coins-=amount;w.penalty_gold_lost+=amount
|
||||
g.floating("−50 МОНЕТ",at+Vector3(0,2.7,0),Color("ef9b85"));w.refresh();g.save_progress()
|
||||
func cancel_helpers(s):
|
||||
for hi in range(w.helpers.size()):
|
||||
var h=w.helpers[hi]
|
||||
if h.soul!=s.id and not (s.state=="mounted" and h.state=="operate" and h.station==s.get("assigned",-2)):continue
|
||||
if h.station>=0 and h.station<w.stations.size() and w.stations[h.station].reserved==hi:w.stations[h.station].reserved=-1
|
||||
h.state="idle";h.soul=-1;h.station=-1;h.path=PackedVector2Array();h.revision=-1;h.model.set_walking(false)
|
||||
func remove_soul(s):
|
||||
cancel_helpers(s)
|
||||
if s.has("task_badge"):s.task_badge.hide()
|
||||
if g.held==s.id:g.held=-1
|
||||
g.souls.erase(s)
|
||||
func station_timeout(d):
|
||||
var index=g.index_of(d.soul)
|
||||
if index<0:return
|
||||
var s=g.souls[index];remove_soul(s);g.life.burn(s)
|
||||
d.soul=-1;d.reserved=-1;d.operator=-1;d.ready=false;d.elapsed=0;d.stage=0;d.hits=0;d.placement=0;d.idle_time=0;d.cooldown=2.1;d.release_clock=2.05;d.bar.hide()
|
||||
if d.flame:d.flame.hide()
|
||||
w.EXTRA.animate(g,d,0,false);fine(d.device.position)
|
||||
func queue_step(dt):
|
||||
var queue=w.waiting().filter(func(s):return not s.entering)
|
||||
if queue.is_empty():head=-1;waiting_time=0;return
|
||||
var s=queue[0]
|
||||
if head!=s.id:head=s.id;waiting_time=0
|
||||
waiting_time+=dt
|
||||
if waiting_time+0.00001>=TIMEOUT:
|
||||
remove_soul(s);s.state="departing";s.visual.unmount_station();s.visual.position.y=.55
|
||||
departures.append({"node":s.node,"visual":s.visual});fine(s.node.position);head=-1;waiting_time=0
|
||||
func update_departures(dt):
|
||||
for i in range(departures.size()-1,-1,-1):
|
||||
var d=departures[i];d.node.position=d.node.position.move_toward(EXIT,dt*3.7)
|
||||
if d.node.position.distance_to(EXIT)<.08:d.node.queue_free();departures.remove_at(i)
|
||||
Reference in New Issue
Block a user