diff --git a/Unity/Codes/Hotfix/Demo/Unit/UnitFactory.cs b/Unity/Codes/Hotfix/Demo/Unit/UnitFactory.cs index a5178c3..4239696 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.InitGrandChildren(); + unit.OnCheckCabin(); 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 96f803c..d81145d 100644 --- a/Unity/Codes/Hotfix/Demo/Unit/UnitSystem.cs +++ b/Unity/Codes/Hotfix/Demo/Unit/UnitSystem.cs @@ -49,6 +49,7 @@ namespace ET [FriendClass(typeof (Unit))] [FriendClass(typeof (Farmland))] [FriendClass(typeof (Building))] + [FriendClass(typeof (Cabin))] public static class UnitSystem { @@ -341,5 +342,28 @@ namespace ET ((Building) v).Durable -= config.DurableDestroy; } } + + public static void OnCheckCabin(this Unit self) + { + foreach (var v in self.GrandChildren.Values) + { + if (v.GetType() == typeof (Cabin)) + { + Cabin cabin = (Cabin) v; + if (cabin.ResidentState == 1) + { + foreach (var id in cabin.FarmlandIds) + { + var farmland = self.GetGrandChild(id); + if (farmland != null && farmland.FarmlandState == FarmlandState.FARMLAND_STATE_SEED) + { + farmland.FarmlandState = FarmlandState.FARMLAND_STATE_GROW; + } + } + } + } + + } + } } } \ No newline at end of file diff --git a/Unity/Codes/Hotfix/Demo/Weather/Handler/M2C_NtfWeatherEndHandler.cs b/Unity/Codes/Hotfix/Demo/Weather/Handler/M2C_NtfWeatherEndHandler.cs index 47d64f7..397af9e 100644 --- a/Unity/Codes/Hotfix/Demo/Weather/Handler/M2C_NtfWeatherEndHandler.cs +++ b/Unity/Codes/Hotfix/Demo/Weather/Handler/M2C_NtfWeatherEndHandler.cs @@ -6,7 +6,7 @@ { protected override void Run(Session session, M2C_NtfWeatherEnd message) { - + UnitComponent.unit.OnWeatherEnd(message.WeatherCfgId); } } diff --git a/Unity/Codes/Hotfix/Demo/Weather/WeatherSystem.cs b/Unity/Codes/Hotfix/Demo/Weather/WeatherSystem.cs index 1f6663c..1253425 100644 --- a/Unity/Codes/Hotfix/Demo/Weather/WeatherSystem.cs +++ b/Unity/Codes/Hotfix/Demo/Weather/WeatherSystem.cs @@ -115,6 +115,7 @@ namespace ET self.State = 0; #if SERVER + unit.OnWeatherEnd(self.ConfigId); UnitHelper.NotifyWeatherEnd(unit, self.ConfigId); #endif self.ConfigId = 0;