Пример #1
0
 private void OnComponentInit(EntityUid uid, DiceComponent component, ComponentInit args)
 {
     if (component.CurrentSide > component.Sides)
     {
         component.CurrentSide = component.Sides;
     }
 }
Пример #2
0
 private void OnExamined(EntityUid uid, DiceComponent dice, ExaminedEvent args)
 {
     //No details check, since the sprite updates to show the side.
     args.Message.PushNewline();
     args.Message.AddMarkup(Loc.GetString("dice-component-on-examine-message-part-1", ("sidesAmount", dice.Sides)));
     args.Message.PushNewline();
     args.Message.AddMarkup(Loc.GetString("dice-component-on-examine-message-part-2", ("currentSide", dice.CurrentSide)));
 }
Пример #3
0
        private void OnUseInHand(EntityUid uid, DiceComponent component, UseInHandEvent args)
        {
            if (args.Handled)
            {
                return;
            }

            args.Handled = true;
            Roll(uid, component);
        }
Пример #4
0
        public void Roll(EntityUid uid, DiceComponent die)
        {
            die.CurrentSide = _random.Next(1, (die.Sides / die.Step) + 1) * die.Step;

            SoundSystem.Play(Filter.Pvs(die.Owner), die.Sound.GetSound(), die.Owner, AudioHelpers.WithVariation(0.05f));

            if (!ComponentManager.TryGetComponent(uid, out SpriteComponent? sprite))
            {
                return;
            }

            // TODO DICE: Use a visualizer instead.
            sprite.LayerSetState(0, $"d{die.Sides}{die.CurrentSide}");
        }
Пример #5
0
 private void OnLand(EntityUid uid, DiceComponent component, LandEvent args)
 {
     Roll(uid, component);
 }
Пример #6
0
 private void OnActivate(EntityUid uid, DiceComponent component, ActivateInWorldEvent args)
 {
     Roll(uid, component);
 }
Пример #7
0
 private void OnUse(EntityUid uid, DiceComponent component, UseInHandEvent args)
 {
     Roll(uid, component);
 }