LazyDuchess / OpenTS2

Open source re-implementation of The Sims 2 in Unity
Mozilla Public License 2.0
248 stars 19 forks source link

Initial implementation of lot architecture #52

Closed riperiperi closed 1 year ago

riperiperi commented 1 year ago

image

Adds support for:

TODO in future:

riperiperi commented 1 year ago

image

Fences also work on slopes. Since unity doesn't seem to support passing in a custom matrix to a transform, it has to build a skew out of three stacked transforms.

riperiperi commented 1 year ago

Added some basic support for Roofs. Right now it only covers the base game roofs.

image

image-1

image

image-1

TS2 builds roofs out of quarter tiles, each can be cut from four cardinal directions. Each roof is made up of a number of faces, which I've represented with RoofEdge. Each edge has a tilemap which represents what graphic should be used for each tile, all of which are stored in a 5x5 texture atlas in the top texture.

Roofs always delete tiles that are lower than them. I've added a simple case that does this when all tile corners are covered, but the interesting part is when grid-aligned roofs intersect. These have specific behaviours which precisely cut into other roof tiles, which make for some really clean roof geometry. Given certain types of intersection, an additional intersection layer is added to the tile. To prevent z-fighting, intersections where two faces are coplanar pick and choose which graphic is shown based on a priority system.

The diagonal roofs will work in a similar way, but they are not allowed to calculate intersections with the regular roofs - only each other. These aren't implemented yet, but hopefully shouldn't be too difficult.

The special roofs (dome, cone, curved) don't have any fancy intersection rules or graphics. They still need to be implemented, likely with custom geometry generators for each.

riperiperi commented 1 year ago

I've pushed a change to the lot testing controller that makes it a lot quicker to switch property without reloading all the game content. It can leave some game objects behind due to object scenegraphs failing, though. They tend to get stuck at the origin point.

Should make it easier to hop around and find issues. It also now loads all expansion content.

https://github.com/LazyDuchess/OpenTS2/assets/6294155/7f4c0af9-7395-4d36-ba3a-6feb4ca60a38

When any code changes are made, all game content seems to unload... which is unfortunate.

riperiperi commented 1 year ago

https://github.com/LazyDuchess/OpenTS2/assets/6294155/9bdfb2ba-57b1-419d-b84e-6e89acebf3fe

I think I've done enough to open the PR for review. There's a lot left to do, but this is getting big enough as is.

The next large step would probably be tools for editing or interaction from the simulator, such as checking wall adjacency for a tile. There are a bunch of smaller things I've listed on the PR body.