Skip to content

Commit 1469b74

Browse files
committed
Some optimization & closes #374
1 parent ade2e57 commit 1469b74

File tree

15 files changed

+29
-23
lines changed

15 files changed

+29
-23
lines changed
0 Bytes
Binary file not shown.

Assets/EconomicSimulation/Scripts/Logic/Factory.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -973,10 +973,7 @@ override internal float getExpences()
973973
{
974974
return base.getExpences() + getSalaryCost();
975975
}
976-
/// <summary>
977-
/// Should optimize? Seek for changes..
978-
/// </summary>
979-
/// <returns></returns>
976+
//Not necessary ti optimize - cost 0.1% of tick
980977
public int getWorkForce()
981978
{
982979
int result = 0;

Assets/EconomicSimulation/Scripts/Logic/Game.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,8 @@ static void makeHelloMessage()
485485
+ "\n\nOr, You can give control to AI and watch it"
486486
+ "\n\nTry arrows or WASD for scrolling map and mouse wheel for scale"
487487
+ "\n'Enter' key to close top window, space - to pause \\ unpause"
488-
+ "\n\n\nAlso I have now Patreon page where I post about that game development. Try red button below!"
488+
+ "\n\n\nI have now Patreon page where I post about that game development. Try red button below!"
489+
+ "\nAlso I would be thankful if you will share info about this project"
489490
, "Ok");
490491
}
491492

Assets/EconomicSimulation/Scripts/Logic/Market.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ private Storage recalculateProductForConsumers(Product product, Func<Consumer, S
101101
foreach (Province province in country.ownedProvinces)
102102
foreach (Consumer consumer in province.getAllAgents())
103103
{
104-
Storage re = selector(consumer).getFirstStorage(product);
105-
result.add(re);
104+
Storage found = selector(consumer).getFirstStorage(product);
105+
result.add(found);
106106
}
107107
Storage countryStor = selector(country).getFirstStorage(product);
108108
result.add(countryStor);

Assets/EconomicSimulation/Scripts/Logic/PopTypes/PopUnit.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ private List<Storage> getNeedsInCommon(List<Storage> needs)
445445
Value multiplier = new Value(this.getPopulation() / 1000f);
446446
List<Storage> result = new List<Storage>();
447447
foreach (Storage next in needs)
448-
if (next.getProduct().isInventedByAnyOne())
448+
if (next.getProduct().IsInventedByAnyOne())
449449
{
450450
Storage nStor = new Storage(next.getProduct(), next.get());
451451
nStor.multiply(multiplier);

Assets/EconomicSimulation/Scripts/Logic/Product.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ static public int CostOrder(Product x, Product y)
243243

244244
public bool isTradable()
245245
{
246-
return this != Product.Gold && isInventedByAnyOne();
246+
return this != Product.Gold && IsInventedByAnyOne();
247247
}
248248

249249
public bool isAbstract()
@@ -287,7 +287,7 @@ internal bool isResource()
287287
}
288288

289289

290-
public bool isInventedByAnyOne()
290+
public bool IsInventedByAnyOne()
291291
{
292292
// including dead countries. Because dead country could organize production
293293
//of some freshly invented product
@@ -361,7 +361,7 @@ public override string ToString()
361361
sb.Append(" (");
362362
bool firstLine = true;
363363
foreach (var item in getSubstitutes())
364-
if (item.isInventedByAnyOne())
364+
if (item.IsInventedByAnyOne())
365365
{
366366
if (!firstLine)
367367
sb.Append(" or ");

Assets/EconomicSimulation/Scripts/Logic/Province.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,7 @@ internal void setResource(Product inres)
704704
internal Product getResource()
705705
{
706706
//if (getOwner().isInvented(resource))
707-
if (resource.isInventedByAnyOne())
707+
if (resource.IsInventedByAnyOne())
708708
return resource;
709709
else
710710
return null;

Assets/EconomicSimulation/Scripts/PanelTables/BuildPanelTable.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,21 @@
44
using System.Collections.Generic;
55
using System;
66
using Nashet.UnityUIUtils;
7+
using System.Linq;
78

89
namespace Nashet.EconomicSimulation
910
{
1011

1112
public class BuildPanelTable : UITableNew<FactoryType>
1213
{
1314
protected override IEnumerable<FactoryType> ContentSelector()
14-
{
15-
return FactoryType.getAllInventedTypes(Game.Player, x => x.canBuildNewFactory(Game.selectedProvince));
16-
}
15+
{
16+
17+
if (Game.selectedProvince == null)
18+
return Enumerable.Empty<FactoryType>();
19+
else
20+
return FactoryType.getAllInventedTypes(Game.Player, x => x.canBuildNewFactory(Game.selectedProvince));
21+
}
1722
protected override void AddRow(FactoryType factoryType, int number)
1823
{
1924
// Adding shownFactory type

Assets/EconomicSimulation/Scripts/Panels/BuildPanel.cs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@
66
using Nashet.UnityUIUtils;
77
using Nashet.ValueSpace;
88
using Nashet.Utils;
9+
using System.Linq;
10+
911
namespace Nashet.EconomicSimulation
1012
{
11-
1213
public class BuildPanel : DragPanel
1314
{
1415
[SerializeField]
@@ -35,7 +36,7 @@ void Start()
3536
public override void Show()
3637
{
3738
selectedFactoryType = null; // changed province
38-
base.Show();
39+
base.Show();
3940
}
4041
public void onBuildClick()
4142
{
@@ -106,7 +107,7 @@ public override void Refresh()
106107

107108
descriptionText.text = sb.ToString();
108109

109-
110+
110111
buildButton.interactable = selectedFactoryType.conditionsBuild.isAllTrue(Game.Player, Game.selectedProvince, out buildButton.GetComponent<ToolTipHandler>().text);
111112
if (!selectedFactoryType.canBuildNewFactory(Game.selectedProvince))
112113
buildButton.interactable = false;
@@ -116,11 +117,13 @@ public override void Refresh()
116117
else
117118
{
118119
buildButton.interactable = false;
119-
{
120-
buildButton.GetComponentInChildren<Text>().text = "Select building";
120+
buildButton.GetComponentInChildren<Text>().text = "Select building";
121+
if (Game.selectedProvince == null)
122+
descriptionText.text = "Select province where to build";
123+
else if (FactoryType.getAllInventedTypes(Game.Player, x => x.canBuildNewFactory(Game.selectedProvince)).Count() == 0)
124+
descriptionText.text = "Nothing to build now";
125+
else
121126
descriptionText.text = "Select building from left";
122-
}
123-
124127
}
125128
}
126129
}

Assets/UnityUIUtils/Scripts/MyTable.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ public string getSymbol()
315315
return " ";
316316
case State.descending:
317317
#if UNITY_WEBGL
318-
return " ˅";
318+
return " v";
319319
#else
320320
return " \u25BC";
321321
#endif

0 commit comments

Comments
 (0)