using UnityEngine; namespace ET { public class FarmlandViewComponentAwakeSystem: AwakeSystem { public override void Awake(FarmlandViewComponent self) { self.Awake(); } } [FriendClass(typeof(FarmlandViewComponent))] [FriendClass(typeof(Farmland))] [FriendClass(typeof(Building))] [FriendClass(typeof(BuildingViewComponent))] public static class FarmlandViewComponentSystem { public static void Awake(this FarmlandViewComponent self) { self.Farmland = self.GetParent(); self.SeedCropPrfb = self.LoadAssetSync("Sprout".ToPrefabAddress()); self.RipeCropPrfb = self.LoadAssetSync("Wheat".ToPrefabAddress()); self.UpdateByState(); } public static void UpdateByState(this FarmlandViewComponent self) { var building = self.Farmland.GetParent(); var buildingView = building.GetComponent(); if (self.FarmlandRoot != null) { Util.GameObjectPoolHelper.ReturnObjectToPool(self.FarmlandRoot); } switch (self.Farmland.FarmlandState) { case FarmlandState.FARMLAND_STATE_FREE: case FarmlandState.FARMLAND_STATE_SEED: break; case FarmlandState.FARMLAND_STATE_GROW: self.FarmlandRoot = Util.GameObjectPoolHelper.SpawnGameObject(self.SeedCropPrfb); self.FarmlandRoot.transform.position = buildingView.GetCenterPos(); self.FarmlandRoot.transform.parent = buildingView.BuildingRoot.transform; break; case FarmlandState.FARMLAND_STATE_RIPE: self.FarmlandRoot = Util.GameObjectPoolHelper.SpawnGameObject(self.RipeCropPrfb); self.FarmlandRoot.transform.position = buildingView.GetCenterPos(); self.FarmlandRoot.transform.parent = buildingView.BuildingRoot.transform; break; } } } }