private void Start() { _building = GetComponent <BuildingScript>(); _building.SetState(BuildingState.Placing); _conditions = new List <IPlaceBuildingCondition>(); Rigidbody rb = gameObject.AddComponent <Rigidbody>(); rb.freezeRotation = true; }
private void PlaceBuilding() { //clear all place conditions foreach (var placeBuildingCondition in _conditions) { Destroy(placeBuildingCondition as Component); } //clear conditions collection _conditions.Clear(); _conditions = null; //remove Rigidbody added at start Rigidbody rb = gameObject.GetComponent <Rigidbody>(); Destroy(rb); _building.SetState(BuildingState.Active); //remove this script from gameObject Destroy(this); }