More refactoring of code.
This commit is contained in:
@@ -41,7 +41,7 @@ namespace Game.Collision
|
||||
|
||||
public class GameObjectModel : IModel
|
||||
{
|
||||
bool initialize(GameObjectModelOwnerBase modelOwner)
|
||||
bool Initialize(GameObjectModelOwnerBase modelOwner)
|
||||
{
|
||||
var modelData = StaticModelList.models.LookupByKey(modelOwner.GetDisplayId());
|
||||
if (modelData == null)
|
||||
@@ -55,7 +55,7 @@ namespace Game.Collision
|
||||
return false;
|
||||
}
|
||||
|
||||
iModel = Global.VMapMgr.acquireModelInstance(modelData.name);
|
||||
iModel = Global.VMapMgr.AcquireModelInstance(modelData.name);
|
||||
|
||||
if (iModel == null)
|
||||
return false;
|
||||
@@ -82,7 +82,7 @@ namespace Game.Collision
|
||||
public static GameObjectModel Create(GameObjectModelOwnerBase modelOwner)
|
||||
{
|
||||
GameObjectModel mdl = new GameObjectModel();
|
||||
if (!mdl.initialize(modelOwner))
|
||||
if (!mdl.Initialize(modelOwner))
|
||||
return null;
|
||||
|
||||
return mdl;
|
||||
@@ -90,7 +90,7 @@ namespace Game.Collision
|
||||
|
||||
public override bool IntersectRay(Ray ray, ref float maxDist, bool stopAtFirstHit, PhaseShift phaseShift, ModelIgnoreFlags ignoreFlags)
|
||||
{
|
||||
if (!isCollisionEnabled() || !owner.IsSpawned())
|
||||
if (!IsCollisionEnabled() || !owner.IsSpawned())
|
||||
return false;
|
||||
|
||||
if (!owner.IsInPhase(phaseShift))
|
||||
@@ -115,7 +115,7 @@ namespace Game.Collision
|
||||
|
||||
public override void IntersectPoint(Vector3 point, AreaInfo info, PhaseShift phaseShift)
|
||||
{
|
||||
if (!isCollisionEnabled() || !owner.IsSpawned() || !isMapObject())
|
||||
if (!IsCollisionEnabled() || !owner.IsSpawned() || !IsMapObject())
|
||||
return;
|
||||
|
||||
if (!owner.IsInPhase(phaseShift))
|
||||
@@ -172,12 +172,12 @@ namespace Game.Collision
|
||||
return true;
|
||||
}
|
||||
|
||||
public override Vector3 getPosition() { return iPos; }
|
||||
public override AxisAlignedBox getBounds() { return iBound; }
|
||||
public override Vector3 GetPosition() { return iPos; }
|
||||
public override AxisAlignedBox GetBounds() { return iBound; }
|
||||
|
||||
public void enableCollision(bool enable) { _collisionEnabled = enable; }
|
||||
bool isCollisionEnabled() { return _collisionEnabled; }
|
||||
public bool isMapObject() { return isWmo; }
|
||||
public void EnableCollision(bool enable) { _collisionEnabled = enable; }
|
||||
bool IsCollisionEnabled() { return _collisionEnabled; }
|
||||
public bool IsMapObject() { return isWmo; }
|
||||
|
||||
public static void LoadGameObjectModelList()
|
||||
{
|
||||
|
||||
@@ -22,8 +22,8 @@ namespace Game.Collision
|
||||
{
|
||||
public class IModel
|
||||
{
|
||||
public virtual Vector3 getPosition() { return default; }
|
||||
public virtual AxisAlignedBox getBounds() { return default; }
|
||||
public virtual Vector3 GetPosition() { return default; }
|
||||
public virtual AxisAlignedBox GetBounds() { return default; }
|
||||
|
||||
public virtual bool IntersectRay(Ray ray, ref float maxDist, bool stopAtFirstHit, PhaseShift phaseShift, ModelIgnoreFlags ignoreFlags) { return false; }
|
||||
public virtual bool IntersectRay(Ray ray, ref float distance, bool stopAtFirstHit, ModelIgnoreFlags ignoreFlags) { return false; }
|
||||
|
||||
@@ -44,7 +44,7 @@ namespace Game.Collision
|
||||
name = spawn.name;
|
||||
}
|
||||
|
||||
public static bool readFromFile(BinaryReader reader, out ModelSpawn spawn)
|
||||
public static bool ReadFromFile(BinaryReader reader, out ModelSpawn spawn)
|
||||
{
|
||||
spawn = new ModelSpawn();
|
||||
|
||||
@@ -94,7 +94,7 @@ namespace Game.Collision
|
||||
iInvScale = 1.0f / iScale;
|
||||
}
|
||||
|
||||
public bool intersectRay(Ray pRay, ref float pMaxDist, bool pStopAtFirstHit, ModelIgnoreFlags ignoreFlags)
|
||||
public bool IntersectRay(Ray pRay, ref float pMaxDist, bool pStopAtFirstHit, ModelIgnoreFlags ignoreFlags)
|
||||
{
|
||||
if (iModel == null)
|
||||
return false;
|
||||
@@ -116,7 +116,7 @@ namespace Game.Collision
|
||||
return hit;
|
||||
}
|
||||
|
||||
public void intersectPoint(Vector3 p, AreaInfo info)
|
||||
public void IntersectPoint(Vector3 p, AreaInfo info)
|
||||
{
|
||||
if (iModel == null)
|
||||
return;
|
||||
@@ -192,7 +192,7 @@ namespace Game.Collision
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setUnloaded() { iModel = null; }
|
||||
public void SetUnloaded() { iModel = null; }
|
||||
|
||||
Matrix3 iInvRot;
|
||||
float iInvScale;
|
||||
|
||||
@@ -128,7 +128,7 @@ namespace Game.Collision
|
||||
return true;
|
||||
}
|
||||
|
||||
public static WmoLiquid readFromFile(BinaryReader reader)
|
||||
public static WmoLiquid ReadFromFile(BinaryReader reader)
|
||||
{
|
||||
WmoLiquid liquid = new WmoLiquid();
|
||||
|
||||
@@ -193,13 +193,13 @@ namespace Game.Collision
|
||||
iLiquid = null;
|
||||
}
|
||||
|
||||
void setLiquidData(WmoLiquid liquid)
|
||||
void SetLiquidData(WmoLiquid liquid)
|
||||
{
|
||||
iLiquid = liquid;
|
||||
liquid = null;
|
||||
}
|
||||
|
||||
public bool readFromFile(BinaryReader reader)
|
||||
public bool ReadFromFile(BinaryReader reader)
|
||||
{
|
||||
triangles.Clear();
|
||||
vertices.Clear();
|
||||
@@ -237,7 +237,7 @@ namespace Game.Collision
|
||||
if (reader.ReadStringFromChars(4) != "MBIH")
|
||||
return false;
|
||||
|
||||
meshTree.readFromFile(reader);
|
||||
meshTree.ReadFromFile(reader);
|
||||
|
||||
// write liquid data
|
||||
if (reader.ReadStringFromChars(4) != "LIQU")
|
||||
@@ -245,7 +245,7 @@ namespace Game.Collision
|
||||
|
||||
chunkSize = reader.ReadUInt32();
|
||||
if (chunkSize > 0)
|
||||
iLiquid = WmoLiquid.readFromFile(reader);
|
||||
iLiquid = WmoLiquid.ReadFromFile(reader);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -256,7 +256,7 @@ namespace Game.Collision
|
||||
return false;
|
||||
|
||||
GModelRayCallback callback = new GModelRayCallback(triangles, vertices);
|
||||
meshTree.intersectRay(ray, callback, ref distance, stopAtFirstHit);
|
||||
meshTree.IntersectRay(ray, callback, ref distance, stopAtFirstHit);
|
||||
return callback.hit;
|
||||
}
|
||||
|
||||
@@ -290,7 +290,7 @@ namespace Game.Collision
|
||||
return 0;
|
||||
}
|
||||
|
||||
public override AxisAlignedBox getBounds() { return iBound; }
|
||||
public override AxisAlignedBox GetBounds() { return iBound; }
|
||||
|
||||
public uint GetMogpFlags() { return iMogpFlags; }
|
||||
|
||||
@@ -328,7 +328,7 @@ namespace Game.Collision
|
||||
return groupModels[0].IntersectRay(ray, ref distance, stopAtFirstHit);
|
||||
|
||||
WModelRayCallBack isc = new WModelRayCallBack(groupModels);
|
||||
groupTree.intersectRay(ray, isc, ref distance, stopAtFirstHit);
|
||||
groupTree.IntersectRay(ray, isc, ref distance, stopAtFirstHit);
|
||||
return isc.hit;
|
||||
}
|
||||
|
||||
@@ -339,7 +339,7 @@ namespace Game.Collision
|
||||
return false;
|
||||
|
||||
WModelAreaCallback callback = new WModelAreaCallback(groupModels, down);
|
||||
groupTree.intersectPoint(p, callback);
|
||||
groupTree.IntersectPoint(p, callback);
|
||||
if (callback.hit != null)
|
||||
{
|
||||
info.rootId = (int)RootWMOID;
|
||||
@@ -359,7 +359,7 @@ namespace Game.Collision
|
||||
return false;
|
||||
|
||||
WModelAreaCallback callback = new WModelAreaCallback(groupModels, down);
|
||||
groupTree.intersectPoint(p, callback);
|
||||
groupTree.IntersectPoint(p, callback);
|
||||
if (callback.hit != null)
|
||||
{
|
||||
info.hitModel = callback.hit;
|
||||
@@ -369,7 +369,7 @@ namespace Game.Collision
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool readFile(string filename)
|
||||
public bool ReadFile(string filename)
|
||||
{
|
||||
if (!File.Exists(filename))
|
||||
{
|
||||
@@ -397,7 +397,7 @@ namespace Game.Collision
|
||||
for (var i = 0; i < count; ++i)
|
||||
{
|
||||
GroupModel group = new GroupModel();
|
||||
group.readFromFile(reader);
|
||||
group.ReadFromFile(reader);
|
||||
groupModels.Add(group);
|
||||
}
|
||||
|
||||
@@ -405,7 +405,7 @@ namespace Game.Collision
|
||||
if (reader.ReadStringFromChars(4) != "GBIH")
|
||||
return false;
|
||||
|
||||
return groupTree.readFromFile(reader);
|
||||
return groupTree.ReadFromFile(reader);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user