/// <summary> /// Create a field view at the given position. /// </summary> /// <param name="pos"></param> /// <returns></returns> public FieldView CreateFieldView(SceneObjectGroup so) { // We could register an existing field here if we wanted to. FieldView fv = new FieldView( m_controller, m_scene, new Field(so.RootPart.UUID, "FieldToDelete"), m_fieldViewScale, m_itemStoreView); fv.Initialize(so); lock (m_fieldViews) m_fieldViews.Add(fv.Uuid, fv); return fv; }
/// <summary> /// Create a field view at the given position. /// </summary> /// <param name="field"></param> /// <param name="pos"></param> /// <returns></returns> public FieldView CreateFieldView(Field f, Vector3 pos) { // m_log.InfoFormat("[WATER WARS]: Placing field {0} at {1}", name, pos); FieldView fv = new FieldView(m_controller, m_scene, f, m_fieldViewScale, m_itemStoreView); fv.Initialize(pos); lock (m_fieldViews) m_fieldViews.Add(fv.Uuid, fv); return fv; }
/// <summary> /// Change the specialization presentation of this buy point view /// </summary> /// <param name="assetType"></param> /// <param name="fields">Fields for which field views need to be created</param> public Dictionary <UUID, FieldView> ChangeSpecialization(AbstractGameAssetType assetType, List <Field> fields) { Dictionary <UUID, FieldView> fvs = new Dictionary <UUID, FieldView>(); string morphItemName = m_veSceneObjectNames[assetType]; ChangeSceneObject(m_itemStoreView, morphItemName); m_bp.Name = morphItemName; if (assetType != AbstractGameAssetType.None) { Vector3 p1, p2; WaterWarsUtils.FindSquareParcelCorners(m_bp.Location.Parcel, out p1, out p2); // m_log.InfoFormat("[WATER WARS]: Found corners of parcel at ({0}),({1})", p1, p2); int shortDimension = (int)Math.Floor(Math.Sqrt(fields.Count)); int longDimension = (int)Math.Ceiling((float)fields.Count / shortDimension); // m_log.InfoFormat("[WATER WARS]: Would space as [{0}][{1}]", shortDimension, longDimension); // XXX: For now, we're always going to short space the fields on the x axis // This shouldn't be a problem if all our regions are square but might start to look a bit odd if they // were different rectangular sizes // Adjust dimensions to leave a gap around the edges for the buypoint p1.X += 5; p1.Y += 5; p2.X -= 5; p2.Y -= 5; float xSpacing = (p2.X - p1.X) / (float)shortDimension; float ySpacing = (p2.Y - p1.Y) / (float)longDimension; List <Vector3> placementPoints = new List <Vector3>(); // for (int y = y1; y < y2; y += ySpacing) // { // for (float x = x1; x < x2; x += xSpacing) // { // placementPoints.Add(new Vector3(x, y, (float)heightHere + 0.1f)); // } // } for (int y = 0; y < longDimension; y++) { for (float x = 0; x < shortDimension; x++) { Vector3 spacing = new Vector3(x * xSpacing, y * ySpacing, 2f); placementPoints.Add(p1 + spacing); } } m_fieldViewScale = new Vector3(xSpacing, ySpacing, 0.1f); Vector3 placementAdjustment = new Vector3(xSpacing / 2, ySpacing / 2, 0); int i = 0; foreach (Vector3 v in placementPoints) { FieldView fv = CreateFieldView(fields[i++], v + placementAdjustment); fvs.Add(fv.RootPart.UUID, fv); } } else { lock (m_fieldViews) { foreach (FieldView fv in m_fieldViews.Values) { fv.Close(); } m_fieldViews.Clear(); } } return(fvs); }