コード例 #1
0
        /// <summary>
        /// when sleeping component is added or removed, we do some stuff with other components.
        /// </summary>
        private void OnSleepStateChanged(EntityUid uid, MobStateComponent component, SleepStateChangedEvent args)
        {
            _prototypeManager.TryIndex <InstantActionPrototype>("Wake", out var wakeAction);
            if (args.FellAsleep)
            {
                EnsureComp <StunnedComponent>(uid);
                EnsureComp <KnockedDownComponent>(uid);

                var emitSound = EnsureComp <SpamEmitSoundComponent>(uid);
                emitSound.Sound          = new SoundCollectionSpecifier("Snores");
                emitSound.PlayChance     = 0.33f;
                emitSound.RollInterval   = 5f;
                emitSound.PopUp          = "sleep-onomatopoeia";
                emitSound.PitchVariation = 0.2f;

                if (wakeAction != null)
                {
                    var wakeInstance = new InstantAction(wakeAction);
                    wakeInstance.Cooldown = (_gameTiming.CurTime, _gameTiming.CurTime + TimeSpan.FromSeconds(15));
                    _actionsSystem.AddAction(uid, wakeInstance, null);
                }
                return;
            }
            if (wakeAction != null)
            {
                _actionsSystem.RemoveAction(uid, wakeAction);
            }

            RemComp <StunnedComponent>(uid);
            RemComp <KnockedDownComponent>(uid);
            RemComp <SpamEmitSoundComponent>(uid);
        }
コード例 #2
0
        protected override void OnComponentInit(EntityUid uid, SharedVendingMachineComponent sharedComponent, ComponentInit args)
        {
            base.OnComponentInit(uid, sharedComponent, args);

            var component = (VendingMachineComponent)sharedComponent;

            if (TryComp <ApcPowerReceiverComponent>(component.Owner, out var receiver))
            {
                TryUpdateVisualState(uid, null, component);
            }

            if (component.Action != null)
            {
                var action = new InstantAction(_prototypeManager.Index <InstantActionPrototype>(component.Action));
                _action.AddAction(uid, action, uid);
            }
        }
コード例 #3
0
        private void OnComponentInit(EntityUid uid, VendingMachineComponent component, ComponentInit args)
        {
            base.Initialize();

            if (TryComp <ApcPowerReceiverComponent>(component.Owner, out var receiver))
            {
                TryUpdateVisualState(uid, null, component);
            }

            if (component.Action != null)
            {
                var action = new InstantAction(_prototypeManager.Index <InstantActionPrototype>(component.Action));
                _action.AddAction(uid, action, uid);
            }

            InitializeFromPrototype(uid, component);
        }
コード例 #4
0
        private void OnInit(EntityUid uid, PolymorphedEntityComponent component, PolymorphComponentSetupEvent args)
        {
            if (component.Prototype.Forced)
            {
                return;
            }

            var act = new InstantAction()
            {
                Event       = new RevertPolymorphActionEvent(),
                EntityIcon  = component.Parent,
                Name        = Loc.GetString("polymorph-revert-action-name"),
                Description = Loc.GetString("polymorph-revert-action-description"),
                UseDelay    = TimeSpan.FromSeconds(component.Prototype.Delay),
            };

            _actions.AddAction(uid, act, null);
        }
コード例 #5
0
    private void OnInit(EntityUid uid, SpellbookComponent component, ComponentInit args)
    {
        //Negative charges means the spell can be used without it running out.
        foreach (var(id, charges) in component.WorldSpells)
        {
            var spell = new WorldTargetAction(_prototypeManager.Index <WorldTargetActionPrototype>(id));
            _actionsSystem.SetCharges(spell, charges < 0 ? null : charges);
            component.Spells.Add(spell);
        }

        foreach (var(id, charges) in component.InstantSpells)
        {
            var spell = new InstantAction(_prototypeManager.Index <InstantActionPrototype>(id));
            _actionsSystem.SetCharges(spell, charges < 0 ? null : charges);
            component.Spells.Add(spell);
        }

        foreach (var(id, charges) in component.EntitySpells)
        {
            var spell = new EntityTargetAction(_prototypeManager.Index <EntityTargetActionPrototype>(id));
            _actionsSystem.SetCharges(spell, charges < 0 ? null : charges);
            component.Spells.Add(spell);
        }
    }
コード例 #6
0
 public InstantAction(InstantAction toClone)
 {
     CopyFrom(toClone);
 }
コード例 #7
0
 public RequestPerformActionEvent(InstantAction action)
 {
     Action = action;
 }