/// <summary> /// This method will lay claim to a plot of land in the city map. Find the associated /// plot in the internal plot list and claim it, if the plot is not found then add it /// to the list. /// </summary> /// <param name="x">The desired x position of the sw corner of the plot.</param> /// <param name="y">The desired y position of the sw corner of the plot.</param> /// <param name="width">The desired width of the plot, x+width = x position for ne corner.</param> /// <param name="depth">The desired depth of the plot, y+depth = y position for ne corner.</param> /// <param name="val">The type of plot this is, ie does it have a building, road, etc on it.</param> public bool ClaimPlot(BuildingPlot plot) { if (plot.Equals(null)) { return(false); } if (isPlotClaimed(plot)) { return(false); } // Search the list. if (cityPlots.Count > 0) { foreach (BuildingPlot p in cityPlots) { if (p.Equals(plot)) { if (p.PlotClaimType == PlotClaimType.CLAIM_NONE) { p.PlotClaimType = PlotClaimType.CLAIM_PARK; } return(true); } } } // If we are here then the plot has not been found so add it as new plot. cityPlots.Add(plot); return(true); }
public override IDataTransferable Duplicate() { BuildingPlot plot = new BuildingPlot(); plot.Duplicate(); return((IDataTransferable)plot); }
// PLOT CONTROL /// <summary> /// Constructs a building plot for a given position, size and claim type, does not /// alter any internal properties, this is just a helper method that allows you to /// create building plots quickly for use as parameters to other internal/external /// methods that the class provides. /// </summary> /// <param name="x"></param> /// <param name="y"></param> /// <param name="w"></param> /// <param name="d"></param> /// <param name="flags"></param> /// <returns></returns> public BuildingPlot MakePlot(int x, int y, int w, int d, PlotClaimType flags) { BuildingPlot plot = new BuildingPlot(); plot.XPos = x; plot.YPos = y; plot.Width = w; plot.Depth = d; plot.PlotClaimType = flags; return(plot); }
// PLOT CONTROL /// <summary> /// Constructs a building plot for a given position, size and claim type, does not /// alter any internal properties, this is just a helper method that allows you to /// create building plots quickly for use as parameters to other internal/external /// methods that the class provides. /// </summary> /// <param name="x"></param> /// <param name="y"></param> /// <param name="w"></param> /// <param name="d"></param> /// <param name="flags"></param> /// <returns></returns> public BuildingPlot MakePlot(int x, int y, int w, int d, PlotClaimType flags) { BuildingPlot plot = new BuildingPlot(); plot.xpos = x; plot.ypos = y; plot.width = (byte)w; plot.depth = (byte)d; plot.plotFlags = flags; return(plot); }
/// <summary> /// /// </summary> /// <param name="plot"></param> private void doBuilding() { // Construct a random building and place it into the buildings list. CityBuilding building; BuildingType type = BuildingType.BUILDING_CIVIL | BuildingType.BUILDING_GENERAL; BuildingFlags flags = BuildingFlags.BUILDING_FLAG_ACOND | BuildingFlags.BUILDING_FLAG_LIGHTS | BuildingFlags.BUILDING_FLAG_LOGO | BuildingFlags.BUILDING_FLAG_TRIM; BuildingPlot plot = new BuildingPlot(); plot.xpos = randomValue(256) / 4; plot.ypos = randomValue(256) / 4; plot.width = (byte)randomValue(10); plot.depth = (byte)randomValue(10); plot.plotFlags = PlotClaimType.CLAIM_BUILDING | PlotClaimType.CLAIM_COMPLEX; building = new CityBuilding(type, plot, flags, UUID.Zero, cityMap.centralRegions[0], "Building"); }
/// <summary> /// Determines if the plot specified has been claimed already or not. /// </summary> /// <param name="plot"></param> /// <returns></returns> public bool isPlotClaimed(BuildingPlot plot) { // For each entry in the city plots list determine if the plot // given as a parameter is allocated to another building, the road // network etc. foreach (BuildingPlot p in cityPlots) { if (plot.XPos >= p.XPos && plot.YPos >= p.YPos && (plot.XPos + plot.Width <= p.XPos + p.Width) && (plot.YPos + plot.Depth <= p.YPos + p.Depth)) { // Plot specified is in this plots area. Determine if it has been // claimed for anything other than part of a complex. if (p.PlotClaimType == PlotClaimType.CLAIM_NONE) { return(false); } } } // Defaults to returning true to indicate whether regardless of whether the // plot is actually claimed or not, safety fall through. return(true); }
// PLOT CONTROL /// <summary> /// Constructs a building plot for a given position, size and claim type, does not /// alter any internal properties, this is just a helper method that allows you to /// create building plots quickly for use as parameters to other internal/external /// methods that the class provides. /// </summary> /// <param name="x"></param> /// <param name="y"></param> /// <param name="w"></param> /// <param name="d"></param> /// <param name="flags"></param> /// <returns></returns> public BuildingPlot MakePlot(int x, int y, int w, int d, PlotClaimType flags) { BuildingPlot plot = new BuildingPlot(); plot.XPos = x; plot.YPos = y; plot.Width = w; plot.Depth = d; plot.PlotClaimType = flags; return (plot); }
/// <summary> /// Determines if the plot specified has been claimed already or not. /// </summary> /// <param name="plot"></param> /// <returns></returns> public bool isPlotClaimed(BuildingPlot plot) { // For each entry in the city plots list determine if the plot // given as a parameter is allocated to another building, the road // network etc. foreach (BuildingPlot p in cityPlots) { if (plot.XPos >= p.XPos && plot.YPos >= p.YPos && (plot.XPos + plot.Width <= p.XPos + p.Width) && (plot.YPos + plot.Depth <= p.YPos + p.Depth)) { // Plot specified is in this plots area. Determine if it has been // claimed for anything other than part of a complex. if (p.PlotClaimType == PlotClaimType.CLAIM_NONE) return (false); } } // Defaults to returning true to indicate whether regardless of whether the // plot is actually claimed or not, safety fall through. return (true); }
/// <summary> /// This method will lay claim to a plot of land in the city map. Find the associated /// plot in the internal plot list and claim it, if the plot is not found then add it /// to the list. /// </summary> /// <param name="x">The desired x position of the sw corner of the plot.</param> /// <param name="y">The desired y position of the sw corner of the plot.</param> /// <param name="width">The desired width of the plot, x+width = x position for ne corner.</param> /// <param name="depth">The desired depth of the plot, y+depth = y position for ne corner.</param> /// <param name="val">The type of plot this is, ie does it have a building, road, etc on it.</param> public bool ClaimPlot(BuildingPlot plot) { if (plot.Equals(null)) return (false); if (isPlotClaimed(plot)) return (false); // Search the list. if (cityPlots.Count > 0) { foreach (BuildingPlot p in cityPlots) { if (p.Equals(plot)) { if (p.PlotClaimType == PlotClaimType.CLAIM_NONE) p.PlotClaimType = PlotClaimType.CLAIM_PARK; return (true); } } } // If we are here then the plot has not been found so add it as new plot. cityPlots.Add(plot); return (true); }
/// <summary> /// /// </summary> /// <param name="plot"></param> private void doBuilding() { // Construct a random building and place it into the buildings list. CityBuilding building; BuildingType type = BuildingType.BUILDING_CIVIL | BuildingType.BUILDING_GENERAL; BuildingFlags flags = BuildingFlags.BUILDING_FLAG_ACOND | BuildingFlags.BUILDING_FLAG_LIGHTS | BuildingFlags.BUILDING_FLAG_LOGO | BuildingFlags.BUILDING_FLAG_TRIM; BuildingPlot plot = new BuildingPlot(); plot.xpos = randomValue(256) / 4; plot.ypos = randomValue(256) / 4; plot.width = (byte)randomValue(10); plot.depth = (byte)randomValue(10); plot.plotFlags = PlotClaimType.CLAIM_BUILDING | PlotClaimType.CLAIM_COMPLEX; building = new CityBuilding(type, plot, flags, UUID.Zero,cityMap.centralRegions[0],"Building"); }
// PLOT CONTROL /// <summary> /// Constructs a building plot for a given position, size and claim type, does not /// alter any internal properties, this is just a helper method that allows you to /// create building plots quickly for use as parameters to other internal/external /// methods that the class provides. /// </summary> /// <param name="x"></param> /// <param name="y"></param> /// <param name="w"></param> /// <param name="d"></param> /// <param name="flags"></param> /// <returns></returns> public BuildingPlot MakePlot(int x, int y, int w, int d, PlotClaimType flags) { BuildingPlot plot = new BuildingPlot(); plot.xpos = x; plot.ypos = y; plot.width = (byte)w; plot.depth = (byte)d; plot.plotFlags = flags; return (plot); }
/// <summary> /// Construct the building class instance from the given properties. /// </summary> /// <param name="type" type="BuildingType">type</param> /// <param name="plot">The plot of land this building stands on, note it might be bigger than the /// actual buildings footprint, for example if it is part of a larger complex, limit the size of /// buildings to have a footprint of no more than 100 square meters.</param> /// <param name="flags"></param> /// <param name="owner">The owner of the building either a user, or company (group of companies) own buildings.</param> /// <param name="seed"></param> /// <param name="height">The height in floors of the building, not each floor is approximately 3 meters in size /// and thus buildings are limited to a maximum height of 100 floors.</param> public CityBuilding( BuildingType type, BuildingPlot plot, BuildingFlags flags, UUID owner, IScene scene, string name ):base(owner,new Vector3(plot.xpos,21,plot.ypos), Quaternion.Identity, PrimitiveBaseShape.CreateBox(), name, scene) { // Start the process of constructing a building given the parameters specified. For // truly random buildings change the following value (6) too another number, this is // used to allow for the buildings to be fairly fixed during research and development. buildingSeed = 6; // TODO FIX ACCESS TO THE CityModule.randomValue(n) code. buildingType = type; buildingPlot = plot; buildingFlags = flags; // Has a valid owner been specified, if not use the default library owner (i think) of the zero uuid. if (!owner.Equals(UUID.Zero)) buildingOwner = owner; else buildingOwner = UUID.Zero; // Generate a unique value for this building and it's own group if it's part of a complex, // otherwise use the zero uuid for group (perhaps it should inherit from the city?) buildingUUID = UUID.Random(); buildingGUID = UUID.Random(); buildingCenter = new Vector3((plot.xpos + plot.width / 2), 21, (plot.ypos + plot.depth) / 2); if (name.Length > 0) buildingName = name; else buildingName = "Building" + type.ToString(); // Now that internal variables that are used by other methods have been set construct // the building based on the type, plot, flags and seed given in the parameters. switch (type) { case BuildingType.BUILDING_GENERAL: OpenSim.Framework.MainConsole.Instance.Output("Building Type GENERAL", log4net.Core.Level.Info); createBlocky(); break; case BuildingType.BUILDING_LOCALE: /* switch ( CityModule.randomValue(8) ) { case 0: OpenSim.Framework.MainConsole.Instance.Output("Locale general.", log4net.Core.Level.Info); createSimple(); break; case 1: OpenSim.Framework.MainConsole.Instance.Output("locale 1", log4net.Core.Level.Info); createBlocky(); break; } */ break; case BuildingType.BUILDING_CIVIL: createTower(); break; case BuildingType.BUILDING_MILITARY: break; case BuildingType.BUILDING_HEALTHCARE: break; case BuildingType.BUILDING_SPORTS: break; case BuildingType.BUILDING_ENTERTAINMENT: break; case BuildingType.BUILDING_EDUCATION: break; case BuildingType.BUILDING_RELIGIOUS: break; case BuildingType.BUILDING_MUSEUM: break; case BuildingType.BUILDING_POWERSTATION: break; case BuildingType.BUILDING_MINEOILGAS: break; case BuildingType.BUILDING_ZOOLOGICAL: break; case BuildingType.BUILDING_CEMETARY: break; case BuildingType.BUILDING_PRISON: break; case BuildingType.BUILDING_AGRICULTURAL: break; case BuildingType.BUILDING_RECREATION: break; default: createSimple(); break; } }
/// <summary> /// Construct the building class instance from the given properties. /// </summary> /// <param name="type" type="BuildingType">type</param> /// <param name="plot">The plot of land this building stands on, note it might be bigger than the /// actual buildings footprint, for example if it is part of a larger complex, limit the size of /// buildings to have a footprint of no more than 100 square meters.</param> /// <param name="flags"></param> /// <param name="owner">The owner of the building either a user, or company (group of companies) own buildings.</param> /// <param name="seed"></param> /// <param name="height">The height in floors of the building, not each floor is approximately 3 meters in size /// and thus buildings are limited to a maximum height of 100 floors.</param> public CityBuilding(BuildingType type, BuildingPlot plot, BuildingFlags flags, UUID owner, IScene scene, string name) : base(owner, new Vector3(plot.xpos, 21, plot.ypos), Quaternion.Identity, PrimitiveBaseShape.CreateBox(), name, scene) { // Start the process of constructing a building given the parameters specified. For // truly random buildings change the following value (6) too another number, this is // used to allow for the buildings to be fairly fixed during research and development. buildingSeed = 6; // TODO FIX ACCESS TO THE CityModule.randomValue(n) code. buildingType = type; buildingPlot = plot; buildingFlags = flags; // Has a valid owner been specified, if not use the default library owner (i think) of the zero uuid. if (!owner.Equals(UUID.Zero)) { buildingOwner = owner; } else { buildingOwner = UUID.Zero; } // Generate a unique value for this building and it's own group if it's part of a complex, // otherwise use the zero uuid for group (perhaps it should inherit from the city?) buildingUUID = UUID.Random(); buildingGUID = UUID.Random(); buildingCenter = new Vector3((plot.xpos + plot.width / 2), 21, (plot.ypos + plot.depth) / 2); if (name.Length > 0) { buildingName = name; } else { buildingName = "Building" + type.ToString(); } // Now that internal variables that are used by other methods have been set construct // the building based on the type, plot, flags and seed given in the parameters. switch (type) { case BuildingType.BUILDING_GENERAL: OpenSim.Framework.MainConsole.Instance.Output("Building Type GENERAL", log4net.Core.Level.Info); createBlocky(); break; case BuildingType.BUILDING_LOCALE: /* * switch ( CityModule.randomValue(8) ) * { * case 0: * OpenSim.Framework.MainConsole.Instance.Output("Locale general.", log4net.Core.Level.Info); * createSimple(); * break; * case 1: * OpenSim.Framework.MainConsole.Instance.Output("locale 1", log4net.Core.Level.Info); * createBlocky(); * break; * } */ break; case BuildingType.BUILDING_CIVIL: createTower(); break; case BuildingType.BUILDING_MILITARY: break; case BuildingType.BUILDING_HEALTHCARE: break; case BuildingType.BUILDING_SPORTS: break; case BuildingType.BUILDING_ENTERTAINMENT: break; case BuildingType.BUILDING_EDUCATION: break; case BuildingType.BUILDING_RELIGIOUS: break; case BuildingType.BUILDING_MUSEUM: break; case BuildingType.BUILDING_POWERSTATION: break; case BuildingType.BUILDING_MINEOILGAS: break; case BuildingType.BUILDING_ZOOLOGICAL: break; case BuildingType.BUILDING_CEMETARY: break; case BuildingType.BUILDING_PRISON: break; case BuildingType.BUILDING_AGRICULTURAL: break; case BuildingType.BUILDING_RECREATION: break; default: createSimple(); break; } }
public override IDataTransferable Duplicate() { BuildingPlot plot = new BuildingPlot(); plot.Duplicate(); return (IDataTransferable)plot; }