view release on metacpan or search on metacpan
lib/Games/Construder/Server/Objects.pm view on Meta::CPAN
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
package Games::Construder::Server::Objects;
use common::sense;
use Games::Construder::Server::PCB;
use Games::Construder::Server::World;
use Games::Construder::Vector;
use Games::Construder::Logging;
use Games::Construder;
use Scalar::Util qw/weaken/;
=head1 NAME
Games::Construder::Server::Objects - Implementation of Object Type specific behaviour
=over 4
=cut
our %TYPES = (
lib/Games/Construder/Server/Player.pm view on Meta::CPAN
use common::sense;
use AnyEvent;
use Games::Construder::Server::World;
use Games::Construder::Server::UI;
use Games::Construder::Server::Objects;
use Games::Construder::Server::PatStorHandle;
use Games::Construder::Logging;
use Games::Construder::Vector;
use Time::HiRes qw/time/;
use base qw/Object::Event/;
use Scalar::Util qw/weaken/;
use Compress::LZF;
=head1 NAME
Games::Construder::Server::Player - Implementation of Player central Game Mechanics (the heart of the game)
=over 4
=cut
lib/Games/Construder/Server/Player.pm view on Meta::CPAN
}
}
sub init {
my ($self) = @_;
$self->load;
$self->save;
$self->set_vis_rad;
my $wself = $self;
weaken $wself;
my $tick_time = time;
my $msg_beacon_upd = 0;
my $save_tmr = 0;
$self->{tick_timer} = AE::timer 0.25, 0.25, sub {
my $cur = time;
my $dt = $cur - $tick_time;
$msg_beacon_upd += $dt;
if ($msg_beacon_upd > 2)
lib/Games/Construder/Server/Player.pm view on Meta::CPAN
});
return;
}
$self->check_assignment_positions;
# was it finished?!
return unless $self->{data}->{assignment};
$self->{uis}->{assignment_time}->show;
my $wself = $self;
weaken $wself;
$self->{assign_timer} = AE::timer 1, 1, sub {
$wself->check_assignment_positions;
# was it finished?!
return unless $self->{data}->{assignment};
$wself->{data}->{assignment}->{time} -= 1;
$wself->{uis}->{assignment_time}->show;
if ($wself->{data}->{assignment}->{time} <= 0) {
$wself->cancel_assignment;
}
lib/Games/Construder/Server/UI.pm view on Meta::CPAN
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
package Games::Construder::Server::UI;
use common::sense;
use Scalar::Util qw/weaken/;
require Exporter;
our @ISA = qw/Exporter/;
our @EXPORT = qw/
ui_player_score
ui_player_bio_warning
ui_player_tagger
/;
=head1 NAME
lib/Games/Construder/Server/UI.pm view on Meta::CPAN
=over 4
=cut
sub new {
my $this = shift;
my $class = ref ($this) || $this;
my $self = { @_ };
bless $self, $class;
weaken $self->{pl};
$self->init;
return $self
}
sub init {
}
sub layout {
lib/Games/Construder/Server/UI.pm view on Meta::CPAN
package Games::Construder::Server::UI::Score;
use Games::Construder::UI;
use base qw/Games::Construder::Server::UI/;
sub layout {
my ($self, $hl) = @_;
if ($hl) {
my $wself = $self;
weaken $wself;
$self->{upd_score_hl_tmout} = AE::timer 1.5, 0, sub {
$wself->show;
delete $wself->{upd_score_hl_tmout};
};
}
my $score = $self->{pl}->{data}->{score};
ui_hud_window ([center => "up"],
[box => {
lib/Games/Construder/Server/UI.pm view on Meta::CPAN
sub handle_command {
my ($self, $cmd) = @_;
}
sub layout {
my ($self, $msg) = @_;
my $wself = $self;
weaken $wself;
$self->{msg_tout} = AE::timer (3, 0, sub {
$wself->hide;
delete $wself->{msg_tout};
});
ui_hud_window_transparent (
[center => "center", -0.25],
ui_warning ($msg)
);
}
package Games::Construder::Server::UI::MsgBox;
use Games::Construder::UI;
use base qw/Games::Construder::Server::UI/;
sub layout {
my ($self, $error, $msg) = @_;
my $wself = $self;
weaken $wself;
$self->{msg_tout} = AE::timer (($error ? 7 : 3), 0, sub {
$wself->hide;
delete $wself->{msg_tout};
});
ui_hud_window_transparent (
[center => "center", 0, 0.15],
$error
? ui_warning ($msg)
: ui_notice ($msg)
lib/Games/Construder/Server/UI.pm view on Meta::CPAN
package Games::Construder::Server::UI::Status;
use Games::Construder::UI;
use Games::Construder::Server::World;
use base qw/Games::Construder::Server::UI/;
sub init {
my ($self) = @_;
my $wself = $self;
weaken $wself;
$self->{tmr} = AE::timer 0, 1, sub {
$wself->show;
};
}
sub commands {
my ($self) = @_;
$self->{cmd_need_select_boxes} = 1;
(
lib/Games/Construder/Server/UI.pm view on Meta::CPAN
my ($self, $bio_usage) = @_;
my $abs_pos = $self->{pl}->get_pos_normalized;
my $chnk_pos = $self->{pl}->get_pos_chnk;
my $sec_pos = $self->{pl}->get_pos_sector;
my $sinfo = world_sector_info ($chnk_pos);
if (ref $bio_usage) {
my $wself = $self;
weaken $wself;
$self->{bio_intake} = $bio_usage;
$self->{bio_intake_tmr} = AE::timer 2, 0, sub {
delete $wself->{bio_intake};
$wself->show;
delete $wself->{bio_intake_tmr};
};
} elsif ($bio_usage) {
my $wself = $self;
weaken $wself;
$self->{bio_usage} = $bio_usage;
$self->{bio_usage_tmr} = AE::timer 2, 0, sub {
delete $wself->{bio_usage};
$wself->show;
delete $wself->{bio_usage_tmr};
};
}
ui_hud_window (
[right => 'up'],