#!/usr/bin/perl
#use Fcntl q{:flock};
#use Mooix::Thing;
#use Mooix::Verb;
#use Mooix::Root;
run sub {
	my $this=shift;
	%_=@_;
	my $avatar=$_{avatar};
	my $prep = ($this->on_prepositions)[0];

	# TODO if there are other avatars on the couch, probably shouldn't
	# let this one lie down. I could just make lying down increase
	# the volume used, and get this behavior for free (once I have
	# volume tracking).
	
	my $lock = $avatar->getlock(LOCK_EX);

	if ($avatar->location == $this && ($avatar->preposition)[0] eq $prep) {
		fail "You're already there."
	}

	if (! $this->location->isa($Mooix::Root->concrete->room)) {
		exit Mooix::Verb::SKIP; # to next furniture
	}

	if ($prep &&
	    $avatar->physics->move(object => $avatar, to => $this, preposition => $prep)) {
	    	$this->msg('lie', %_);
	}
	else {
		fail "You can't lie down there.";
	}
}
