Centered hitboxes are now handled via the config

This commit is contained in:
MascaraSnake 2016-01-14 23:44:00 +01:00
parent e29f7af427
commit 16d8bb39c6
12 changed files with 27 additions and 14 deletions

View file

@ -3282,6 +3282,7 @@ thingtypes
width = 96;
height = 192;
unflippable = true;
centerHitbox = true;
}
605
{
@ -3289,6 +3290,7 @@ thingtypes
sprite = "RINGA0";
width = 192;
unflippable = true;
centerHitbox = true;
}
606
{
@ -3297,6 +3299,7 @@ thingtypes
width = 96;
height = 192;
unflippable = true;
centerHitbox = true;
}
607
{
@ -3304,6 +3307,7 @@ thingtypes
sprite = "NWNGA0";
width = 192;
unflippable = true;
centerHitbox = true;
}
608
{
@ -3312,6 +3316,7 @@ thingtypes
width = 96;
height = 192;
unflippable = true;
centerHitbox = true;
}
609
{
@ -3319,6 +3324,7 @@ thingtypes
sprite = "NWNGA0";
width = 192;
unflippable = true;
centerHitbox = true;
}
}
@ -3847,6 +3853,7 @@ thingtypes
width = 80;
height = 160;
unflippable = true;
centerHitbox = true;
}
1706
{
@ -3901,6 +3908,7 @@ thingtypes
width = 80;
height = 160;
unflippable = true;
centerHitbox = true;
}
}

View file

@ -62,6 +62,7 @@ namespace CodeImp.DoomBuilder.Config
private readonly int heightoffset;
private readonly bool isUnflippable;
private readonly bool ignoreZ;
private readonly bool centerHitbox;
// Disposing
private bool isdisposed;
@ -98,6 +99,7 @@ namespace CodeImp.DoomBuilder.Config
public int HeightOffset { get { return heightoffset; } }
public bool IsUnflippable { get { return isUnflippable; } }
public bool IgnoreZ { get { return ignoreZ; } }
public bool CenterHitbox { get { return centerHitbox; } }
#endregion
#region ================== Constructor / Disposer
@ -132,6 +134,7 @@ namespace CodeImp.DoomBuilder.Config
this.heightoffset = parent.heightoffset;
this.isUnflippable = parent.isUnflippable;
this.ignoreZ = parent.ignoreZ;
this.centerHitbox = parent.centerHitbox;
}
// Set default properties
else
@ -154,6 +157,7 @@ namespace CodeImp.DoomBuilder.Config
this.heightoffset = 0;
this.isUnflippable = false;
this.ignoreZ = false;
this.centerHitbox = false;
}
// We have no destructor
@ -212,6 +216,7 @@ namespace CodeImp.DoomBuilder.Config
this.heightoffset = cfg.ReadSetting("thingtypes." + name + ".flags8height", parent.heightoffset);
this.isUnflippable = cfg.ReadSetting("thingtypes." + name + ".unflippable", parent.isUnflippable);
this.ignoreZ = cfg.ReadSetting("thingtypes." + name + ".ignoreZ", parent.ignoreZ);
this.centerHitbox = cfg.ReadSetting("thingtypes." + name + ".centerHitbox", parent.centerHitbox);
}
else
{
@ -233,6 +238,7 @@ namespace CodeImp.DoomBuilder.Config
this.heightoffset = cfg.ReadSetting("thingtypes." + name + ".flags8height", 0);
this.isUnflippable = cfg.ReadSetting("thingtypes." + name + ".unflippable", false);
this.ignoreZ = cfg.ReadSetting("thingtypes." + name + ".ignoreZ", false);
this.centerHitbox = cfg.ReadSetting("thingtypes." + name + ".centerHitbox", false);
}
// Safety

View file

@ -78,6 +78,7 @@ namespace CodeImp.DoomBuilder.Config
private int heightoffset;
private bool isUnflippable;
private bool ignoreZ;
private bool centerHitbox;
//mxd. GLOOME rendering settings
private Thing.SpriteRenderMode rendermode;
@ -125,6 +126,7 @@ namespace CodeImp.DoomBuilder.Config
public int HeightOffset { get { return heightoffset; } }
public bool IsUnflippable { get { return isUnflippable; } }
public bool IgnoreZ { get { return ignoreZ; } }
public bool CenterHitbox { get { return centerHitbox; } }
#endregion
#region ================== Constructor / Disposer
@ -163,6 +165,7 @@ namespace CodeImp.DoomBuilder.Config
this.heightoffset = 0;
this.isUnflippable = false;
this.ignoreZ = false;
this.centerHitbox = false;
// We have no destructor
GC.SuppressFinalize(this);
@ -206,6 +209,7 @@ namespace CodeImp.DoomBuilder.Config
this.heightoffset = cfg.ReadSetting("thingtypes." + cat.Name + "." + key + ".flags8height", cat.HeightOffset);
this.isUnflippable = cfg.ReadSetting("thingtypes." + cat.Name + "." + key + ".unflippable", cat.IsUnflippable);
this.ignoreZ = cfg.ReadSetting("thingtypes." + cat.Name + "." + key + ".ignoreZ", cat.IgnoreZ);
this.centerHitbox = cfg.ReadSetting("thingtypes." + cat.Name + "." + key + ".centerHitbox", cat.CenterHitbox);
// Read the args
for (int i = 0; i < Linedef.NUM_ARGS; i++)
@ -261,6 +265,7 @@ namespace CodeImp.DoomBuilder.Config
this.heightoffset = cat.HeightOffset;
this.isUnflippable = cat.IsUnflippable;
this.ignoreZ = cat.IgnoreZ;
this.centerHitbox = cat.CenterHitbox;
// Safety
if (this.radius < 4f) this.radius = 8f;
@ -310,6 +315,7 @@ namespace CodeImp.DoomBuilder.Config
this.heightoffset = cat.HeightOffset;
this.isUnflippable = cat.IsUnflippable;
this.ignoreZ = cat.IgnoreZ;
this.centerHitbox = cat.CenterHitbox;
// Safety
if (this.radius < 4f) this.radius = 8f;
@ -356,6 +362,7 @@ namespace CodeImp.DoomBuilder.Config
this.heightoffset = cat.HeightOffset;
this.isUnflippable = cat.IsUnflippable;
this.ignoreZ = cat.IgnoreZ;
this.centerHitbox = cat.CenterHitbox;
// Safety
if (this.radius < 4f) this.radius = 8f;
@ -404,6 +411,7 @@ namespace CodeImp.DoomBuilder.Config
this.heightoffset = other.heightoffset;
this.isUnflippable = other.isUnflippable;
this.ignoreZ = other.ignoreZ;
this.centerHitbox = other.centerHitbox;
//mxd. Copy GLOOME properties
this.rendermode = other.rendermode;

View file

@ -48,7 +48,6 @@ namespace CodeImp.DoomBuilder.IO
vertexSlopeTypes = new Dictionary<int, int[]>() { };
translucentLineTypes = new Dictionary<int, float>() { { 208, -1.0f } };
startTypes = new List<int>();
centerHitboxTypes = new List<int>();
}
#endregion

View file

@ -48,7 +48,6 @@ namespace CodeImp.DoomBuilder.IO
vertexSlopeTypes = new Dictionary<int, int[]>() { };
translucentLineTypes = new Dictionary<int, float>() { { 208, -1.0f } };
startTypes = new List<int>();
centerHitboxTypes = new List<int>();
}
#endregion

View file

@ -83,6 +83,5 @@ namespace CodeImp.DoomBuilder.IO
int AxisTransferType { get; }
int AxisTransferLineType { get; }
List<int> StartTypes { get; }
List<int> CenterHitboxTypes { get; }
}
}

View file

@ -51,7 +51,6 @@ namespace CodeImp.DoomBuilder.IO
protected Dictionary<int, int[]> vertexSlopeTypes;
protected Dictionary<int, float> translucentLineTypes;
protected List<int> startTypes;
protected List<int> centerHitboxTypes;
#endregion
#region ================== Properties
@ -111,7 +110,6 @@ namespace CodeImp.DoomBuilder.IO
public abstract int AxisTransferType { get; }
public abstract int AxisTransferLineType { get; }
public List<int> StartTypes { get { return startTypes; } }
public List<int> CenterHitboxTypes { get { return centerHitboxTypes; } }
#endregion
#region ================== Constructor / Disposer

View file

@ -144,8 +144,6 @@ namespace CodeImp.DoomBuilder.IO
};
startTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35 };
centerHitboxTypes = new List<int>() { 604, 605, 606, 607, 608, 609, 1705, 1713 };
}
#endregion

View file

@ -53,7 +53,6 @@ namespace CodeImp.DoomBuilder.IO
vertexSlopeTypes = new Dictionary<int, int[]>() { };
translucentLineTypes = new Dictionary<int, float>() { { 208, -1.0f } };
startTypes = new List<int>();
centerHitboxTypes = new List<int>();
// Make configuration
Configuration config = new Configuration();

View file

@ -130,7 +130,6 @@ namespace CodeImp.DoomBuilder.Map
}
public bool IsReverse { get { return General.Map.SRB2 && !Unflippable && IsFlagSet("2"); } }
public bool Unflippable { get { return General.Map.Data.GetThingInfo(Type).IsUnflippable; } }
public bool CenterHitbox { get { return General.Map.FormatInterface.CenterHitboxTypes.Contains(Type); } }
#endregion
#region ================== Constructor / Disposer

View file

@ -439,8 +439,8 @@ namespace CodeImp.DoomBuilder.VisualModes
}
else
{
float top = position_v3.Z + (thing.CenterHitbox ? thing.Height/2 : thing.Height);
float bottom = position_v3.Z - (thing.CenterHitbox ? thing.Height / 2 : 0);
float top = position_v3.Z + (info.CenterHitbox ? thing.Height/2 : thing.Height);
float bottom = position_v3.Z - (info.CenterHitbox ? thing.Height / 2 : 0);
WorldVertex v0 = new WorldVertex(-thing.Size + position_v3.X, -thing.Size + position_v3.Y, bottom);
WorldVertex v1 = new WorldVertex(-thing.Size + position_v3.X, thing.Size + position_v3.Y, bottom);
@ -471,7 +471,7 @@ namespace CodeImp.DoomBuilder.VisualModes
{
Matrix transform = Matrix.Scaling(thing.Size, thing.Size, thing.Size)
* (Matrix.RotationY(-Thing.RollRad) * Matrix.RotationX(-Thing.PitchRad) * Matrix.RotationZ(Thing.Angle))
* ((sizeless || thing.CenterHitbox) ? position : position * Matrix.Translation(0.0f, 0.0f, thingheight / 2f));
* ((sizeless || info.CenterHitbox) ? position : position * Matrix.Translation(0.0f, 0.0f, thingheight / 2f));
WorldVertex a0 = new WorldVertex(Vector3D.Transform(0.0f, 0.0f, 0.0f, transform)); //start
WorldVertex a1 = new WorldVertex(Vector3D.Transform(0.0f, -1.5f, 0.0f, transform)); //end

View file

@ -358,7 +358,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
verts[4] = verts[2];
verts[5] = new WorldVertex(+radius + offsetx, 0.0f, offsety - hh, sectorcolor, 1.0f, 1.0f);
}
else if (Thing.CenterHitbox)
else if (info.CenterHitbox)
{
float hh = height / 2;
verts[0] = new WorldVertex(-radius + offsetx, 0.0f, -hh, sectorcolor, 0.0f, 1.0f);
@ -509,7 +509,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
boxp1 = new Vector3D(pos.x - thingradius, pos.y - thingradius, pos.z - thingradius/2);
boxp2 = new Vector3D(pos.x + thingradius, pos.y + thingradius, pos.z + thingradius/2);
}
else if (Thing.CenterHitbox)
else if (info.CenterHitbox)
{
boxp1 = new Vector3D(pos.x - thingradius, pos.y - thingradius, pos.z - thingheight/2);
boxp2 = new Vector3D(pos.x + thingradius, pos.y + thingradius, pos.z + thingheight/2);