Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Build Mode Test Scene #57

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

JDrocks450
Copy link

@JDrocks450 JDrocks450 commented Jan 22, 2024

image

Build Mode Test Scene

This pull request implements the features detailed below in service of a build mode test scene environment allowing basic construction.

Loading Lot Architecture
This scene is based on the pre-existing work of loading a lot from file, with the advantage of now being able to edit the LotArchitecture on the fly through using build tools.

These changes are now in a new class called LotLoad.cs
LotLoad.cs allows for a lot to be loaded into the current scene as easily as:
image
Which will perform the behind the scenes tasks of:

  • Unloading the previous lot
  • Building the ContentProvider
  • Adding the lot package to the content provider
  • Building a LotArchitecture instance from the lot package
  • Creates GameObjects for that architecture instance
  • Setting the wall mode to "Roof" (change later to use last selected value)

Build Mode HUD
image
The Build Mode HUD has been implemented with a controller (LotBuildModeHUD.cs).

The Build Mode HUD currently has the ability to perform the following tasks:

  • Invoke the Wall, Foundation, Terrain, Floor and Hand tools.
  • Switch to different Sorts (Walls, Floors, Foundations, Terrain, etc.) and Subsorts (Carpet, Stone, Linoleum, etc.)
  • Show catalog entries for floors.

Build Mode Server
Since all of the tools listed below make direct changes to the LotArchitecture instance supplied by LotLoad -- a build mode server has been added as a pipeline to modify the lot. The Build Mode Server has a constructor that takes the current LotLoad instance for modification.

For clarity, each tool below has its relative function signature(s) on the BuildModeServer attached for reference.

Wall Tool

walltool.mp4

This tool (mainly) uses the following functions:
image
This method creates walls by doing the following:

  • Segmenting them into 1 unit long segments
  • Adds the wall segment to the WallGraph on the floor given (this also creates the layer ID)
  • Ensures the wall paper given is added to the WallMap
  • Adds data to the WallLayer with the wallpaper given
    It also uses functionality on the Build Mode Server such as:
  • Leveling terrain both below and above the wall to match the height of the wall.
    (this is how foundations are made)

image
image
These functions utilize the same logic as above but in reverse.
Deleting walls can be done diagonally and also by Room as well (hold shift)
Invoke the delete function by holding Ctrl :)

Floor Tool

FLOORtool.mp4

This tool (mainly) uses the following functions:
image
This function will ensure the pattern is added to the FloorMap. You can also use this function for wallpaper as well.

image
This function adds floors to the FloorPatterns on the LotArchitecture.
It will also do the following:

  • Ensure the pattern is referenced.
  • Level the terrain beneath the floor.
    This is done using the original game's implementation, it will poll the elevation at the NE corner of the tile the cursor originates and levels the region of terrain under the floor you placed.

image
This function uses the CreateFloors() method, but sets the FloorPattern to be empty.

Foundation Tool
image

The foundation tool uses both of these functions above together.
It will do the following:

  • Adjust the height of the foundation to be at the origin of the selection.
  • Need to level terrain under foundation so it cannot be placed through hills. - Complete.

Terrain Tool

terraintool.mp4

The terrain tool has three sizes matching the original games. The sizes are found in the enum TerrainBrushSizes:
image

It uses the following function:
image

This function supports the following: Raise, Lower, Water. In the future it can also support: Smooth and Terrain paint.
This function also supports the constrainfloorelevation cheat I added as well by using the IsFloorAt() function.

Note: This function will modify Elevation data for any floor provided, so walls, foundations, etc. can be modified.

The flatten lot function is also implemented, but should be revisited to remove all the stuff on the lot (there also is no confirmation message yet -- be careful)

Quick note on Cheats
Added the SimpleProperty, which can be used with the RegisterProperty function in the Cheat System. I almost reimplemented the whole cheat system until I saw it already existed! Anyway, this can be used to create properties like CFE which are a simple toggle on/off.

Final note
This is still proof of concept and help/feedback is welcome. If this pr is merged, I would highly recommend doing so to a dedicated branch as the features can be a little buggy right now.

Changes:
Build Mode
Lot Camera
3D Build Cursor
Catalog (early)
Add Terrain Tools (with cheat)
Add Foundation Tool
Add Wall tool
Add Floor tool
Add Pond Tool
Add Build Mode HUD Elements
Refactor
…veling to respect elevations of floors beneath this one.
@JDrocks450
Copy link
Author

fixelevations.mp4

Fixed bug mentioned in initial comment.

Copy link
Owner

@LazyDuchess LazyDuchess left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing work, thank you! I did notice some inconsistent naming though - some private variables start with uppercase, others don't, some have the _ prefix but others don't etc.

That could be cleaned up.

@JDrocks450
Copy link
Author

My apologies I will have that cleaned up in the next commit and respond back. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants