private void CreateExtractor(Player a_player, Map a_map, Vector3 a_position) { Extractor f_extractor = a_player.m_thingsAssets.CreateExtractor(a_position); f_extractor.m_builtTimer = f_extractor.m_requiredBuildTime + 1; Rectangle f_area = MathGameHelper.GetAreaRectangle(ref f_extractor.m_currentposition, ref f_extractor.m_size); WorldObject wo = a_map.GetWorldObject(ref f_area, WorldObjectType.SoL); f_extractor.m_currentposition = wo.m_position; a_player.AddVisibleThing(f_extractor, null, wo, 0); }
// test ///<summary> ///Returns any world object that is inside buildarea, ///used for instance by standard build if it's not looking for a WO to check that you're not building on a WO! ///</summary> internal WorldObject GetWorldObject(ref Rectangle a_buildArea) { foreach (WorldObject worldObject in m_worldObjects) { Rectangle f_woArea = MathGameHelper.GetAreaRectangle(ref worldObject.m_position, ref worldObject.m_size); //Intersect properly... if (MathGameHelper.RectanglesIntersects(ref a_buildArea, ref f_woArea)) { return(worldObject); } } return(null); }
///<summary> ///Returns a world object of a specific type on a specific area! ///</summary> public WorldObject GetWorldObject(ref Rectangle a_buildArea, WorldObjectType a_type) { foreach (WorldObject worldObject in m_worldObjects) { Rectangle f_woArea = MathGameHelper.GetAreaRectangle(ref worldObject.m_position, ref worldObject.m_size); if (MathGameHelper.RectanglesIntersects(ref a_buildArea, ref f_woArea) && a_type == worldObject.m_type) { if (worldObject.m_type == WorldObjectType.SoL) { if ((worldObject as SoL).m_taken) { return(null); } } return(worldObject); } } return(null); }