@@ -27,17 +27,17 @@ public class UpgradesManager
2727 {
2828 readonly Actor self ;
2929 Dictionary < string , UpgradeInfo > upgrades ;
30- HashSet < string > unlockedUpgradeTypes ;
30+ Dictionary < string , int > unlockedUpgradeTypes ;
3131
3232 public int Hash { get ; private set ; }
3333
34- public HashSet < string > UnlockedUpgradeTypes => unlockedUpgradeTypes ;
34+ public Dictionary < string , int > UnlockedUpgradeTypes => unlockedUpgradeTypes ;
3535
3636 public UpgradesManager ( Actor self , UpgradesManagerInfo info )
3737 {
3838 this . self = self ;
3939 upgrades = new Dictionary < string , UpgradeInfo > ( ) ;
40- unlockedUpgradeTypes = new HashSet < string > ( ) ;
40+ unlockedUpgradeTypes = new Dictionary < string , int > ( ) ;
4141 Hash = 0 ;
4242 }
4343
@@ -79,23 +79,26 @@ public UpgradeInfo UpgradeableActorCreated(Upgradeable upgradeable, string upgra
7979
8080 public void UpgradeProviderCreated ( string type )
8181 {
82- if ( IsUnlocked ( type ) )
83- return ;
82+ if ( unlockedUpgradeTypes . ContainsKey ( type ) )
83+ unlockedUpgradeTypes [ type ] ++ ;
84+ else
85+ unlockedUpgradeTypes . Add ( type , 1 ) ;
8486
85- Update ( ) ;
86-
87- unlockedUpgradeTypes . Add ( type ) ;
88- var upgradeables = self . World . ActorsWithTrait < Upgradeable > ( ) . Where ( x => x . Trait . Info . Type == type && x . Actor . Owner == self . Owner ) . ToList ( ) ;
87+ if ( ! IsUnlocked ( type ) )
88+ {
89+ var upgradeables = self . World . ActorsWithTrait < Upgradeable > ( ) . Where ( x => x . Trait . Info . Type == type && x . Actor . Owner == self . Owner ) . ToList ( ) ;
8990
90- foreach ( var p in upgradeables )
91- p . Trait . Unlock ( ) ;
91+ foreach ( var p in upgradeables )
92+ p . Trait . Unlock ( ) ;
93+ }
9294
9395 UpgradeCompleted ? . Invoke ( type ) ;
96+ Update ( ) ;
9497 }
9598
9699 public bool IsUnlocked ( string upgradeType )
97100 {
98- return unlockedUpgradeTypes . Contains ( upgradeType ) ;
101+ return unlockedUpgradeTypes . ContainsKey ( upgradeType ) ;
99102 }
100103
101104 int CalculateCost ( string sourceActorType , string targetActorType )
0 commit comments