forked from LostArtefacts/TR-Rando
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LostArtefacts#241 Environment Click Function
Adds a basic surface click function to move a sector's floor or ceiling up or down - this differs from the EMFloor and EMCeiling functions as it doesn't take faces into consideration.
- Loading branch information
Showing
3 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ public enum EMType | |
Flood = 2, | ||
Drain = 3, | ||
Ceiling = 4, | ||
Click = 5, | ||
|
||
// Texture types 21-40 | ||
Reface = 21, | ||
|
46 changes: 46 additions & 0 deletions
46
TREnvironmentEditor/Model/Types/Surfaces/EMClickFunction.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
using TREnvironmentEditor.Helpers; | ||
using TRFDControl; | ||
using TRFDControl.Utilities; | ||
using TRLevelReader.Model; | ||
|
||
namespace TREnvironmentEditor.Model.Types | ||
{ | ||
public class EMClickFunction : BaseEMFunction | ||
{ | ||
// This differs from dedicated floor/ceiling functions by only shifting sector values and does not deal with faces. | ||
// See example in Masonic room in Aldwych. | ||
public EMLocation Location { get; set; } | ||
public sbyte? FloorClicks { get; set; } | ||
public sbyte? CeilingClicks { get; set; } | ||
|
||
public override void ApplyToLevel(TR2Level level) | ||
{ | ||
FDControl floorData = new FDControl(); | ||
floorData.ParseFromLevel(level); | ||
|
||
TRRoomSector sector = FDUtilities.GetRoomSector(Location.X, Location.Y, Location.Z, Location.Room, level, floorData); | ||
MoveSector(sector); | ||
} | ||
|
||
public override void ApplyToLevel(TR3Level level) | ||
{ | ||
FDControl floorData = new FDControl(); | ||
floorData.ParseFromLevel(level); | ||
|
||
TRRoomSector sector = FDUtilities.GetRoomSector(Location.X, Location.Y, Location.Z, Location.Room, level, floorData); | ||
MoveSector(sector); | ||
} | ||
|
||
private void MoveSector(TRRoomSector sector) | ||
{ | ||
if (FloorClicks.HasValue) | ||
{ | ||
sector.Floor += FloorClicks.Value; | ||
} | ||
if (CeilingClicks.HasValue) | ||
{ | ||
sector.Ceiling += CeilingClicks.Value; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters