public override void SetUp() { base.SetUp(); m_pcm = new PrimCountModule(); LandManagementModule lmm = new LandManagementModule(); m_scene = new SceneHelpers().SetupScene(); SceneHelpers.SetupSceneModules(m_scene, lmm, m_pcm); int xParcelDivider = (int)Constants.RegionSize - 1; ILandObject lo = new LandObject(m_userId, false, m_scene); lo.LandData.Name = "m_lo"; lo.SetLandBitmap( lo.GetSquareLandBitmap(0, 0, xParcelDivider, (int)Constants.RegionSize)); m_lo = lmm.AddLandObject(lo); ILandObject lo2 = new LandObject(m_userId, false, m_scene); lo2.SetLandBitmap( lo2.GetSquareLandBitmap(xParcelDivider, 0, (int)Constants.RegionSize, (int)Constants.RegionSize)); lo2.LandData.Name = "m_lo2"; m_lo2 = lmm.AddLandObject(lo2); }
protected ILandObject GetNoLand() { ILandObject obj = new LandObject(UUID.Zero, false, m_scene); obj.LandData.Name = "NO LAND"; return(obj); }
private void SetupDefaultParcel() { ILandObject obj = new LandObject(UUID.Zero, false, m_scene); obj.LandData.Name = "Your Parcel"; m_parcels.Add(obj); }
public void TestSubdivide() { TestHelpers.InMethod(); // TestHelpers.EnableLogging(); UUID userId = TestHelpers.ParseTail(0x1); LandManagementModule lmm = new LandManagementModule(); Scene scene = new SceneHelpers().SetupScene(); SceneHelpers.SetupSceneModules(scene, lmm); ILandObject lo = new LandObject(userId, false, scene); lo.LandData.Name = "lo1"; lo.SetLandBitmap( lo.GetSquareLandBitmap(0, 0, (int)Constants.RegionSize, (int)Constants.RegionSize)); lo = lmm.AddLandObject(lo); lmm.Subdivide(0, 0, LandManagementModule.LandUnit, LandManagementModule.LandUnit, userId); { ILandObject loAtCoord = lmm.GetLandObject(0, 0); Assert.That(loAtCoord.LandData.LocalID, Is.Not.EqualTo(lo.LandData.LocalID)); Assert.That(loAtCoord.LandData.GlobalID, Is.Not.EqualTo(lo.LandData.GlobalID)); } { ILandObject loAtCoord = lmm.GetLandObject(LandManagementModule.LandUnit, LandManagementModule.LandUnit); Assert.That(loAtCoord.LandData.LocalID, Is.EqualTo(lo.LandData.LocalID)); Assert.That(loAtCoord.LandData.GlobalID, Is.EqualTo(lo.LandData.GlobalID)); } }
public void TestLoadWithSinglePartialCoveringParcel() { TestHelpers.InMethod(); // TestHelpers.EnableLogging(); UUID userId = TestHelpers.ParseTail(0x1); SceneHelpers sh = new SceneHelpers(); LandManagementModule lmm = new LandManagementModule(); Scene scene = sh.SetupScene(); SceneHelpers.SetupSceneModules(scene, lmm); ILandObject originalLo1 = new LandObject(userId, false, scene); originalLo1.LandData.Name = "lo1"; originalLo1.SetLandBitmap( originalLo1.GetSquareLandBitmap(0, 0, (int)Constants.RegionSize, (int)Constants.RegionSize / 2)); sh.SimDataService.StoreLandObject(originalLo1); scene.loadAllLandObjectsFromStorage(scene.RegionInfo.RegionID); ILandObject loAtCoord1 = lmm.GetLandObject(0, 0); Assert.That(loAtCoord1.LandData.Name, Is.EqualTo(originalLo1.LandData.Name)); Assert.That(loAtCoord1.LandData.GlobalID, Is.EqualTo(originalLo1.LandData.GlobalID)); ILandObject loAtCoord2 = lmm.GetLandObject((int)Constants.RegionSize - 1, ((int)Constants.RegionSize - 1)); Assert.That(loAtCoord2.LandData.LocalID, Is.EqualTo(loAtCoord1.LandData.LocalID)); Assert.That(loAtCoord2.LandData.GlobalID, Is.EqualTo(loAtCoord1.LandData.GlobalID)); }
public void Clear(bool setupDefaultParcel) { m_parcels.Clear(); if (setupDefaultParcel) { ILandObject obj = new LandObject(UUID.Zero, false, m_scene); obj.LandData.Name = "Your Parcel"; m_parcels.Add(obj); } }
public static void CreateMyAsset() { LandObject asset = ScriptableObject.CreateInstance <LandObject>(); AssetDatabase.CreateAsset(asset, "Assets/LandData.asset"); AssetDatabase.SaveAssets(); EditorUtility.FocusProjectWindow(); Selection.activeObject = asset; }
public void TestAddLandObject() { TestHelpers.InMethod(); // TestHelpers.EnableLogging(); UUID userId = TestHelpers.ParseTail(0x1); LandManagementModule lmm = new LandManagementModule(); Scene scene = new SceneHelpers().SetupScene(); SceneHelpers.SetupSceneModules(scene, lmm); ILandObject lo = new LandObject(userId, false, scene); lo.LandData.Name = "lo1"; lo.SetLandBitmap( lo.GetSquareLandBitmap(0, 0, (int)Constants.RegionSize, (int)Constants.RegionSize)); lo = lmm.AddLandObject(lo); // TODO: Should add asserts to check that land object was added properly. // At the moment, this test just makes sure that we can't add a land object that overlaps the areas that // the first still holds. ILandObject lo2 = new LandObject(userId, false, scene); lo2.SetLandBitmap( lo2.GetSquareLandBitmap(0, 0, (int)Constants.RegionSize, (int)Constants.RegionSize)); lo2.LandData.Name = "lo2"; lo2 = lmm.AddLandObject(lo2); { ILandObject loAtCoord = lmm.GetLandObject(0, 0); Assert.That(loAtCoord.LandData.LocalID, Is.EqualTo(lo.LandData.LocalID)); Assert.That(loAtCoord.LandData.GlobalID, Is.EqualTo(lo.LandData.GlobalID)); } { ILandObject loAtCoord = lmm.GetLandObject((int)Constants.RegionSize - 1, ((int)Constants.RegionSize - 1)); Assert.That(loAtCoord.LandData.LocalID, Is.EqualTo(lo.LandData.LocalID)); Assert.That(loAtCoord.LandData.GlobalID, Is.EqualTo(lo.LandData.GlobalID)); } }
public void SetUp() { m_pcm = new PrimCountModule(); LandManagementModule lmm = new LandManagementModule(); m_scene = SceneHelpers.SetupScene(); SceneHelpers.SetupSceneModules(m_scene, lmm, m_pcm); int xParcelDivider = (int)Constants.RegionSize - 1; ILandObject lo = new LandObject(m_userId, false, m_scene); lo.LandData.Name = "m_lo"; lo.SetLandBitmap( lo.GetSquareLandBitmap(0, 0, xParcelDivider, (int)Constants.RegionSize)); m_lo = lmm.AddLandObject(lo); ILandObject lo2 = new LandObject(m_userId, false, m_scene); lo2.SetLandBitmap( lo2.GetSquareLandBitmap(xParcelDivider, 0, (int)Constants.RegionSize, (int)Constants.RegionSize)); lo2.LandData.Name = "m_lo2"; m_lo2 = lmm.AddLandObject(lo2); }
public virtual void SetUp() { lo1 = new LandObject(UUID.Zero, false, null); lo2 = new LandObject(UUID.Zero, false, null); lo3 = new LandObject(UUID.Zero, false, null); bp1 = null; bp2 = null; bp3 = null; p1 = null; p2 = null; c1 = null; h1 = null; h2 = null; h3 = null; m_controller = CreateController(); m_mockDispatcher = new MockDispatcher(m_controller); m_mockDispatcher.Configuration = @" [General] start_date = 11/2/1904 seconds_per_stage = 0 rounds_per_game = 10 water_delivery_series = 1 [Players] manufacturer_start_money = 17000 developer_start_money = 16000 farmer_start_money = 15000 manufacturer_cost_of_living = 0 developer_cost_of_living = 0 farmer_cost_of_living = 0 [Parcels] rights_price = 350 water_entitlement = 1000 hill_zone_rights_price = 500 hill_zone_water_entitlement = 300 river_zone_rights_price = 1000 river_zone_water_entitlement = 900 [Crops] alfalfa_cost_per_build_step = 50 chillis_cost_per_build_step = 30 grapes_cost_per_build_step = 80 alfalfa_build_steps = 1; chillis_build_steps = 1; grapes_build_steps = 1; alfalfa_revenue = 100 chillis_revenue = 100 grapes_revenue = 40 alfalfa_maintenance = 0 chillis_maintenance = 0 grapes_maintenance = 0 alfalfa_water = 200 chillis_water = 500 grapes_water = 100 [Condos] condos_1_cost_per_build_step = 50 condos_2_cost_per_build_step = 90 condos_3_cost_per_build_step = 120 condos_1_build_steps = 2; condos_2_build_steps = 2; condos_3_build_steps = 2; condos_1_revenue = 150 condos_2_revenue = 200 condos_3_revenue = 250 condos_1_revenue_series = 1 condos_2_revenue_series = 1 condos_3_revenue_series = 1 condos_1_maintenance = 5 condos_2_maintenance = 4 condos_3_maintenance = 3 condos_1_water = 10 condos_2_water = 18 condos_3_water = 24 [Factories] factories_1_cost_per_build_step = 5000 factories_2_cost_per_build_step = 7000 factories_3_cost_per_build_step = 9000 factories_1_build_steps = 1 factories_2_build_steps = 1 factories_3_build_steps = 1 factories_1_revenue = 2000 factories_2_revenue = 3000 factories_3_revenue = 4000 factories_revenue_series = 1 factories_1_maintenance = 500 factories_2_maintenance = 700 factories_3_maintenance = 900 factories_1_water = 1000 factories_2_water = 800 factories_3_water = 600"; m_controller.Dispatcher = m_mockDispatcher; m_controller.Initialise(false); }
public XmlNode RequestSnapshotData(XmlDocument nodeFactory) { XmlNode parent = nodeFactory.CreateNode(XmlNodeType.Element, "parceldata", ""); ILandChannel landChannel = m_scene.LandChannel; if (landChannel == null) { return(parent); } List <ILandObject> parcels = landChannel.AllParcels(); IDwellModule dwellModule = m_scene.RequestModuleInterface <IDwellModule>(); if (parcels != null) { //foreach (KeyValuePair<int, Land> curParcel in m_landIndexed) foreach (ILandObject parcel_interface in parcels) { // Play it safe if (!(parcel_interface is LandObject)) { continue; } LandObject land = (LandObject)parcel_interface; LandData parcel = land.LandData; if (m_parent.ExposureLevel.Equals("all") || (m_parent.ExposureLevel.Equals("minimum") && (parcel.Flags & (uint)ParcelFlags.ShowDirectory) == (uint)ParcelFlags.ShowDirectory)) { //TODO: make better method of marshalling data from LandData to XmlNode XmlNode xmlparcel = nodeFactory.CreateNode(XmlNodeType.Element, "parcel", ""); // Attributes of the parcel node XmlAttribute scripts_attr = nodeFactory.CreateAttribute("scripts"); scripts_attr.Value = GetScriptsPermissions(parcel); XmlAttribute build_attr = nodeFactory.CreateAttribute("build"); build_attr.Value = GetBuildPermissions(parcel); XmlAttribute public_attr = nodeFactory.CreateAttribute("public"); public_attr.Value = GetPublicPermissions(parcel); // Check the category of the Parcel XmlAttribute category_attr = nodeFactory.CreateAttribute("category"); category_attr.Value = ((int)parcel.Category).ToString(); // Check if the parcel is for sale XmlAttribute forsale_attr = nodeFactory.CreateAttribute("forsale"); forsale_attr.Value = CheckForSale(parcel); XmlAttribute sales_attr = nodeFactory.CreateAttribute("salesprice"); sales_attr.Value = parcel.SalePrice.ToString(); XmlAttribute directory_attr = nodeFactory.CreateAttribute("showinsearch"); directory_attr.Value = GetShowInSearch(parcel); //XmlAttribute entities_attr = nodeFactory.CreateAttribute("entities"); //entities_attr.Value = land.primsOverMe.Count.ToString(); xmlparcel.Attributes.Append(directory_attr); xmlparcel.Attributes.Append(scripts_attr); xmlparcel.Attributes.Append(build_attr); xmlparcel.Attributes.Append(public_attr); xmlparcel.Attributes.Append(category_attr); xmlparcel.Attributes.Append(forsale_attr); xmlparcel.Attributes.Append(sales_attr); //xmlparcel.Attributes.Append(entities_attr); //name, description, area, and UUID XmlNode name = nodeFactory.CreateNode(XmlNodeType.Element, "name", ""); name.InnerText = parcel.Name; xmlparcel.AppendChild(name); XmlNode desc = nodeFactory.CreateNode(XmlNodeType.Element, "description", ""); desc.InnerText = parcel.Description; xmlparcel.AppendChild(desc); XmlNode uuid = nodeFactory.CreateNode(XmlNodeType.Element, "uuid", ""); uuid.InnerText = parcel.GlobalID.ToString(); xmlparcel.AppendChild(uuid); XmlNode area = nodeFactory.CreateNode(XmlNodeType.Element, "area", ""); area.InnerText = parcel.Area.ToString(); xmlparcel.AppendChild(area); //default location XmlNode tpLocation = nodeFactory.CreateNode(XmlNodeType.Element, "location", ""); Vector3 loc = parcel.UserLocation; if (loc.Equals(Vector3.Zero)) // This test is moot at this point: the location is wrong by default { loc = new Vector3((parcel.AABBMax.X + parcel.AABBMin.X) / 2, (parcel.AABBMax.Y + parcel.AABBMin.Y) / 2, (parcel.AABBMax.Z + parcel.AABBMin.Z) / 2); } tpLocation.InnerText = loc.X.ToString() + "/" + loc.Y.ToString() + "/" + loc.Z.ToString(); xmlparcel.AppendChild(tpLocation); XmlNode infouuid = nodeFactory.CreateNode(XmlNodeType.Element, "infouuid", ""); uint x = (uint)loc.X, y = (uint)loc.Y; findPointInParcel(land, ref x, ref y); // find a suitable spot infouuid.InnerText = Util.BuildFakeParcelID( m_scene.RegionInfo.RegionHandle, x, y).ToString(); xmlparcel.AppendChild(infouuid); XmlNode dwell = nodeFactory.CreateNode(XmlNodeType.Element, "dwell", ""); if (dwellModule != null) { dwell.InnerText = dwellModule.GetDwell(parcel.GlobalID).ToString(); } else { dwell.InnerText = "0"; } xmlparcel.AppendChild(dwell); //TODO: figure how to figure out teleport system landData.landingType //land texture snapshot uuid if (parcel.SnapshotID != UUID.Zero) { XmlNode textureuuid = nodeFactory.CreateNode(XmlNodeType.Element, "image", ""); textureuuid.InnerText = parcel.SnapshotID.ToString(); xmlparcel.AppendChild(textureuuid); } string groupName = String.Empty; //attached user and group if (parcel.GroupID != UUID.Zero) { XmlNode groupblock = nodeFactory.CreateNode(XmlNodeType.Element, "group", ""); XmlNode groupuuid = nodeFactory.CreateNode(XmlNodeType.Element, "groupuuid", ""); groupuuid.InnerText = parcel.GroupID.ToString(); groupblock.AppendChild(groupuuid); IGroupsModule gm = m_scene.RequestModuleInterface <IGroupsModule>(); if (gm != null) { GroupRecord g = gm.GetGroupRecord(parcel.GroupID); if (g != null) { groupName = g.GroupName; } } XmlNode groupname = nodeFactory.CreateNode(XmlNodeType.Element, "groupname", ""); groupname.InnerText = groupName; groupblock.AppendChild(groupname); xmlparcel.AppendChild(groupblock); } XmlNode userblock = nodeFactory.CreateNode(XmlNodeType.Element, "owner", ""); UUID userOwnerUUID = parcel.OwnerID; XmlNode useruuid = nodeFactory.CreateNode(XmlNodeType.Element, "uuid", ""); useruuid.InnerText = userOwnerUUID.ToString(); userblock.AppendChild(useruuid); if (!parcel.IsGroupOwned) { try { XmlNode username = nodeFactory.CreateNode(XmlNodeType.Element, "name", ""); UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, userOwnerUUID); if (account != null) { username.InnerText = account.FirstName + " " + account.LastName; } else { username.InnerText = "UnKnown"; } userblock.AppendChild(username); } catch (Exception) { //m_log.Info("[DATASNAPSHOT]: Cannot find owner name; ignoring this parcel"); } } else { XmlNode username = nodeFactory.CreateNode(XmlNodeType.Element, "name", ""); username.InnerText = groupName; userblock.AppendChild(username); } xmlparcel.AppendChild(userblock); parent.AppendChild(xmlparcel); } } //snap.AppendChild(parent); } this.Stale = false; return(parent); }
public void TestLoadOarDeededLand() { TestHelpers.InMethod(); // TestHelpers.EnableLogging(); UUID landID = TestHelpers.ParseTail(0x10); MockGroupsServicesConnector groupsService = new MockGroupsServicesConnector(); IConfigSource configSource = new IniConfigSource(); IConfig config = configSource.AddConfig("Groups"); config.Set("Enabled", true); config.Set("Module", "GroupsModule"); config.Set("DebugEnabled", true); SceneHelpers.SetupSceneModules( m_scene, configSource, new object[] { new GroupsModule(), groupsService, new LandManagementModule() }); // Create group in scene for loading // FIXME: For now we'll put up with the issue that we'll get a group ID that varies across tests. UUID groupID = groupsService.CreateGroup(UUID.Zero, "group1", "", true, UUID.Zero, 3, true, true, true, UUID.Zero); // Construct OAR MemoryStream oarStream = new MemoryStream(); TarArchiveWriter tar = new TarArchiveWriter(oarStream); tar.WriteDir(ArchiveConstants.LANDDATA_PATH); tar.WriteFile( ArchiveConstants.CONTROL_FILE_PATH, new ArchiveWriteRequest(m_scene, (Stream)null, Guid.Empty).CreateControlFile(new ArchiveScenesGroup())); LandObject lo = new LandObject(groupID, true, m_scene); lo.SetLandBitmap(lo.BasicFullRegionLandBitmap()); LandData ld = lo.LandData; ld.GlobalID = landID; string ldPath = ArchiveConstants.CreateOarLandDataPath(ld); Dictionary <string, object> options = new Dictionary <string, object>(); tar.WriteFile(ldPath, LandDataSerializer.Serialize(ld, options)); tar.Close(); oarStream = new MemoryStream(oarStream.ToArray()); // Load OAR lock (this) { m_scene.EventManager.OnOarFileLoaded += LoadCompleted; m_archiverModule.DearchiveRegion(oarStream); } ILandObject rLo = m_scene.LandChannel.GetLandObject(16, 16); LandData rLd = rLo.LandData; Assert.That(rLd.GlobalID, Is.EqualTo(landID)); Assert.That(rLd.OwnerID, Is.EqualTo(groupID)); Assert.That(rLd.GroupID, Is.EqualTo(groupID)); Assert.That(rLd.IsGroupOwned, Is.EqualTo(true)); }
public void TestLoad() { TestHelpers.InMethod(); // TestHelpers.EnableLogging(); UUID userId = TestHelpers.ParseTail(0x1); SceneHelpers sh = new SceneHelpers(); LandManagementModule lmm = new LandManagementModule(); Scene scene = sh.SetupScene(); SceneHelpers.SetupSceneModules(scene, lmm); ILandObject originalLo1 = new LandObject(userId, false, scene); originalLo1.LandData.Name = "lo1"; originalLo1.SetLandBitmap( originalLo1.GetSquareLandBitmap(0, 0, (int)Constants.RegionSize, (int)Constants.RegionSize / 2)); sh.SimDataService.StoreLandObject(originalLo1); ILandObject originalLo2 = new LandObject(userId, false, scene); originalLo2.LandData.Name = "lo2"; originalLo2.SetLandBitmap( originalLo2.GetSquareLandBitmap(0, (int)Constants.RegionSize / 2, (int)Constants.RegionSize, (int)Constants.RegionSize)); sh.SimDataService.StoreLandObject(originalLo2); scene.loadAllLandObjectsFromStorage(scene.RegionInfo.RegionID); { ILandObject loAtCoord = lmm.GetLandObject(0, 0); Assert.That(loAtCoord.LandData.Name, Is.EqualTo(originalLo1.LandData.Name)); Assert.That(loAtCoord.LandData.GlobalID, Is.EqualTo(originalLo1.LandData.GlobalID)); } { ILandObject loAtCoord = lmm.GetLandObject((int)Constants.RegionSize - 1, ((int)Constants.RegionSize - 1)); Assert.That(loAtCoord.LandData.Name, Is.EqualTo(originalLo2.LandData.Name)); Assert.That(loAtCoord.LandData.GlobalID, Is.EqualTo(originalLo2.LandData.GlobalID)); } }