zerodowned

Moderator
So, looking at the Houses code I see this

public class SmallOldHouse : BaseHouse
{
public static Rectangle2D[] AreaArray = new Rectangle2D[] { new Rectangle2D(-3,-3,7,7), new Rectangle2D(-1, 4, 3, 1) };

If I understand correctly, 2 sets of braces and four numbers in each set means it's creating an area that's 2 rows and 4 columns ?
But that doesn't match up with the size of the house.

So my confusion lies in the learning of C# and applying it to ServUO code. Not neccesarily houses, just trying to apply what I'm learning as I go so it makes more sense.

Any help would be awesome.
 
I'm not familiar enough with the code yet to explain how it works in regard to houses, but I can explain the c# code.

What you have here is an array which contains 2 Rectangle2D objects. This array is called AreaArray.
The code is creating the array and adding 2 elements to it at the same time. To simplify:

Create an array which can hold 2 Rectangle2D objects.
Code:
Rectangle2D[] AreaArray = new Rectangle2D[2];

Add a Rectangle2D object. This rectangle has a top left point at co-ordinates -3,-3, and has a width and height of 7. I assume this rectangle represents an area.
Code:
AreaArray[0] = new Rectangle2D(-3,-3,7,7);

Add another Rectangle to represent a different area
Code:
AreaArray[1] = new rectangle2D(-1,4,3,1);

The code you posted does the same as I have done above but in a less verbose form. It uses an object initialiser to add rectangles to the array in the same statement as creating the array.
  1. Code:
    Rectangle2D[] AreaArray = new Rectangle2D[] { new Rectangle2D(-3,-3,7,7), new Rectangle2D(-1, 4, 3, 1) };
Edit: Having had a quick glance through the code, it looks like this AreaArray defines the footprint of the house using one or more rectangles. This is used to determine where the house region starts / ends.
 
Last edited:
If I remember right, the Rect was original code to define the house region. And somewhere around beta 30's they (Krrios/Zippy) changed it to detect the house foundation somehow, and the rect became useless. I really never looked into the code much to see what was changed, where or how, though
 
@Sir Criesalot
I'm not sure i understand
Add a Rectangle2D object. This rectangle has a top left point at co-ordinates -3,-3, and has a width and height of 7. I assume this rectangle represents an area.
you're referring to a right triangle? two of those facing opposite directions makes a square

@Dian
i see what you mean. looking through basehouse and houseplacementtool.
 
Yeah, I know thats not why you posted, you were just wanting to understand the code more than anything.. but I figured it was relevant :)
 
I had created soe 50+ custom houses, added them to Multi.mul/idx years and years ago, and had to actually create those rect areas for each of them.. to be placed as deeds for players..

The one thing you really want to understand now, is the actual placement target. If you do not get the target correct, you will have the house shadow showing in one place, but when you click to place the house, it will be no where near where the shadow house showed it to be. I had a heck of a time understanding that part, more than anything. Just a heads up :)
 
@Sir Criesalot
I'm not sure i understand

you're referring to a right triangle? two of those facing opposite directions makes a square

Not quite. Each Rectangle2D object is an individual rectangle. In order to define a rectangle you only need 3 pieces of information - The position of the top left corner, and the width and height of the rectangle.

Code:
AreaArray[0] = new Rectangle2D(-3, -3, 7, 7);

This is the first rectangle. There are 4 parameters to the Rectangle2D constructor: -3, -3, 7, 7.
The first parameter, -3, is the x co-ordinate of the top left corner of the rectangle.
The seconds parameter, -3, is the y co-ordinate of the top left corner of the rectangle.

If we plot these co-ordinates on a graph, this is the top left corner of our rectangle.
ai32.photobucket.com_albums_d34_davidmsut_grid1_zpsf6628f01.png

The third parameter, 7 is the width of the rectangle.
The fourth parameter, 7, is the height of the rectangle.

Since the rectangle has a width of 7, we can deduce that the top right of the rectangle is at co-ordinate (-3 + 7, -3) == (4, -3).

The rectangle has a height of 7, we can deduce that the bottom left corner of the rectangle is at co-ordinate (-3, -3 + 7) == (-3, 4).
The bottom right corner of the rectangle is at co-ordinates (-3 +7, -3 + 7) == (4, 4)

Adding these 3 points on the graph gives us the corners of our rectangle.
ai32.photobucket.com_albums_d34_davidmsut_grid2_zps753f0079.png


The second Rectangle in the AreaArray is this:
Code:
AreaArray[1] = new Rectangle2D(-1, 4, 3, 1);

This is a rectangle with the top left corner at co-ordinates (-1, 4).
ai32.photobucket.com_albums_d34_davidmsut_grid3_zpsbbd02045.png
This rectangle will be plotted in blue, to differentiate it from the previous rectangle.

The rectangle has a width of 3, and a height of 1.
ai32.photobucket.com_albums_d34_davidmsut_grid4_zpscbddaa50.png

And that is it. The 2 rectangles in the AreaArray define the floor footprint of the house. The larger rectangle is the main house, the smaller one is the porch / step at the front of the house.
 
ugh, where did i get triangle from?! RECTANGLE! *face palm* lol

ok, this makes way more sense now.
i hate being a visual learner.

and thank you, that helped a lot.



@Dian and thank you for the heads up. definitely one of those small problems that could drive a person crazy until they figure out what's causing the problem.
 

Active Shards

Donations

Total amount
$0.00
Goal
$1,000.00
Back