Skip to content

Commit

Permalink
improv: cache Region in Position
Browse files Browse the repository at this point in the history
  • Loading branch information
Mishura4 committed Jun 14, 2024
1 parent fd55949 commit a7b55b7
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion GameServer/Geometry/Position.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,20 @@ public struct Position
public int Y => Coordinate.Y;
public int Z => Coordinate.Z;

public Region Region => WorldMgr.GetRegion(RegionID);
private Region m_region = null;

public Region Region
{
get
{
if (m_region?.ID == RegionID)
{
return m_region;
}
m_region = WorldMgr.GetRegion(RegionID);
return m_region;
}
}

public Position() { }

Expand Down

0 comments on commit a7b55b7

Please sign in to comment.