mirror of
https://git.do.srb2.org/STJr/ZoneBuilder.git
synced 2024-11-10 06:41:49 +00:00
Special Z position handling for NiGHTS path items and hoops
This commit is contained in:
parent
1e10c8b129
commit
841f4087b6
8 changed files with 87 additions and 27 deletions
|
@ -104,6 +104,7 @@ namespace CodeImp.DoomBuilder.IO
|
|||
public override int ColormapType { get { return -1; } }
|
||||
public override int FlatAlignmentType { get { return -1; } }
|
||||
public override int AxisType { get { return -1; } }
|
||||
public override int AxisTransferType { get { return -1; } }
|
||||
public override int AxisTransferLineType { get { return -1; } }
|
||||
#endregion
|
||||
|
||||
|
|
|
@ -104,6 +104,7 @@ namespace CodeImp.DoomBuilder.IO
|
|||
public override int ColormapType { get { return -1; } }
|
||||
public override int FlatAlignmentType { get { return -1; } }
|
||||
public override int AxisType { get { return -1; } }
|
||||
public override int AxisTransferType { get { return -1; } }
|
||||
public override int AxisTransferLineType { get { return -1; } }
|
||||
#endregion
|
||||
|
||||
|
|
|
@ -80,6 +80,7 @@ namespace CodeImp.DoomBuilder.IO
|
|||
int ColormapType { get; }
|
||||
int FlatAlignmentType { get; }
|
||||
int AxisType { get; }
|
||||
int AxisTransferType { get; }
|
||||
int AxisTransferLineType { get; }
|
||||
List<int> UnflippableTypes { get; }
|
||||
List<int> StartTypes { get; }
|
||||
|
|
|
@ -110,6 +110,7 @@ namespace CodeImp.DoomBuilder.IO
|
|||
public abstract int ColormapType { get; }
|
||||
public abstract int FlatAlignmentType { get; }
|
||||
public abstract int AxisType { get; }
|
||||
public abstract int AxisTransferType { get; }
|
||||
public abstract int AxisTransferLineType { get; }
|
||||
public List<int> UnflippableTypes { get { return unflippableTypes; } }
|
||||
public List<int> StartTypes { get { return startTypes; } }
|
||||
|
|
|
@ -165,6 +165,7 @@ namespace CodeImp.DoomBuilder.IO
|
|||
public override int ColormapType { get { return 606; } }
|
||||
public override int FlatAlignmentType { get { return 7; } }
|
||||
public override int AxisType { get { return 1700; } }
|
||||
public override int AxisTransferType { get { return 1701; } }
|
||||
public override int AxisTransferLineType { get { return 1702; } }
|
||||
#endregion
|
||||
|
||||
|
|
|
@ -155,6 +155,7 @@ namespace CodeImp.DoomBuilder.IO
|
|||
public override int ColormapType { get { return -1; } }
|
||||
public override int FlatAlignmentType { get { return -1; } }
|
||||
public override int AxisType { get { return -1; } }
|
||||
public override int AxisTransferType { get { return -1; } }
|
||||
public override int AxisTransferLineType { get { return -1; } }
|
||||
#endregion
|
||||
|
||||
|
|
|
@ -132,6 +132,11 @@ namespace CodeImp.DoomBuilder.Map
|
|||
public bool Unflippable { get { return General.Map.FormatInterface.UnflippableTypes.Contains(Type); } }
|
||||
public bool IsFloatable { get { return General.Map.FormatInterface.FloatableTypes.Contains(Type); } }
|
||||
public bool CenterHitbox { get { return General.Map.FormatInterface.CenterHitboxTypes.Contains(Type); } }
|
||||
public bool IsNiGHTSPathItem { get { return General.Map.FormatInterface.AxisType == Type
|
||||
|| General.Map.FormatInterface.AxisTransferType == Type
|
||||
|| General.Map.FormatInterface.AxisTransferLineType == Type;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ================== Constructor / Disposer
|
||||
|
@ -393,22 +398,6 @@ namespace CodeImp.DoomBuilder.Map
|
|||
if(selecteditem.List != null) selecteditem.List.Remove(selecteditem);
|
||||
selecteditem = null;
|
||||
}
|
||||
|
||||
public int GetFlagsValue()
|
||||
{
|
||||
int flags = 0;
|
||||
foreach (KeyValuePair<string, bool> f in Flags)
|
||||
{
|
||||
int fnum;
|
||||
if (f.Value && int.TryParse(f.Key, out fnum)) flags |= fnum;
|
||||
}
|
||||
|
||||
//SRB2 stores Z position in upper 12 bits of flags. Add Z position to flags.
|
||||
if (General.Map.SRB2) flags |= (UInt16)Position.z << 4;
|
||||
|
||||
return flags;
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ================== Changes
|
||||
|
@ -636,6 +625,35 @@ namespace CodeImp.DoomBuilder.Map
|
|||
return new Dictionary<string,bool>(flags);
|
||||
}
|
||||
|
||||
public int GetFlagsValue()
|
||||
{
|
||||
int flags = 0;
|
||||
foreach (KeyValuePair<string, bool> f in Flags)
|
||||
{
|
||||
int fnum;
|
||||
if (f.Value && int.TryParse(f.Key, out fnum)) flags |= fnum;
|
||||
}
|
||||
|
||||
//SRB2 stores Z position in upper 12 bits of flags. Add Z position to flags.
|
||||
if (General.Map.SRB2) flags |= (UInt16)Position.z << 4;
|
||||
|
||||
return flags;
|
||||
}
|
||||
|
||||
public void SetFlagsValue(int value)
|
||||
{
|
||||
Dictionary<string, bool> newflags = new Dictionary<string, bool>(flags);
|
||||
foreach (KeyValuePair<string, bool> f in flags)
|
||||
{
|
||||
int fnum;
|
||||
if (int.TryParse(f.Key, out fnum)) newflags[f.Key] = ((value & fnum) == fnum);
|
||||
}
|
||||
flags = newflags;
|
||||
|
||||
//SRB2 stores Z position in upper 12 bits of flags. Get Z position to flags.
|
||||
if (General.Map.SRB2) pos.z = value >> 4;
|
||||
}
|
||||
|
||||
// This clears all flags
|
||||
public void ClearFlags()
|
||||
{
|
||||
|
|
|
@ -421,15 +421,35 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
}
|
||||
else if (General.Map.SRB2 && Thing.IsSlopeVertex)
|
||||
{
|
||||
if (Thing.Sector != null) //mxd
|
||||
if (Thing.Sector != null)
|
||||
{
|
||||
// This is a special thing that needs special positioning
|
||||
SectorData sd = mode.GetSectorData(Thing.Sector);
|
||||
pos.z = sd.Floor.sector.FloorHeight + Thing.Position.z - Thing.Height/2;
|
||||
}
|
||||
}
|
||||
else if (Thing.IsNiGHTSPathItem)
|
||||
{
|
||||
//Z position is always 0.
|
||||
if (Thing.Sector != null)
|
||||
{
|
||||
SectorData sd = mode.GetSectorData(Thing.Sector);
|
||||
pos.z = sd.Floor.sector.FloorHeight;
|
||||
}
|
||||
else pos.z = 0;
|
||||
}
|
||||
else if (General.Map.SRB2 && Thing.Type == 1705)
|
||||
{
|
||||
//Use the flags value instead of the Z position for the Z position. SRB2 is really stupid sometimes.
|
||||
pos.z = Thing.GetFlagsValue();
|
||||
if (Thing.Sector != null)
|
||||
{
|
||||
SectorData sd = mode.GetSectorData(Thing.Sector);
|
||||
pos.z += sd.Floor.sector.FloorHeight;
|
||||
}
|
||||
}
|
||||
|
||||
else if(info.AbsoluteZ)
|
||||
else if (info.AbsoluteZ)
|
||||
{
|
||||
// Absolute Z position
|
||||
pos.z = Thing.Position.z;
|
||||
|
@ -808,17 +828,33 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
// Raise/lower thing
|
||||
public void OnChangeTargetHeight(int amount)
|
||||
{
|
||||
if (Thing.IsNiGHTSPathItem) return; //NiGHTS path items have no height.
|
||||
|
||||
if(General.Map.FormatInterface.HasThingHeight)
|
||||
{
|
||||
if((General.Map.UndoRedo.NextUndo == null) || (General.Map.UndoRedo.NextUndo.TicketID != undoticket))
|
||||
undoticket = mode.CreateUndo("Change thing height");
|
||||
|
||||
if (General.Map.SRB2 && Thing.Type == 1705)
|
||||
{
|
||||
int newZ = General.Clamp(Thing.GetFlagsValue() + amount,0,0xFFFF);
|
||||
Thing.SetFlagsValue(newZ);
|
||||
|
||||
int actualZ = newZ >> 4;
|
||||
Vector3D newPosition = new Vector3D(Thing.Position.x, Thing.Position.y, actualZ);
|
||||
Thing.Move(newPosition);
|
||||
|
||||
mode.SetActionResult("Changed thing height to " + newZ + ".");
|
||||
}
|
||||
else
|
||||
{
|
||||
Vector3D newPosition = Thing.Position + new Vector3D(0.0f, 0.0f, (Thing.IsFlipped ? -amount : amount));
|
||||
newPosition.z = General.Clamp(newPosition.z, General.Map.FormatInterface.MinThingHeight, General.Map.FormatInterface.MaxThingHeight);
|
||||
|
||||
Thing.Move(newPosition);
|
||||
|
||||
mode.SetActionResult("Changed thing height to " + Thing.Position.z + ".");
|
||||
}
|
||||
|
||||
// Update what must be updated
|
||||
ThingData td = mode.GetThingData(this.Thing);
|
||||
|
|
Loading…
Reference in a new issue