This commit is contained in:
Tandy 2026-09-27 14:51:21 -06:00
commit fe8ae84ce1
11 changed files with 99 additions and 32 deletions

View file

@ -40,6 +40,11 @@ func _unhandled_input(event: InputEvent):
zoom.y = 1
else:
zoom.y -= 1
if UserContext.modal_command is MoveCommand and event.button_index == MOUSE_BUTTON_LEFT and UserContext.selected_member != null:
var loc = get_global_mouse_position()
var node := Node2D.new()
node.name = "targetNode"
node.top_level = true
node.position = loc
self.add_child(node)
UserContext.select_point(node)

View file

@ -6,13 +6,14 @@
[ext_resource type="Resource" uid="uid://dfbgxc6nlcjct" path="res://allegiance/bad.tres" id="4_sitmf"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_riqys"]
size = Vector2(98, 100)
size = Vector2(99, 97.67441)
[node name="CharacterBody2D" type="CharacterBody2D" unique_id=1581641385]
scale = Vector2(0.215, 0.215)
script = ExtResource("1_xfhet")
[node name="CollisionShape2D" type="CollisionShape2D" parent="." unique_id=1841709482]
position = Vector2(50, 49)
position = Vector2(50.500004, 48.837223)
shape = SubResource("RectangleShape2D_riqys")
[node name="MemberSprite" parent="." unique_id=283117283 instance=ExtResource("2_v0at3")]

View file

@ -22,3 +22,6 @@ func _on_mouse_exited() -> void:
func _input(event: InputEvent) -> void:
if event is InputEventMouseButton and event.pressed and event.button_index == MOUSE_BUTTON_LEFT:
UserContext.select_focused_member()
func get_allegiance():
return allegiance.kingdom_name

View file

@ -3,6 +3,7 @@ extends Node
signal productions_update(p: Array[Production])
@warning_ignore("unused_signal")
signal production_log(producer: Currency, p: Production)
signal log(s: String)
@export var currencies: Array[Production]
@export var members: Array
@ -78,12 +79,15 @@ func simulate():
update_currencies()
for e in events:
if e.requirements_satisfied() and e.will_happen():
if e.log_message != "" and not e.skip_log:
Economy.log.emit(e.log_message)
var outcome := e.outcome()
for o in outcome:
if o == null:
continue
produce(o)
production_log.emit(null, o)
if e.log_message == "" and not e.skip_log:
production_log.emit(null, o)
if e.timeline != null:
GameState.add_letter.emit(e.into_letter())
if randf() < 0.01:

View file

@ -16,6 +16,7 @@ enum EventNature {
@export var nature: EventNature = EventNature.Random
@export var email_source: Currency = preload("res://currency/sentient/town_crier.tres")
@export var email_subject: String = "Something is amok!"
@export var log_message: String = ""
func requirements_satisfied() -> bool:
for requirement in requirements:

View file

@ -5,6 +5,19 @@ extends VBoxContainer
func _ready() -> void:
Economy.production_log.connect(append)
Economy.log.connect(log)
func log(s: String):
var display := preload("res://gui/production_log.tscn").instantiate()
display.set_color(new_message_color)
for child in get_children():
if child is ProductionLog and child.is_old:
child.set_color(old_message_color)
display.generic = true
display.generic_text = s
add_child(display)
move_child(display, 0)
func append(producer: Currency, production: Production):
var display := preload("res://gui/production_log.tscn").instantiate()

View file

@ -3,27 +3,38 @@ class_name ProductionLog
@export var producer: Currency = null
@export var production: Production
@export var generic: bool = false
@export var generic_text: String = "<No message>"
var is_old: bool = false
func _ready() -> void:
if producer != null:
%producer.text = producer.name
%Production.visible = true
if generic:
%GenericMessage.visible = true
%GenericMessage.text = generic_text
%Production.visible = false
%Production2.visible = false
else:
%Production.visible = false
%Production2.visible = true
%amount.text = str(abs(production.amount))
%amount2.text = str(abs(production.amount))
if production.amount > 0:
%type.text = "produced "
%producer2.text = "You gained "
else:
%type.text = "consumed "
%producer2.text = "You lost "
%production.text = production.currency.name
%production2.text = production.currency.name
if producer != null:
%producer.text = producer.name
%GenericMessage.visible = false
%Production.visible = true
%Production2.visible = false
else:
%GenericMessage.visible = false
%Production.visible = false
%Production2.visible = true
%amount.text = str(abs(production.amount))
%amount2.text = str(abs(production.amount))
if production.amount > 0:
%type.text = "produced "
%producer2.text = "You gained "
else:
%type.text = "consumed "
%producer2.text = "You lost "
if production != null:
%production.text = production.currency.name
%production2.text = production.currency.name
make_old.call_deferred()
func make_old():

View file

@ -5,6 +5,10 @@
[node name="ProductionLog" type="MarginContainer" unique_id=253822540]
script = ExtResource("1_ei3g1")
[node name="GenericMessage" type="Label" parent="." unique_id=712313778]
unique_name_in_owner = true
layout_mode = 2
[node name="Production" type="HBoxContainer" parent="." unique_id=1073672077]
unique_name_in_owner = true
layout_mode = 2

View file

@ -170,14 +170,14 @@ currency = ExtResource("4_gqbix")
allegiance = ExtResource("5_71pa8")
[node name="CharacterBody2D2" parent="." unique_id=559452664 instance=ExtResource("3_e0an3")]
position = Vector2(628, 935)
position = Vector2(854, 34)
[node name="MemberSprite" parent="CharacterBody2D2" index="1" unique_id=283117283]
currency = ExtResource("4_iw27f")
allegiance = ExtResource("5_71pa8")
[node name="CharacterBody2D3" parent="." unique_id=1323337635 instance=ExtResource("3_e0an3")]
position = Vector2(1129, 814)
position = Vector2(905, 42)
[node name="MemberSprite" parent="CharacterBody2D3" index="1" unique_id=283117283]
allegiance = ExtResource("5_71pa8")
@ -242,13 +242,13 @@ position = Vector2(368, -1353)
currency = ExtResource("6_05x41")
[node name="CharacterBody2D12" parent="." unique_id=2114526449 instance=ExtResource("3_e0an3")]
position = Vector2(388, -1138)
position = Vector2(853, -17.999998)
[node name="MemberSprite" parent="CharacterBody2D12" index="1" unique_id=283117283]
currency = ExtResource("8_oysan")
[node name="CharacterBody2D13" parent="." unique_id=799583982 instance=ExtResource("3_e0an3")]
position = Vector2(679, -1035)
position = Vector2(905.99994, -11.999985)
[node name="MemberSprite" parent="CharacterBody2D13" index="1" unique_id=283117283]
currency = ExtResource("4_iw27f")

View file

@ -1,11 +1,12 @@
extends CharacterBody2D
const SPEED = 100.0
const SPEED = 700.0
const JUMP_VELOCITY = -400.0
@export var target : Node2D
func _ready() -> void:
UserContext. set_target_for . connect(set_target_for)
func set_target_for(who: CurrencyMemberSprite, t: Node2D):
@ -19,6 +20,18 @@ func set_target_for(who: CurrencyMemberSprite, t: Node2D):
func removed_target():
target = null
func combat(target):
var winner = randf_range(0,2)
print(winner)
if winner <= 1:
target.queue_free()
else:
var p := Production.new()
p.amount = -1
p.currency = %MemberSprite.currency
Economy.produce(p)
self.queue_free()
#func _Direction() -> Vector2:
#self.position = self.position.move_toward(target.transform.position, speed * delta)
@ -30,12 +43,19 @@ func _physics_process(delta: float) -> void:
#print(num)
var direction = (target.global_position - self.global_position).normalized() * SPEED * delta
#if (num > Vector2(2,2)):
if (self.global_position.distance_to(target.global_position) > 0.2):
if (self.global_position.distance_to(target.global_position) > 25):
self.velocity = direction
#self.global_position = self.global_position.move_toward(target.global_position, SPEED * delta)
elif (target.is_class("SentientCurrency")):
pass
elif (target.is_class("CharacterBody2D")):
print("is SentientCurrency")
print(target.name)
print(target.get_node("MemberSprite").get_allegiance())
if (target.get_node("MemberSprite").get_allegiance() != get_node("MemberSprite").get_allegiance() ):
#print("different Allegience: "+ target.get_node("CurrencyMemberSprite").alligence)
combat(target)
removed_target()
else:
pass
print("Removed Target")
removed_target()
#target = null
move_and_slide()

View file

@ -60,6 +60,11 @@ func select_focused_member():
selected_member_change.emit(selected_member)
UserContext.member_inspect.emit(selected_member)
func select_point(node : Node2D):
if modal_command is MoveCommand:
set_target_for.emit(selected_member, node)
func unselect_member():
if selected_member == null:
return