From 16d8bb39c638a2eb0ddd3926b229028025731b75 Mon Sep 17 00:00:00 2001 From: MascaraSnake Date: Thu, 14 Jan 2016 23:44:00 +0100 Subject: [PATCH] Centered hitboxes are now handled via the config --- Build/Configurations/Srb2-21slopeszb.cfg | 8 ++++++++ Source/Core/Config/ThingCategory.cs | 6 ++++++ Source/Core/Config/ThingTypeInfo.cs | 8 ++++++++ Source/Core/IO/DoomMapSetIO.cs | 1 - Source/Core/IO/HexenMapSetIO.cs | 1 - Source/Core/IO/IMapSetIO.cs | 1 - Source/Core/IO/MapSetIO.cs | 2 -- Source/Core/IO/SRB2MapSetIO.cs | 2 -- Source/Core/IO/UniversalMapSetIO.cs | 1 - Source/Core/Map/Thing.cs | 1 - Source/Core/VisualModes/VisualThing.cs | 6 +++--- .../Plugins/BuilderModes/VisualModes/BaseVisualThing.cs | 4 ++-- 12 files changed, 27 insertions(+), 14 deletions(-) diff --git a/Build/Configurations/Srb2-21slopeszb.cfg b/Build/Configurations/Srb2-21slopeszb.cfg index 8f56216..b630cae 100644 --- a/Build/Configurations/Srb2-21slopeszb.cfg +++ b/Build/Configurations/Srb2-21slopeszb.cfg @@ -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; } } diff --git a/Source/Core/Config/ThingCategory.cs b/Source/Core/Config/ThingCategory.cs index 775da89..28d0dbe 100644 --- a/Source/Core/Config/ThingCategory.cs +++ b/Source/Core/Config/ThingCategory.cs @@ -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 diff --git a/Source/Core/Config/ThingTypeInfo.cs b/Source/Core/Config/ThingTypeInfo.cs index e336735..cec12f0 100644 --- a/Source/Core/Config/ThingTypeInfo.cs +++ b/Source/Core/Config/ThingTypeInfo.cs @@ -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; diff --git a/Source/Core/IO/DoomMapSetIO.cs b/Source/Core/IO/DoomMapSetIO.cs index 353d4f0..a730323 100644 --- a/Source/Core/IO/DoomMapSetIO.cs +++ b/Source/Core/IO/DoomMapSetIO.cs @@ -48,7 +48,6 @@ namespace CodeImp.DoomBuilder.IO vertexSlopeTypes = new Dictionary() { }; translucentLineTypes = new Dictionary() { { 208, -1.0f } }; startTypes = new List(); - centerHitboxTypes = new List(); } #endregion diff --git a/Source/Core/IO/HexenMapSetIO.cs b/Source/Core/IO/HexenMapSetIO.cs index a985656..ca4ed98 100644 --- a/Source/Core/IO/HexenMapSetIO.cs +++ b/Source/Core/IO/HexenMapSetIO.cs @@ -48,7 +48,6 @@ namespace CodeImp.DoomBuilder.IO vertexSlopeTypes = new Dictionary() { }; translucentLineTypes = new Dictionary() { { 208, -1.0f } }; startTypes = new List(); - centerHitboxTypes = new List(); } #endregion diff --git a/Source/Core/IO/IMapSetIO.cs b/Source/Core/IO/IMapSetIO.cs index 2bdcb14..e1a5b3f 100644 --- a/Source/Core/IO/IMapSetIO.cs +++ b/Source/Core/IO/IMapSetIO.cs @@ -83,6 +83,5 @@ namespace CodeImp.DoomBuilder.IO int AxisTransferType { get; } int AxisTransferLineType { get; } List StartTypes { get; } - List CenterHitboxTypes { get; } } } diff --git a/Source/Core/IO/MapSetIO.cs b/Source/Core/IO/MapSetIO.cs index bd48927..722bd5c 100644 --- a/Source/Core/IO/MapSetIO.cs +++ b/Source/Core/IO/MapSetIO.cs @@ -51,7 +51,6 @@ namespace CodeImp.DoomBuilder.IO protected Dictionary vertexSlopeTypes; protected Dictionary translucentLineTypes; protected List startTypes; - protected List centerHitboxTypes; #endregion #region ================== Properties @@ -111,7 +110,6 @@ namespace CodeImp.DoomBuilder.IO public abstract int AxisTransferType { get; } public abstract int AxisTransferLineType { get; } public List StartTypes { get { return startTypes; } } - public List CenterHitboxTypes { get { return centerHitboxTypes; } } #endregion #region ================== Constructor / Disposer diff --git a/Source/Core/IO/SRB2MapSetIO.cs b/Source/Core/IO/SRB2MapSetIO.cs index cf8da7e..e06bb84 100644 --- a/Source/Core/IO/SRB2MapSetIO.cs +++ b/Source/Core/IO/SRB2MapSetIO.cs @@ -144,8 +144,6 @@ namespace CodeImp.DoomBuilder.IO }; startTypes = new List() { 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() { 604, 605, 606, 607, 608, 609, 1705, 1713 }; } #endregion diff --git a/Source/Core/IO/UniversalMapSetIO.cs b/Source/Core/IO/UniversalMapSetIO.cs index 44e5fff..2e06684 100644 --- a/Source/Core/IO/UniversalMapSetIO.cs +++ b/Source/Core/IO/UniversalMapSetIO.cs @@ -53,7 +53,6 @@ namespace CodeImp.DoomBuilder.IO vertexSlopeTypes = new Dictionary() { }; translucentLineTypes = new Dictionary() { { 208, -1.0f } }; startTypes = new List(); - centerHitboxTypes = new List(); // Make configuration Configuration config = new Configuration(); diff --git a/Source/Core/Map/Thing.cs b/Source/Core/Map/Thing.cs index c1142d7..9ad6e16 100644 --- a/Source/Core/Map/Thing.cs +++ b/Source/Core/Map/Thing.cs @@ -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 diff --git a/Source/Core/VisualModes/VisualThing.cs b/Source/Core/VisualModes/VisualThing.cs index 718e9d4..2d872fb 100644 --- a/Source/Core/VisualModes/VisualThing.cs +++ b/Source/Core/VisualModes/VisualThing.cs @@ -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 diff --git a/Source/Plugins/BuilderModes/VisualModes/BaseVisualThing.cs b/Source/Plugins/BuilderModes/VisualModes/BaseVisualThing.cs index 3ae98ad..995c2ae 100644 --- a/Source/Plugins/BuilderModes/VisualModes/BaseVisualThing.cs +++ b/Source/Plugins/BuilderModes/VisualModes/BaseVisualThing.cs @@ -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);