|
|
|
namespace ET
|
|
|
|
{
|
|
|
|
public class FarmlandDestroySystem : DestroySystem<Farmland>
|
|
|
|
{
|
|
|
|
public override void Destroy(Farmland self)
|
|
|
|
{
|
|
|
|
self.Parent.Parent.GetParent<Unit>().RemoveFarmland(self);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public class FarmlandAwakeSystem : AwakeSystem<Farmland>
|
|
|
|
{
|
|
|
|
public override void Awake(Farmland self)
|
|
|
|
{
|
|
|
|
self.Parent.Parent.GetParent<Unit>().AddFarmland(self);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public class FarmlandUpdateSystem: UpdateSystem<Farmland>
|
|
|
|
{
|
|
|
|
public override void Update(Farmland self)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
[FriendClass(typeof(Farmland))]
|
|
|
|
public static class FarmlandSystem
|
|
|
|
{
|
|
|
|
public static void FromMessage(this Farmland self, FarmlandProto farmlandProto)
|
|
|
|
{
|
|
|
|
self.Id = farmlandProto.id;
|
|
|
|
self.SeedCfgId = farmlandProto.SeedCfgId;
|
|
|
|
self.Duration = farmlandProto.duration;
|
|
|
|
self.ExProduct = farmlandProto.exProduct;
|
|
|
|
self.PlanSeedCfgId = farmlandProto.plantCfgId;
|
|
|
|
self.FarmlandState = farmlandProto.farmlandState;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static FarmlandProto ToMessage(this Farmland self)
|
|
|
|
{
|
|
|
|
FarmlandProto proto = new FarmlandProto();
|
|
|
|
proto.id = self.Id;
|
|
|
|
proto.SeedCfgId = self.SeedCfgId;
|
|
|
|
proto.duration = self.Duration;
|
|
|
|
proto.exProduct = self.ExProduct;
|
|
|
|
proto.plantCfgId = self.PlanSeedCfgId;
|
|
|
|
proto.farmlandState = self.FarmlandState;
|
|
|
|
return proto;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void Plant(this Farmland self)
|
|
|
|
{
|
|
|
|
self.Duration = 0;
|
|
|
|
self.FarmlandState = FarmlandState.FARMLAND_STATE_GROW;
|
|
|
|
self.ExProduct = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void Update(this Farmland self)
|
|
|
|
{
|
|
|
|
if (self.FarmlandState != FarmlandState.FARMLAND_STATE_GROW)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
self.Duration += 1;
|
|
|
|
if (self.Duration >= self.Config.GrowthCycle)
|
|
|
|
{
|
|
|
|
self.FarmlandState = FarmlandState.FARMLAND_STATE_RIPE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void Harvest(this Farmland self)
|
|
|
|
{
|
|
|
|
self.Duration = 0;
|
|
|
|
self.SeedCfgId = 0;
|
|
|
|
self.PlanSeedCfgId = 0;
|
|
|
|
self.ExProduct = 0;
|
|
|
|
self.FarmlandState = FarmlandState.FARMLAND_STATE_FREE;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void Seed(this Farmland self,int seedCfgId)
|
|
|
|
{
|
|
|
|
self.SeedCfgId = seedCfgId;
|
|
|
|
self.FarmlandState = FarmlandState.FARMLAND_STATE_SEED;
|
|
|
|
self.PlanSeedCfgId = seedCfgId;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|