public MoveableNode GetNodeByDistance(bool furthest = false) { Ray mouseRay = Camera.main.ScreenPointToRay(Input.mousePosition); Vector3 clickPos = MoveItTool.RaycastMouseLocation(mouseRay); if (Vector3.Distance(StartNode.position, clickPos) < Vector3.Distance(EndNode.position, clickPos)) { if (furthest) { return(EndNode); } else { return(StartNode); } } else { if (furthest) { return(StartNode); } else { return(EndNode); } } }
// Constructor for FindIt object public CloneActionFindIt(PrefabInfo prefab) { m_oldSelection = selection; m_states.Clear(); Vector3 position = MoveItTool.RaycastMouseLocation(); InstanceState state = new InstanceState(); if (prefab is BuildingInfo) { state = new BuildingState { isSubInstance = false, isHidden = false, flags = Building.Flags.Completed }; state.Info.Prefab = prefab; InstanceID id = new InstanceID { Building = 1, Type = InstanceType.Building }; state.instance = new MoveableBuilding(id); } else if (prefab is PropInfo) { state = new PropState { fixedHeight = false, single = false, }; state.Info.Prefab = prefab; InstanceID id = new InstanceID { Prop = 1, Type = InstanceType.Prop }; state.instance = new MoveableProp(id); } else if (prefab is TreeInfo) { state = new TreeState { fixedHeight = false, single = false, }; state.Info.Prefab = prefab; InstanceID id = new InstanceID { Tree = 1, Type = InstanceType.Tree }; state.instance = new MoveableTree(id); } state.position = position; state.terrainHeight = position.y; m_states.Add(state); center = position; }