public void CheckValidity() { //Find weaver (might not exist) if (weaver == null) { weaver = GetComponent <RoadWeaver>(); } //Check for terrain if (!CheckWorldObstacles()) { SetInvalid(); return; } //Ask the weaver whether there is a valid road next to this station if (weaver != null && !weaver.ShouldWeave()) { //Weaver didnt detect any SetInvalid(); return; } //Otherwise, it's ok SetValid(); }
//Attach powerstation weaver (Side for adjacent road weaving) void AttachWeaver(GameObject obj, Side direction) { current.AddComponent <RoadValidityChecker>(); RoadWeaver w = current.AddComponent <RoadWeaver>(); w.direction = direction; }