refactor party

This commit is contained in:
2026-08-12 13:31:11 +02:00
parent 81d7a213cd
commit 51da5c97eb
29 changed files with 274 additions and 67 deletions

87
Ceo.cs Normal file
View File

@@ -0,0 +1,87 @@
using Godot;
namespace Game;
[GlobalClass]
public partial class Ceo : Resource
{
private float _competence = 50;
private float _energy = 100;
private float _insanity;
private float _maxEnergy = 100;
private string _name = "";
[Export]
public string Name
{
get => _name;
set
{
_name = value;
EmitCeoStatusChanged();
}
}
[Export]
public float Energy
{
get => _energy;
set
{
_energy = Mathf.Clamp(value, 0, MaxEnergy);
EmitCeoStatusChanged();
}
}
[Export]
public float MaxEnergy
{
get => _maxEnergy;
set
{
_maxEnergy = Mathf.Max(value, 0);
_energy = Mathf.Min(_energy, _maxEnergy);
EmitCeoStatusChanged();
}
}
[Export]
public float Insanity
{
get => _insanity;
set
{
_insanity = value;
EmitCeoStatusChanged();
}
}
[Export]
public float Competence
{
get => _competence;
set
{
_competence = value;
EmitCeoStatusChanged();
}
}
private void EmitCeoStatusChanged()
{
EventBus.CeoChanged.Invoke(ToCeoStats());
}
public CeoStats ToCeoStats()
{
return new CeoStats(Name, Energy, MaxEnergy, Insanity, Competence);
}
public record CeoStats(
string Name,
float Energy,
float MaxEnergy,
float Insanity,
float Competence
);
}

19
CeoStatsContainer.cs Normal file
View File

@@ -0,0 +1,19 @@
using Godot;
namespace Game;
[SceneTree]
public partial class CeoStatsContainer : FoldableContainer
{
public override void _Ready()
{
EventBus.CeoChanged += UpdateCeoStats;
}
private void UpdateCeoStats(Ceo.CeoStats stats)
{
EnergyValue.Text = stats.Energy.ToString();
InsanityValue.Text = stats.Insanity.ToString();
CompetenceValue.Text = stats.Competence.ToString();
}
}

1
CeoStatsContainer.cs.uid Normal file
View File

@@ -0,0 +1 @@
uid://b3s8fcft34m3f

56
CeoStatsContainer.tscn Normal file
View File

@@ -0,0 +1,56 @@
[gd_scene format=3 uid="uid://bf2e8stflktgv"]
[ext_resource type="Script" uid="uid://b3s8fcft34m3f" path="res://CeoStatsContainer.cs" id="1_0krmq"]
[node name="CeoStatsContainer" type="FoldableContainer" unique_id=317328071]
anchors_preset = 1
anchor_left = 1.0
anchor_right = 1.0
offset_left = -249.53503
offset_bottom = 116.0
grow_horizontal = 0
title = "CEO"
title_alignment = 1
script = ExtResource("1_0krmq")
[node name="VBoxContainer" type="VBoxContainer" parent="." unique_id=832183396]
layout_mode = 2
[node name="HBoxContainer4" type="HBoxContainer" parent="VBoxContainer" unique_id=1164364814]
layout_mode = 2
[node name="Label" type="Label" parent="VBoxContainer/HBoxContainer4" unique_id=2113984350]
layout_mode = 2
size_flags_horizontal = 3
text = "Energy"
[node name="EnergyValue" type="Label" parent="VBoxContainer/HBoxContainer4" unique_id=1672825837]
unique_name_in_owner = true
layout_mode = 2
text = "3 / 10"
[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer" unique_id=1721269664]
layout_mode = 2
[node name="Label" type="Label" parent="VBoxContainer/HBoxContainer" unique_id=894714403]
layout_mode = 2
size_flags_horizontal = 3
text = "Insanity"
[node name="InsanityValue" type="Label" parent="VBoxContainer/HBoxContainer" unique_id=1054913799]
unique_name_in_owner = true
layout_mode = 2
text = "Low"
[node name="HBoxContainer2" type="HBoxContainer" parent="VBoxContainer" unique_id=1217186337]
layout_mode = 2
[node name="Label" type="Label" parent="VBoxContainer/HBoxContainer2" unique_id=52458700]
layout_mode = 2
size_flags_horizontal = 3
text = "Competence"
[node name="CompetenceValue" type="Label" parent="VBoxContainer/HBoxContainer2" unique_id=2047724511]
unique_name_in_owner = true
layout_mode = 2
text = "Low"

View File

@@ -1,5 +1,6 @@
using Godot;
using yourareanaiceo;
namespace Game;
[GlobalClass]
public partial class Company : Resource

View File

@@ -1,6 +1,7 @@
using System.Globalization;
using Godot;
using yourareanaiceo;
namespace Game;
[SceneTree]
public partial class CompanyStatsContainer : FoldableContainer

View File

@@ -6,8 +6,7 @@
anchors_preset = 1
anchor_left = 1.0
anchor_right = 1.0
offset_left = -245.0
offset_right = 4.535034
offset_left = -249.53503
offset_bottom = 149.0
grow_horizontal = 0
title = "Your Company Inc."

View File

@@ -1,5 +1,7 @@
using Game.Extensions;
using Godot;
using yourareanaiceo;
namespace Game;
public partial class CurrentTimeLine : Panel
{
@@ -14,7 +16,7 @@ public partial class CurrentTimeLine : Panel
return;
var pos = OffsetTransformPosition;
pos.Y += Speed * delta.toFloat();
pos.Y += Speed * DoubleExtensions.toFloat(delta);
OffsetTransformPosition = pos;
}

View File

@@ -2,6 +2,8 @@ using System.Collections.Generic;
using System.Linq;
using Godot;
namespace Game;
[SceneTree]
public partial class DaySchedule : PanelContainer
{
@@ -52,6 +54,8 @@ public partial class DaySchedule : PanelContainer
GetTimeSlots().First().StartMeeting();
_currentSlot += 1;
EventBus.DayStarted?.Invoke();
}
public void EndDay()

View File

@@ -1,5 +1,7 @@
using Game.Extensions;
using Godot;
using yourareanaiceo;
namespace Game;
public partial class DropZone : Control
{
@@ -14,7 +16,7 @@ public partial class DropZone : Control
var meetingControl = ((MeetingControlDragData)data).MeetingControl;
var meetingPhysicsBox = meetingControl.MeetingPhysicsBox;
var game = this.GetGame();
var game = NodeExtensions.GetMain(this);
game.AddChild(meetingPhysicsBox);
meetingPhysicsBox.Position = GetGlobalMousePosition();
meetingControl.QueueFree();

View File

@@ -1,8 +1,12 @@
using System;
namespace yourareanaiceo;
namespace Game;
public static class EventBus
{
public static Action<Company.CompanyStats> CompanyChanged;
public static Action<Ceo.CeoStats> CeoChanged;
public static Action DayStarted;
}

View File

@@ -1,4 +1,4 @@
namespace yourareanaiceo;
namespace Game.Extensions;
public static class DoubleExtensions
{

View File

@@ -1,11 +1,11 @@
using Godot;
namespace yourareanaiceo;
namespace Game.Extensions;
public static class NodeExtensions
{
public static Game GetGame(this Node node)
public static Main GetMain(this Node node)
{
return node.GetTree().CurrentScene as Game;
return node.GetTree().CurrentScene as Main;
}
}

View File

@@ -1,6 +1,8 @@
namespace yourareanaiceo;
namespace Game;
public class GameState
{
public Company Company { get; set; } = new();
public Ceo Ceo { get; set; } = new();
}

View File

@@ -1,8 +1,9 @@
using Godot;
using yourareanaiceo;
namespace Game;
[SceneTree]
public partial class Game : Node2D
public partial class Main : Node2D
{
public GameState GameState { get; set; } = new();
@@ -11,5 +12,6 @@ public partial class Game : Node2D
ExecuteButton.Pressed += () => DaySchedule.StartDay();
EventBus.CompanyChanged?.Invoke(GameState.Company.ToCompanyStats());
EventBus.CeoChanged?.Invoke(GameState.Ceo.ToCeoStats());
}
}

View File

@@ -1,13 +1,14 @@
[gd_scene format=3 uid="uid://b2rl7r8oav3hy"]
[ext_resource type="Script" uid="uid://d1h0qvskvk1wu" path="res://Game.cs" id="1_joorw"]
[ext_resource type="PackedScene" uid="uid://ckdqrg8c0mq8h" path="res://CompanyStatsContainer.tscn" id="2_2vekm"]
[ext_resource type="PackedScene" uid="uid://covomnw8s7k1n" path="res://DaySchedule.tscn" id="3_yx171"]
[ext_resource type="PackedScene" uid="uid://dciugg77wsy6p" path="res://MeetingPhysicsBox.tscn" id="4_yhmtn"]
[ext_resource type="Resource" uid="uid://mifwco1yj8kc" path="res://resources/meetings/coffee_meeting.tres" id="5_gwjdr"]
[ext_resource type="Resource" uid="uid://du72uxjqr0h4a" path="res://resources/meetings/lockin.tres" id="6_lvtmh"]
[ext_resource type="Resource" uid="uid://bcd4qf4i84pwf" path="res://resources/meetings/work_product_1.tres" id="7_yyih5"]
[ext_resource type="Script" uid="uid://bs531c76ivhtf" path="res://DropZone.cs" id="8_qjyg3"]
[ext_resource type="Script" uid="uid://d1h0qvskvk1wu" path="res://Main.cs" id="1_trn2v"]
[ext_resource type="PackedScene" uid="uid://ckdqrg8c0mq8h" path="res://CompanyStatsContainer.tscn" id="2_03owx"]
[ext_resource type="PackedScene" uid="uid://bf2e8stflktgv" path="res://CeoStatsContainer.tscn" id="3_03owx"]
[ext_resource type="PackedScene" uid="uid://covomnw8s7k1n" path="res://DaySchedule.tscn" id="3_wkp8b"]
[ext_resource type="PackedScene" uid="uid://dciugg77wsy6p" path="res://MeetingPhysicsBox.tscn" id="4_20pc6"]
[ext_resource type="Resource" uid="uid://mifwco1yj8kc" path="res://Resources/Meetings/coffee_meeting.tres" id="5_5vvyt"]
[ext_resource type="Resource" uid="uid://du72uxjqr0h4a" path="res://Resources/Meetings/lockin.tres" id="6_c6i3y"]
[ext_resource type="Resource" uid="uid://bcd4qf4i84pwf" path="res://Resources/Meetings/work_product_1.tres" id="7_c2ibq"]
[ext_resource type="Script" uid="uid://bs531c76ivhtf" path="res://DropZone.cs" id="8_j4qnp"]
[sub_resource type="Gradient" id="Gradient_trn2v"]
offsets = PackedFloat32Array(0, 0.5518293, 1)
@@ -31,8 +32,8 @@ size = Vector2(727.5, 20)
[sub_resource type="RectangleShape2D" id="RectangleShape2D_ig7tw"]
size = Vector2(21.5, 1920)
[node name="Game" type="Node2D" unique_id=287617203]
script = ExtResource("1_joorw")
[node name="Main" type="Node2D" unique_id=287617203]
script = ExtResource("1_trn2v")
[node name="MeetingSpawn" type="Marker2D" parent="." unique_id=1266113438]
unique_name_in_owner = true
@@ -64,12 +65,22 @@ grow_horizontal = 2
grow_vertical = 2
mouse_filter = 2
[node name="CompanyStatsContainer" parent="CanvasLayer/Control" unique_id=317328071 instance=ExtResource("2_2vekm")]
[node name="VBoxContainer" type="VBoxContainer" parent="CanvasLayer/Control" unique_id=1966287105]
layout_mode = 1
offset_left = -249.53503
offset_right = 0.0
anchors_preset = 1
anchor_left = 1.0
anchor_right = 1.0
offset_left = -172.0
offset_bottom = 263.0
grow_horizontal = 0
[node name="DaySchedule" parent="." unique_id=457829015 instance=ExtResource("3_yx171")]
[node name="CeoStatsContainer" parent="CanvasLayer/Control/VBoxContainer" unique_id=1046022403 instance=ExtResource("3_03owx")]
layout_mode = 2
[node name="CompanyStatsContainer" parent="CanvasLayer/Control/VBoxContainer" unique_id=317328071 instance=ExtResource("2_03owx")]
layout_mode = 2
[node name="DaySchedule" parent="." unique_id=457829015 instance=ExtResource("3_wkp8b")]
unique_name_in_owner = true
offset_left = -498.0
offset_top = -269.0
@@ -106,48 +117,49 @@ shape = SubResource("RectangleShape2D_ig7tw")
position = Vector2(1120, -339)
shape = SubResource("RectangleShape2D_ig7tw")
[node name="Meeting" parent="." unique_id=796440984 instance=ExtResource("4_yhmtn")]
[node name="Meeting" parent="." unique_id=796440984 instance=ExtResource("4_20pc6")]
position = Vector2(35, -776.00006)
MeetingResource = ExtResource("5_gwjdr")
MeetingResource = ExtResource("5_5vvyt")
[node name="Meeting4" parent="." unique_id=1960552374 instance=ExtResource("4_yhmtn")]
[node name="Meeting4" parent="." unique_id=1960552374 instance=ExtResource("4_20pc6")]
position = Vector2(108, -662.00006)
rotation = 0.24779713
MeetingResource = ExtResource("6_lvtmh")
MeetingResource = ExtResource("6_c6i3y")
[node name="Meeting5" parent="." unique_id=1692042144 instance=ExtResource("4_yhmtn")]
[node name="Meeting5" parent="." unique_id=1692042144 instance=ExtResource("4_20pc6")]
position = Vector2(252, -822.00006)
rotation = 0.24779713
MeetingResource = ExtResource("7_yyih5")
MeetingResource = ExtResource("7_c2ibq")
[node name="Meeting6" parent="." unique_id=2120697586 instance=ExtResource("4_yhmtn")]
[node name="Meeting6" parent="." unique_id=2120697586 instance=ExtResource("4_20pc6")]
position = Vector2(5, -942)
rotation = 0.24779713
MeetingResource = ExtResource("5_gwjdr")
MeetingResource = ExtResource("5_5vvyt")
[node name="Meeting7" parent="." unique_id=2144014406 instance=ExtResource("4_yhmtn")]
[node name="Meeting7" parent="." unique_id=2144014406 instance=ExtResource("4_20pc6")]
position = Vector2(258, -983.00006)
rotation = 0.24779713
MeetingResource = ExtResource("5_gwjdr")
MeetingResource = ExtResource("5_5vvyt")
[node name="Meeting8" parent="." unique_id=1157887697 instance=ExtResource("4_yhmtn")]
position = Vector2(365, -877.00006)
[node name="Meeting8" parent="." unique_id=1157887697 instance=ExtResource("4_20pc6")]
position = Vector2(365, -878.00006)
rotation = 0.24779713
MeetingResource = ExtResource("5_5vvyt")
[node name="Meeting9" parent="." unique_id=1055632102 instance=ExtResource("4_yhmtn")]
[node name="Meeting9" parent="." unique_id=1055632102 instance=ExtResource("4_20pc6")]
position = Vector2(15, -1055)
rotation = 0.24779713
MeetingResource = ExtResource("7_yyih5")
MeetingResource = ExtResource("7_c2ibq")
[node name="Meeting2" parent="." unique_id=1691479453 instance=ExtResource("4_yhmtn")]
[node name="Meeting2" parent="." unique_id=1691479453 instance=ExtResource("4_20pc6")]
position = Vector2(338, -674.00006)
rotation = -0.5541229
MeetingResource = ExtResource("5_gwjdr")
MeetingResource = ExtResource("5_5vvyt")
[node name="Meeting3" parent="." unique_id=673551448 instance=ExtResource("4_yhmtn")]
[node name="Meeting3" parent="." unique_id=673551448 instance=ExtResource("4_20pc6")]
position = Vector2(163.99982, -503.0002)
rotation = -0.18364333
MeetingResource = ExtResource("5_gwjdr")
MeetingResource = ExtResource("5_5vvyt")
[node name="DropZone" type="Control" parent="." unique_id=80494692]
layout_mode = 3
@@ -157,6 +169,6 @@ offset_top = -323.0
offset_right = 507.0
offset_bottom = 276.0
mouse_filter = 2
script = ExtResource("8_qjyg3")
script = ExtResource("8_j4qnp")
[node name="Camera2D" type="Camera2D" parent="." unique_id=1154975713]

View File

@@ -1,5 +1,7 @@
using Game.Extensions;
using Godot;
using yourareanaiceo;
namespace Game;
public sealed partial class MeetingControlDragData(MeetingControl meetingControl) : GodotObject
{
@@ -91,7 +93,7 @@ public partial class MeetingControl : Control
private void RespawnPhysicsBoxFromSpawn()
{
var game = this.GetGame();
var game = NodeExtensions.GetMain(this);
game.AddChild(MeetingPhysicsBox);
MeetingPhysicsBox.Position = game.MeetingSpawn.GlobalPosition;
QueueFree();

View File

@@ -1,6 +1,8 @@
using System;
using Game.Resources;
using Godot;
namespace Game;
[SceneTree]
public partial class MeetingControlGfx : PanelContainer
{

View File

@@ -1,5 +1,8 @@
using Game.Resources;
using Godot;
namespace Game;
[SceneTree]
public partial class MeetingPhysicsBox : RigidBody2D
{

View File

@@ -1,6 +1,6 @@
using Godot;
namespace yourareanaiceo;
namespace Game;
[ResourceTree]
public static partial class MyRes;

View File

@@ -1,5 +1,7 @@
using Game.Extensions;
using Godot;
using yourareanaiceo;
namespace Game;
[SceneTree]
public partial class TimeSlot : PanelContainer
@@ -35,7 +37,7 @@ public partial class TimeSlot : PanelContainer
public void StartMeeting()
{
GD.Print("New Meeting starts!");
var gameState = this.GetGame().GameState;
var gameState = NodeExtensions.GetMain(this).GameState;
// TODO: TimeSlot hat bekommt die MeetingResource on Drop?? oder zumindest nicht über Gfx gehen
MeetingControl?.MeetingControlGfx.MeetingResource.StartMeeting(gameState);

View File

@@ -1,5 +1,6 @@
using Godot;
using yourareanaiceo;
namespace Game.Resources;
[GlobalClass]
public partial class GainHypeAction : MeetingActionResource

View File

@@ -1,5 +1,6 @@
using Godot;
using yourareanaiceo;
namespace Game.Resources;
[GlobalClass]
public abstract partial class MeetingActionResource : Resource

View File

@@ -1,7 +1,8 @@
using System.Linq;
using Godot;
using Godot.Collections;
using yourareanaiceo;
namespace Game.Resources;
[GlobalClass]
public partial class MeetingResource : Resource

View File

@@ -1,6 +1,7 @@
[gd_resource type="Resource" script_class="MeetingResource" format=3 uid="uid://mifwco1yj8kc"]
[gd_resource type="Resource" format=3 uid="uid://mifwco1yj8kc"]
[ext_resource type="Script" uid="uid://cuq38lbfa2v74" path="res://resources/MeetingResource.cs" id="1_s1cac"]
[ext_resource type="Script" uid="uid://chl0yv2tsg2va" path="res://Resources/MeetingActionResource.cs" id="1_nqgj7"]
[ext_resource type="Script" uid="uid://cuq38lbfa2v74" path="res://Resources/MeetingResource.cs" id="1_s1cac"]
[resource]
script = ExtResource("1_s1cac")

View File

@@ -1,8 +1,8 @@
[gd_resource type="Resource" script_class="MeetingResource" format=3 uid="uid://du72uxjqr0h4a"]
[ext_resource type="Script" uid="uid://cuq38lbfa2v74" path="res://resources/MeetingResource.cs" id="1_4yd4m"]
[ext_resource type="Script" uid="uid://chl0yv2tsg2va" path="res://resources/MeetingActionResource.cs" id="1_edffo"]
[ext_resource type="Script" uid="uid://cduoflv3vjfmg" path="res://resources/GainHypeAction.cs" id="1_qpv0b"]
[ext_resource type="Script" uid="uid://cuq38lbfa2v74" path="res://Resources/MeetingResource.cs" id="1_4yd4m"]
[ext_resource type="Script" uid="uid://chl0yv2tsg2va" path="res://Resources/MeetingActionResource.cs" id="1_edffo"]
[ext_resource type="Script" uid="uid://cduoflv3vjfmg" path="res://Resources/GainHypeAction.cs" id="1_qpv0b"]
[sub_resource type="Resource" id="Resource_7t1gw"]
script = ExtResource("1_qpv0b")

View File

@@ -1,8 +1,8 @@
[gd_resource type="Resource" script_class="MeetingResource" format=3 uid="uid://bcd4qf4i84pwf"]
[ext_resource type="Script" uid="uid://cduoflv3vjfmg" path="res://resources/GainHypeAction.cs" id="1_7t1gw"]
[ext_resource type="Script" uid="uid://chl0yv2tsg2va" path="res://resources/MeetingActionResource.cs" id="1_8teln"]
[ext_resource type="Script" uid="uid://cuq38lbfa2v74" path="res://resources/MeetingResource.cs" id="1_qndny"]
[ext_resource type="Script" uid="uid://cduoflv3vjfmg" path="res://Resources/GainHypeAction.cs" id="1_7t1gw"]
[ext_resource type="Script" uid="uid://chl0yv2tsg2va" path="res://Resources/MeetingActionResource.cs" id="1_8teln"]
[ext_resource type="Script" uid="uid://cuq38lbfa2v74" path="res://Resources/MeetingResource.cs" id="1_qndny"]
[sub_resource type="Resource" id="Resource_b6clr"]
script = ExtResource("1_7t1gw")

View File

@@ -3,12 +3,14 @@
<TargetFramework>net8.0</TargetFramework>
<TargetFramework Condition=" '$(GodotTargetPlatform)' == 'android' ">net9.0</TargetFramework>
<EnableDynamicLoading>true</EnableDynamicLoading>
<RootNamespace>AiCeo</RootNamespace>
<RootNamespace>Game</RootNamespace>
<Authors>Jens Becker</Authors>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="GodotSharp.SourceGenerators" Version="2.7.0" />
</ItemGroup>
<ItemGroup>
<Folder Include=".godot\" />
<Folder Include=".godot\mono\" />
</ItemGroup>
</Project>