using System; namespace ET { public static class CabinHelper { public static async ETTask GoCabin(Unit unit,People people,Cabin cabin) { try { C2M_GoCabin msg = new C2M_GoCabin() { PeopleId = people.Id,CabinId = cabin.Id}; M2C_GoCabin resp = await unit.ZoneScene().GetComponent().Session.Call(msg) as M2C_GoCabin; if (resp.Error == ErrorCode.ERR_Success) { cabin.PeoplePrepare(people.Id); PeopleOperate.ChangeBehave(unit, people, ConstBehaveType.BEHAVE_PREPARE_CABIN, cabin.Id); } else { Log.Error(resp.Error.ToString()); } return resp.Error; } catch (Exception e) { Log.Error(e.ToString()); throw; } } public static async ETTask ArriveCabin(Unit unit,People people,Cabin cabin) { try { C2M_ArriveCabin msg = new C2M_ArriveCabin() { PeopleId = people.Id,CabinId = cabin.Id}; M2C_ArriveCabin resp = await unit.ZoneScene().GetComponent().Session.Call(msg) as M2C_ArriveCabin; if (resp.Error == ErrorCode.ERR_Success) { cabin.PeopleArrive(people.Id); people.SetBehaveType(ConstBehaveType.BEHAVE_CABIN); } else { Log.Error(resp.Error.ToString()); } return resp.Error; } catch (Exception e) { Log.Error(e.ToString()); throw; } } public static async ETTask AddFarmland(Unit unit,Cabin cabin,Farmland farmland) { try { C2M_CabinAddFarmland msg = new C2M_CabinAddFarmland() { CabinId = cabin.Id,FarmlandId = farmland.Id}; M2C_CabinAddFarmland resp = await unit.ZoneScene().GetComponent().Session.Call(msg) as M2C_CabinAddFarmland; if (resp.Error == ErrorCode.ERR_Success) { cabin.AddFarmland(farmland.Id); farmland.SetCabinId(cabin.Id); } else { Log.Error(resp.Error.ToString()); } return resp.Error; } catch (Exception e) { Log.Error(e.ToString()); throw; } } public static async ETTask CabinSeed(Unit unit,Farmland farmland,int cropCfgId) { try { C2M_CabinSeed msg = new C2M_CabinSeed() { CropCfgId = cropCfgId,FarmlandId = farmland.Id}; M2C_CabinSeed resp = await unit.ZoneScene().GetComponent().Session.Call(msg) as M2C_CabinSeed; if (resp.Error == ErrorCode.ERR_Success) { FarmlandOperate.FarmlandSeed(unit, farmland, cropCfgId); } else { Log.Error(resp.Error.ToString()); } return resp.Error; } catch (Exception e) { Log.Error(e.ToString()); throw; } } } }