Advertisement
mojito-ice

Untitled

Oct 16th, 2014
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.36 KB | None | 0 0
  1. /*
  2. * Copyright (C) 2012-2014 Arctium Emulation <http://arctium.org>
  3. *
  4. * This program is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation, either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17.  
  18. using Framework.Constants.Object;
  19. using Framework.Objects.WorldEntities;
  20.  
  21. namespace Framework.Objects
  22. {
  23. public class SmartGuid
  24. {
  25. public ulong Low { get; set; }
  26. public ulong High { get; set; }
  27.  
  28. public SmartGuid() { }
  29.  
  30. public SmartGuid(IWorldObject obj)
  31. {
  32. if ((var player = obj as Player) != null)
  33. {
  34. Type = GuidType.Player;
  35. MapId = (ushort)player.Data.Map;
  36. CreationBits = player.Data.Guid;
  37. }
  38. }
  39.  
  40. public GuidType Type
  41. {
  42. get { return (GuidType)(High >> 58); }
  43. set { High |= (ulong)value << 58; }
  44. }
  45.  
  46. public GuidSubType SubType
  47. {
  48. get { return (GuidSubType)(Low >> 56); }
  49. set { Low |= (ulong)value << 56; }
  50. }
  51.  
  52. public ushort RealmId
  53. {
  54. get { return (ushort)((High >> 42) & 0x1FFF); }
  55. set { High |= (ulong)value << 42; }
  56. }
  57.  
  58. public ushort ServerId
  59. {
  60. get { return (ushort)((Low >> 40) & 0x1FFF); }
  61. set { Low |= (ulong)value << 40; }
  62. }
  63.  
  64. public ushort MapId
  65. {
  66. get { return (ushort)((High >> 29) & 0x1FFF); }
  67. set { High |= (ulong)value << 29; }
  68. }
  69.  
  70. public uint Id
  71. {
  72. get { return (uint)(High & 0xFFFFFF) >> 6; }
  73. set { High |= (ulong)value << 6; }
  74. }
  75.  
  76. public ulong CreationBits
  77. {
  78. get { return Low & 0xFFFFFFFFFF; }
  79. set { Low |= value; }
  80. }
  81. }
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement