Zepheus.Zone.Game.ZoneCharacter.ZoneCharacter C# (CSharp) Method

ZoneCharacter() public method

public ZoneCharacter ( string name, bool loadequips = true ) : System
name string
loadequips bool
return System
        public ZoneCharacter(string name, bool loadequips = true)
        {
            try
            {
                character = Program.Entity.Characters.First(c => c.Name == name);
                if (character == null) throw new Exception("Character not found.");
                Program.Entity.Refresh(System.Data.Objects.RefreshMode.StoreWins, character); //fixes changes when character is offline
                Buffs = new Buffs(this);
                LastShout = Program.CurrentTime;
                ChatBlocked = DateTime.MinValue;
                NextSPRest = DateTime.MaxValue;
                NextHPRest = DateTime.MaxValue;
                SelectedObject = null;
                House = null;
                HP = (uint)character.HP; //we copy these to make less stress on Entity
                SP = (uint)character.SP;
                Exp = character.Exp;
                StonesHP = character.HPStones;
                StonesSP = character.SPStones;
                State = PlayerState.Normal;
                LoadItems();
                if (IsDead)
                {
                    HP = MaxHP / 4;
                    Exp = Exp / 2;
                    MapInfo mi;
                    DataProvider.Instance.MapsByID.TryGetValue(MapID, out mi);
                    if (mi != null)
                    {
                        character.XPos = mi.RegenX;
                        character.YPos = mi.RegenY;
                    }
                }
                SetMap(MapID);
            }
            catch (Exception ex)
            {
                Log.WriteLine(LogLevel.Exception, "Error reading character from entity: {0}", ex.ToString());
            }
        }