Core/Misc: Misc fixes
This commit is contained in:
@@ -19,6 +19,7 @@ using Framework.GameMath;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.Contracts;
|
||||
using System.Collections.Concurrent;
|
||||
|
||||
namespace Game.Collision
|
||||
{
|
||||
@@ -39,14 +40,14 @@ namespace Game.Collision
|
||||
Vector3 pos = value.getPosition();
|
||||
Node node = getGridFor(pos.X, pos.Y);
|
||||
node.insert(value);
|
||||
memberTable.Add(value, node);
|
||||
memberTable.TryAdd(value, node);
|
||||
}
|
||||
|
||||
public virtual void remove(T value)
|
||||
{
|
||||
memberTable[value].remove(value);
|
||||
// Remove the member
|
||||
memberTable.Remove(value);
|
||||
memberTable.TryRemove(value, out Node node);
|
||||
}
|
||||
|
||||
public virtual void balance()
|
||||
@@ -205,7 +206,7 @@ namespace Game.Collision
|
||||
node.intersectRay(ray, intersectCallback, ref max_dist);
|
||||
}
|
||||
|
||||
Dictionary<T, Node> memberTable = new Dictionary<T, Node>();
|
||||
ConcurrentDictionary<T, Node> memberTable = new ConcurrentDictionary<T, Node>();
|
||||
Node[][] nodes = new Node[CELL_NUMBER][];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -265,10 +265,14 @@ namespace Game.Entities
|
||||
if (obj == this)
|
||||
return true;
|
||||
|
||||
// move arc to range 0.. 2*pi
|
||||
arc = NormalizeOrientation(arc);
|
||||
|
||||
float angle = GetAngle(obj);
|
||||
angle -= GetOrientation();
|
||||
|
||||
// move angle to range -pi ... +pi
|
||||
angle = NormalizeOrientation(angle);
|
||||
if (angle > MathFunctions.PI)
|
||||
angle -= 2.0f * MathFunctions.PI;
|
||||
|
||||
@@ -276,6 +280,16 @@ namespace Game.Entities
|
||||
float rborder = (arc / border); // in range 0..pi
|
||||
return ((angle >= lborder) && (angle <= rborder));
|
||||
}
|
||||
|
||||
public bool HasInLine(Position pos, float width)
|
||||
{
|
||||
if (!HasInArc(MathFunctions.PI, pos))
|
||||
return false;
|
||||
|
||||
float angle = GetRelativeAngle(pos);
|
||||
return Math.Abs(Math.Sin(angle)) * GetExactDist2d(pos.GetPositionX(), pos.GetPositionY()) < width;
|
||||
}
|
||||
|
||||
public void GetSinCos(float x, float y, out float vsin, out float vcos)
|
||||
{
|
||||
float dx = GetPositionX() - x;
|
||||
|
||||
@@ -2568,14 +2568,6 @@ namespace Game.Entities
|
||||
public virtual bool LoadFromDB(ulong guid, Map map) { return true; }
|
||||
|
||||
//Position
|
||||
public bool HasInLine(WorldObject target, float width)
|
||||
{
|
||||
if (!HasInArc(MathFunctions.PI, target))
|
||||
return false;
|
||||
width += target.GetObjectSize();
|
||||
float angle = GetRelativeAngle(target);
|
||||
return Math.Abs(Math.Sin(angle)) * GetExactDist2d(target.GetPositionX(), target.GetPositionY()) < width;
|
||||
}
|
||||
|
||||
public float GetDistanceZ(WorldObject obj)
|
||||
{
|
||||
|
||||
@@ -2262,7 +2262,7 @@ namespace Game
|
||||
modelInfo.BoundingRadius = result.Read<float>(1);
|
||||
modelInfo.CombatReach = result.Read<float>(2);
|
||||
modelInfo.DisplayIdOtherGender = result.Read<uint>(3);
|
||||
modelInfo.gender = (sbyte)creatureDisplay.Gender;
|
||||
modelInfo.gender = creatureDisplay.Gender;
|
||||
|
||||
// Checks
|
||||
if (modelInfo.gender == (sbyte)Gender.Unknown)
|
||||
@@ -3587,7 +3587,7 @@ namespace Game
|
||||
return null;
|
||||
|
||||
// If a model for another gender exists, 50% chance to use it
|
||||
if (modelInfo.DisplayIdOtherGender != 0 && RandomHelper.NextDouble() == 0)
|
||||
if (modelInfo.DisplayIdOtherGender != 0 && RandomHelper.URand(0, 1) == 0)
|
||||
{
|
||||
CreatureModelInfo minfotmp = GetCreatureModelInfo(modelInfo.DisplayIdOtherGender);
|
||||
if (minfotmp == null)
|
||||
|
||||
Reference in New Issue
Block a user