public void Rest(bool pStart)
{
if (IsDead)
{
Log.WriteLine(LogLevel.Warn, "Zombie tried to rest while being dead. {0}", this);
CheatTracker.AddCheat(CheatTypes.DEAD_REST, 100);
return;
}
if (pStart && (this.State == PlayerState.Resting || this.State == PlayerState.Vendor))
{
Log.WriteLine(LogLevel.Warn, "Tried to go in home twice {0}", this);
return;
}
else if (!pStart && this.House == null)
{
Log.WriteLine(LogLevel.Warn, "Tried to exit house while not in one {0}", this);
}
if (pStart)
{
this.State = PlayerState.Resting;
this.House = new House(this, House.HouseType.Resting);
this.NextHPRest = Program.CurrentTime.AddMilliseconds((uint)this.House.Info.HPTick);
this.NextSPRest = Program.CurrentTime.AddMilliseconds((uint)this.House.Info.SPTick);
Handler8.SendBeginRestResponse(this.Client, 0x0a81);
using (var broad = Handler8.BeginDisplayRest(this))
{
this.Broadcast(broad);
}
}
else
{
this.State = PlayerState.Normal;
this.House = null;
Handler8.SendEndRestResponse(this.Client);
this.NextHPRest = DateTime.MaxValue;
this.NextSPRest = DateTime.MaxValue;
using (var broad = Handler8.EndDisplayRest(this))
{
this.Broadcast(broad);
}
}
}