From 242d6686c999eed61e2e135f474258ad2004ae0c Mon Sep 17 00:00:00 2001 From: wserver/wangdisen <1065498738@qq.com> Date: Fri, 26 Aug 2022 10:23:45 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=B0=8F=E5=B1=8B=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E7=9A=84=E5=86=9C=E7=94=B0seed=E7=8A=B6=E6=80=81?= =?UTF-8?q?=E6=A3=80=E6=B5=8B=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Unity/Codes/Hotfix/Demo/Unit/UnitFactory.cs | 1 + Unity/Codes/Hotfix/Demo/Unit/UnitSystem.cs | 24 +++++++++++++++++++ .../Handler/M2C_NtfWeatherEndHandler.cs | 2 +- .../Hotfix/Demo/Weather/WeatherSystem.cs | 1 + 4 files changed, 27 insertions(+), 1 deletion(-) 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;