#!/usr/bin/perl
#use Fcntl q{:flock};
#use Mooix::Thing;
run sub {
	my $this=shift;
	%_=@_;
	my $avatar = $_{avatar};

	# Handle the case of "sit up" and "sit bed", when the avatar
	# is already lying in the bed.
	if ($_{preposition} eq 'up' || $this == $avatar->location) {
        	my $prep = ($this->on_prepositions)[0];
		if (($avatar->preposition)[0] eq $prep) {
			fail "You're already seated."
		}
		my $lock = $avatar->getlock(LOCK_EX);
		if ($prep &&
		    $avatar->physics->move(object => $avatar, to => $this, preposition => $prep)) {
		    	$this->msg('situp', %_);
		}
		else {
			fail "You can't sit there.";
		}
	}
	else {
		# Regular sitting.
		$this->super(@_);
	}
}
