You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
97 lines
2.7 KiB
97 lines
2.7 KiB
namespace ET |
|
{ |
|
public class FarmlandDestroySystem : DestroySystem<Farmland> |
|
{ |
|
public override void Destroy(Farmland self) |
|
{ |
|
self.Parent.Parent.GetParent<Unit>().RemoveGrandChild(self.Id); |
|
} |
|
} |
|
|
|
public class FarmlandAwakeSystem : AwakeSystem<Farmland> |
|
{ |
|
public override void Awake(Farmland 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.CropCfgId = farmlandProto.CropCfgId; |
|
self.Duration = farmlandProto.Duration; |
|
self.ExProduct = farmlandProto.ExProduct; |
|
self.PlanCropCfgId = farmlandProto.PlantCfgId; |
|
self.FarmlandState = farmlandProto.FarmlandState; |
|
self.PeopleId = farmlandProto.PeopleId; |
|
} |
|
|
|
public static FarmlandProto ToMessage(this Farmland self) |
|
{ |
|
FarmlandProto proto = new FarmlandProto(); |
|
proto.id = self.Id; |
|
proto.CropCfgId = self.CropCfgId; |
|
proto.Duration = self.Duration; |
|
proto.ExProduct = self.ExProduct; |
|
proto.PlantCfgId = self.PlanCropCfgId; |
|
proto.FarmlandState = self.FarmlandState; |
|
proto.PeopleId = self.PeopleId; |
|
|
|
return proto; |
|
} |
|
|
|
public static void Plant(this Farmland self) |
|
{ |
|
self.Duration = 0; |
|
self.FarmlandState = FarmlandState.FARMLAND_STATE_GROW; |
|
self.ExProduct = 0; |
|
self.PeopleId = 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.CropCfgId = 0; |
|
self.ExProduct = 0; |
|
self.FarmlandState = FarmlandState.FARMLAND_STATE_FREE; |
|
self.PeopleId = 0; |
|
|
|
} |
|
|
|
public static void Seed(this Farmland self,int cropCfgId) |
|
{ |
|
self.CropCfgId = cropCfgId; |
|
self.FarmlandState = FarmlandState.FARMLAND_STATE_SEED; |
|
self.PlanCropCfgId = cropCfgId; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
} |