public void OnEnterDoor(ShPlayer player, ShDoor door, ShPlayer sender, bool forceEnter) { if (!forceEnter) { if (player.IsRestrained) { player.svPlayer.SendGameMessage("You are restrained"); return; } if (door.svDoor.key && !player.HasItem(door.svDoor.key)) { player.svPlayer.SendGameMessage("Need " + door.svDoor.key.itemName + " to enter"); return; } if (!player.InActionRange(door)) { return; } } ShMountable baseEntity; if (player.curMount is ShPlayer mountPlayer) { baseEntity = mountPlayer; } else { baseEntity = player; if (player.curMount) { player.svPlayer.SvDismount(); } } if (door is ShApartment apartment && sender.ownedApartments.TryGetValue(apartment, out var place)) { baseEntity.svMountable.SvRelocate(place.mainDoor.spawnPoint, place.mTransform); }
public virtual bool IsValid() => player && targetEntity && player.IsMobile && player.InActionRange(targetEntity);