diff --git a/Server/Hotfix/Demo/Unit/UnitFactory.cs b/Server/Hotfix/Demo/Unit/UnitFactory.cs index 9508e3d..c5c9884 100644 --- a/Server/Hotfix/Demo/Unit/UnitFactory.cs +++ b/Server/Hotfix/Demo/Unit/UnitFactory.cs @@ -57,7 +57,6 @@ namespace ET unit.SeasonConfig = SeasonConfigCategory.Instance.Get(unit.Season); unitComponent.AddChild(unit); - InitNoDb(unit); } else { @@ -195,23 +194,6 @@ namespace ET }*/ } - public static void InitNoDb(Unit unit) - { - var bc = unit.GetComponent(); - if (bc == null) - { - return; - } - foreach (var v in unit.GetComponent().Children.Values) - { - foreach (var c in v.Children.Values) - { - if (c.GetType() == typeof (Farmland)) - { - unit.FarmlandDic[c.Id] = (Farmland) c; - } - } - } - } + } } \ No newline at end of file diff --git a/Unity/Codes/Hotfix/Demo/Unit/UnitFactory.cs b/Unity/Codes/Hotfix/Demo/Unit/UnitFactory.cs index bd430c6..c853c70 100644 --- a/Unity/Codes/Hotfix/Demo/Unit/UnitFactory.cs +++ b/Unity/Codes/Hotfix/Demo/Unit/UnitFactory.cs @@ -110,6 +110,7 @@ namespace ET unitComponent.Add(unit); unit.AddComponent(); + unit.InitFarmlandDic(); Game.EventSystem.Publish(new EventType.AfterUnitCreate() {Unit = unit}); return unit; diff --git a/Unity/Codes/Hotfix/Demo/Unit/UnitSystem.cs b/Unity/Codes/Hotfix/Demo/Unit/UnitSystem.cs index e9543ed..3335395 100644 --- a/Unity/Codes/Hotfix/Demo/Unit/UnitSystem.cs +++ b/Unity/Codes/Hotfix/Demo/Unit/UnitSystem.cs @@ -146,6 +146,7 @@ namespace ET self.UpdateValleyTime = TimeHelper.ServerUnix(); self.SeasonConfig = SeasonConfigCategory.Instance.Get(self.Season); self.InitPeopleNumberic(); + self.InitFarmlandDic(); } public static void updateSeason(this Unit self) @@ -245,6 +246,25 @@ namespace ET ((People) v).GrowUp(); } } + + public static void InitFarmlandDic(this Unit self) + { + var bc = self.GetComponent(); + if (bc == null) + { + return; + } + foreach (var v in self.GetComponent().Children.Values) + { + foreach (var c in v.Children.Values) + { + if (c.GetType() == typeof (Farmland)) + { + self.FarmlandDic[c.Id] = (Farmland) c; + } + } + } + } } } \ No newline at end of file