11using System ;
2- using System . Threading . Tasks ;
32using Godot ;
43
54/// <summary>
@@ -15,23 +14,23 @@ public partial class EventDatabase
1514 [ "EVENT_EVENT1_OPTION1" , "EVENT_EVENT1_OPTION2" , "EVENT_EVENT1_OPTION3" ] ,
1615 [ "EVENT_EVENT1_OUTCOME1" , "EVENT_EVENT1_OUTCOME2" , "EVENT_EVENT1_OUTCOME3" ] ,
1716 [
18- async ( self , node ) =>
17+ ( self , node ) =>
1918 {
2019 int randIndex = StageProducer . GlobalRng . RandiRange (
2120 0 ,
2221 StageProducer . PlayerStats . CurNotes . Length
2322 ) ;
2423 StageProducer . PlayerStats . RemoveNote ( randIndex ) ;
2524 } ,
26- async ( self , node ) =>
25+ ( self , node ) =>
2726 {
2827 int randIndex = StageProducer . GlobalRng . RandiRange (
2928 0 ,
3029 StageProducer . PlayerStats . CurRelics . Length
3130 ) ;
3231 StageProducer . PlayerStats . RemoveRelic ( randIndex ) ;
3332 } ,
34- async ( self , node ) =>
33+ ( self , node ) =>
3534 {
3635 StageProducer . PlayerStats . Money /= 2 ;
3736 } ,
@@ -49,10 +48,10 @@ public partial class EventDatabase
4948 [ "EVENT_EVENT2_OPTION1" , "EVENT_EVENT2_OPTION2" ] ,
5049 [ "" , "EVENT_EVENT2_OUTCOME1" ] ,
5150 [
52- async ( self , node ) =>
51+ ( self , node ) =>
5352 {
5453 var spinner = node . GetNodeOrNull < Sprite2D > ( "EventSprite" ) ;
55- int spinOutcome = ( int ) StageProducer . GlobalRng . RandWeighted ( [ 1 , 1 , 1 , 1 , 1 , 1 ] ) ;
54+ int spinOutcome = ( int ) StageProducer . GlobalRng . RandiRange ( 0 , 5 ) ;
5655
5756 int outcomeCount = 6 ;
5857 float sectorAngle = 360f / outcomeCount ;
@@ -66,61 +65,57 @@ public partial class EventDatabase
6665 . SetTrans ( Tween . TransitionType . Cubic )
6766 . SetEase ( Tween . EaseType . Out ) ;
6867
69- var tcs = new TaskCompletionSource < bool > ( ) ;
70- tween . TweenCallback ( Callable . From ( ( ) => tcs . SetResult ( true ) ) ) ;
71- await tcs . Task ;
72-
73- switch ( spinOutcome )
74- {
75- case 0 :
76- GD . Print ( "lost half money" ) ;
77- StageProducer . PlayerStats . Money /= 2 ;
78- self . OutcomeDescriptions [ 0 ] = "EVENT_EVENT2_OUTCOME2" ;
79- break ;
80- case 1 :
81- GD . Print ( "took damage" ) ;
82- self . OutcomeDescriptions [ 0 ] = "EVENT_EVENT2_OUTCOME3" ;
83- StageProducer . PlayerStats . CurrentHealth = Math . Max (
84- 1 ,
85- StageProducer . PlayerStats . CurrentHealth - 10
86- ) ;
87- break ;
88- case 2 :
89- GD . Print ( "gain money" ) ;
90- self . OutcomeDescriptions [ 0 ] = "EVENT_EVENT2_OUTCOME4" ;
91- StageProducer . PlayerStats . Money += 50 ;
92- break ;
93- case 3 :
94- GD . Print ( "random note" ) ;
95- self . OutcomeDescriptions [ 0 ] = "EVENT_EVENT2_OUTCOME5" ;
96- StageProducer . PlayerStats . AddNote (
97- Scribe . GetRandomRewardNotes ( 1 , StageProducer . CurRoom + 10 ) [ 0 ]
98- ) ;
99- break ;
100- case 4 :
101- GD . Print ( "random relic" ) ;
102- self . OutcomeDescriptions [ 0 ] = "EVENT_EVENT2_OUTCOME6" ;
103- StageProducer . PlayerStats . AddRelic (
104- Scribe . GetRandomRelics (
105- 1 ,
106- StageProducer . CurRoom + 10 ,
107- StageProducer . PlayerStats . RarityOdds
108- ) [ 0 ]
109- ) ;
110- break ;
111- case 5 :
112- GD . Print ( "heal" ) ;
113- self . OutcomeDescriptions [ 0 ] = "EVENT_EVENT2_OUTCOME7" ;
114- StageProducer . PlayerStats . CurrentHealth = Math . Min (
115- StageProducer . PlayerStats . CurrentHealth + 20 ,
116- StageProducer . PlayerStats . MaxHealth
117- ) ;
118- break ;
119- }
120-
121- GD . Print ( $ "new description { self . OutcomeDescriptions [ 0 ] } ") ;
68+ // Defer execution of the outcome until the tween finishes
69+ tween . TweenCallback (
70+ Callable . From ( ( ) =>
71+ {
72+ switch ( spinOutcome )
73+ {
74+ case 0 :
75+ StageProducer . PlayerStats . Money /= 2 ;
76+ self . OutcomeDescriptions [ 0 ] = "EVENT_EVENT2_OUTCOME2" ;
77+ break ;
78+ case 1 :
79+ self . OutcomeDescriptions [ 0 ] = "EVENT_EVENT2_OUTCOME3" ;
80+ StageProducer . PlayerStats . CurrentHealth = Math . Max (
81+ 1 ,
82+ StageProducer . PlayerStats . CurrentHealth - 10
83+ ) ;
84+ break ;
85+ case 2 :
86+ self . OutcomeDescriptions [ 0 ] = "EVENT_EVENT2_OUTCOME4" ;
87+ StageProducer . PlayerStats . Money += 50 ;
88+ break ;
89+ case 3 :
90+ self . OutcomeDescriptions [ 0 ] = "EVENT_EVENT2_OUTCOME5" ;
91+ StageProducer . PlayerStats . AddNote (
92+ Scribe . GetRandomRewardNotes ( 1 , StageProducer . CurRoom + 10 ) [
93+ 0
94+ ]
95+ ) ;
96+ break ;
97+ case 4 :
98+ self . OutcomeDescriptions [ 0 ] = "EVENT_EVENT2_OUTCOME6" ;
99+ StageProducer . PlayerStats . AddRelic (
100+ Scribe . GetRandomRelics (
101+ 1 ,
102+ StageProducer . CurRoom + 10 ,
103+ StageProducer . PlayerStats . RarityOdds
104+ ) [ 0 ]
105+ ) ;
106+ break ;
107+ case 5 :
108+ self . OutcomeDescriptions [ 0 ] = "EVENT_EVENT2_OUTCOME7" ;
109+ StageProducer . PlayerStats . CurrentHealth = Math . Min (
110+ StageProducer . PlayerStats . CurrentHealth + 20 ,
111+ StageProducer . PlayerStats . MaxHealth
112+ ) ;
113+ break ;
114+ }
115+ } )
116+ ) ;
122117 } ,
123- async ( self , node ) => {
118+ ( self , node ) => {
124119 // does nothing
125120 } ,
126121 ] ,
@@ -133,18 +128,18 @@ public partial class EventDatabase
133128 [ "EVENT_EVENT3_OPTION1" , "EVENT_EVENT3_OPTION2" , "EVENT_EVENT3_OPTION3" ] ,
134129 [ "EVENT_EVENT3_OUTCOME1" , "EVENT_EVENT3_OUTCOME2" , "EVENT_EVENT3_OUTCOME3" ] ,
135130 [
136- async ( self , node ) =>
131+ ( self , node ) =>
137132 {
138133 StageProducer . PlayerStats . CurrentHealth = Math . Min (
139134 StageProducer . PlayerStats . CurrentHealth + 10 ,
140135 StageProducer . PlayerStats . MaxHealth
141136 ) ;
142137 } ,
143- async ( self , node ) =>
138+ ( self , node ) =>
144139 {
145140 StageProducer . PlayerStats . MaxComboBar -= 5 ;
146141 } ,
147- async ( self , node ) =>
142+ ( self , node ) =>
148143 {
149144 StageProducer . PlayerStats . Money -= 30 ;
150145 StageProducer . PlayerStats . AddNote ( Scribe . NoteDictionary [ 3 ] ) ;
0 commit comments