Browse Source

增加小屋管理的农田seed状态检测功能

master
wserver/wangdisen 3 years ago
parent
commit
242d6686c9
  1. 1
      Unity/Codes/Hotfix/Demo/Unit/UnitFactory.cs
  2. 24
      Unity/Codes/Hotfix/Demo/Unit/UnitSystem.cs
  3. 2
      Unity/Codes/Hotfix/Demo/Weather/Handler/M2C_NtfWeatherEndHandler.cs
  4. 1
      Unity/Codes/Hotfix/Demo/Weather/WeatherSystem.cs

1
Unity/Codes/Hotfix/Demo/Unit/UnitFactory.cs

@ -110,6 +110,7 @@ namespace ET
unitComponent.Add(unit);
unit.AddComponent<ObjectWait>();
unit.InitGrandChildren();
unit.OnCheckCabin();
Game.EventSystem.Publish(new EventType.AfterUnitCreate() {Unit = unit});
return unit;

24
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<Farmland>(id);
if (farmland != null && farmland.FarmlandState == FarmlandState.FARMLAND_STATE_SEED)
{
farmland.FarmlandState = FarmlandState.FARMLAND_STATE_GROW;
}
}
}
}
}
}
}
}

2
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);
}
}

1
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;

Loading…
Cancel
Save