/*public void SetChestItems(Terraria.Item[] items)
* {
* Terraria.Main.chest[ID].item = items;
* }*/
public bool IsOpenFor(CPlayer player)
{
if (!IsLocked()) //if chest not locked skip all checks
{
return(true);
}
if (!tPulse.Players[player.Index].IsLoggedIn) //if player isn't logged in, and chest is protected, don't allow access
{
return(false);
}
if (IsOwnerConvert(player)) //if player is owner then skip checks
{
return(true);
}
if (HashedPassword != "") //this chest is passworded, so check if user has unlocked this chest
{
if (player.HasAccessToChest(ID)) //has unlocked this chest
{
return(true);
}
}
if (IsRegionLocked()) //if region lock then check region
{
var x = (int)Position.X;
var y = (int)Position.Y;
if (tPulse.Regions.InArea(x, y)) //if not in area disable region lock
{
if (tPulse.Regions.CanBuild(x, y, tPulse.Players[player.Index])) //if can build in area
{
return(true);
}
}
else
{
regionLock(false);
}
}
return(false);
}