#!/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];

	my $lock = $avatar->getlock(LOCK_EX);

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

	if (! $this->location->isa($Mooix::Root->concrete->room)) {
		# Let the parser try some better peice of furniture.
		exit Mooix::Verb::SKIP;
	}
	
	if ($prep &&
	    $avatar->physics->move(object => $avatar, to => $this, preposition => $prep)) {
	        $this->msg('sit', %_);
	}
	else {
		fail "You can't sit there.";
	}
}
