Exemple #1
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);
        }
    }
Exemple #2
0
    private void OnBoltInit(EntityUid uid, BoltActionBarrelComponent component, ComponentInit args)
    {
        component.SpawnedAmmo   = new Stack <EntityUid>(component.Capacity - 1);
        component.AmmoContainer = uid.EnsureContainer <Container>($"{component.GetType()}-ammo-container", out var existing);

        if (existing)
        {
            foreach (var entity in component.AmmoContainer.ContainedEntities)
            {
                component.SpawnedAmmo.Push(entity);
                component.UnspawnedCount--;
            }
        }

        component.ChamberContainer = uid.EnsureContainer <ContainerSlot>($"{component.GetType()}-chamber-container");

        if (TryComp(uid, out AppearanceComponent? appearanceComponent))
        {
            appearanceComponent.SetData(MagazineBarrelVisuals.MagLoaded, true);
        }

        component.Dirty(EntityManager);
        UpdateBoltAppearance(component);
    }
Exemple #3
0
    private void OnComponentInit(EntityUid uid, ImmovableRodComponent component, ComponentInit args)
    {
        if (EntityManager.TryGetComponent(uid, out PhysicsComponent? phys))
        {
            phys.LinearDamping = 0f;
            phys.Friction      = 0f;
            phys.BodyStatus    = BodyStatus.InAir;

            if (!component.RandomizeVelocity)
            {
                return;
            }

            var xform = Transform(uid);
            var vel   = component.DirectionOverride.Degrees switch
            {
                0f => _random.NextVector2(component.MinSpeed, component.MaxSpeed),
                _ => xform.WorldRotation.RotateVec(component.DirectionOverride.ToVec()) * _random.NextFloat(component.MinSpeed, component.MaxSpeed)
            };

            phys.ApplyLinearImpulse(vel);
            xform.LocalRotation = (vel - xform.WorldPosition).ToWorldAngle() + MathHelper.PiOver2;
        }
    }
Exemple #4
0
 private void HandleInit(EntityUid uid, PointLightComponent component, ComponentInit args)
 {
     UpdateMask(component);
 }
Exemple #5
0
 private void OnInit(EntityUid uid, PoweredLightComponent light, ComponentInit args)
 {
     light.LightBulbContainer = _containerSystem.EnsureContainer <ContainerSlot>(uid, LightBulbContainer);
     _signalSystem.EnsureReceiverPorts(uid, light.OnPort, light.OffPort, light.TogglePort);
 }
Exemple #6
0
 private void OnComponentInit(EntityUid uid, ItemCabinetComponent cabinet, ComponentInit args)
 {
     _itemSlotsSystem.AddItemSlot(uid, cabinet.Name, cabinet.CabinetSlot);
 }
 private void OnMetabolizerInit(EntityUid uid, MetabolizerComponent component, ComponentInit args)
 {
     if (!component.SolutionOnBody)
     {
         _solutionContainerSystem.EnsureSolution(uid, component.SolutionName);
     }
     else
     {
         if (EntityManager.TryGetComponent <MechanismComponent>(uid, out var mech))
         {
             if (mech.Body != null)
             {
                 _solutionContainerSystem.EnsureSolution((mech.Body).Owner, component.SolutionName);
             }
         }
     }
 }
 private void OnComponentInit(EntityUid uid, SharedChemMasterComponent component, ComponentInit args)
 {
     _itemSlotsSystem.AddItemSlot(uid, $"{component.Name}-beaker", component.BeakerSlot);
 }
 private void OnFireExtinguisherInit(EntityUid uid, FireExtinguisherComponent component, ComponentInit args)
 {
     if (component.HasSafety)
     {
         UpdateAppearance(uid, component);
     }
 }
Exemple #10
0
        private void OnConstructionInit(EntityUid uid, ConstructionComponent construction, ComponentInit args)
        {
            if (GetCurrentGraph(uid, construction) is not {
            } graph)
            {
                _sawmill.Warning($"Prototype {EntityManager.GetComponent<MetaDataComponent>(construction.Owner).EntityPrototype?.ID}'s construction component has an invalid graph specified.");
                return;
            }

            if (GetNodeFromGraph(graph, construction.Node) is not {
            } node)
            {
                _sawmill.Warning($"Prototype {EntityManager.GetComponent<MetaDataComponent>(construction.Owner).EntityPrototype?.ID}'s construction component has an invalid node specified.");
                return;
            }

            ConstructionGraphEdge?edge = null;

            if (construction.EdgeIndex is {} edgeIndex)
            {
                if (GetEdgeFromNode(node, edgeIndex) is not {
                } currentEdge)
                {
                    _sawmill.Warning($"Prototype {EntityManager.GetComponent<MetaDataComponent>(construction.Owner).EntityPrototype?.ID}'s construction component has an invalid edge index specified.");
                    return;
                }

                edge = currentEdge;
            }

            if (construction.TargetNode is {} targetNodeId)
            {
                if (GetNodeFromGraph(graph, targetNodeId) is not {
                } targetNode)
                {
                    _sawmill.Warning($"Prototype {EntityManager.GetComponent<MetaDataComponent>(construction.Owner).EntityPrototype?.ID}'s construction component has an invalid target node specified.");
                    return;
                }

                UpdatePathfinding(uid, graph, node, targetNode, edge, construction);
            }
        }
 private void OnMachineInit(EntityUid uid, MachineComponent component, ComponentInit args)
 {
     component.BoardContainer = _container.EnsureContainer <Container>(uid, MachineFrameComponent.BoardContainer);
     component.PartContainer  = _container.EnsureContainer <Container>(uid, MachineFrameComponent.PartContainer);
 }
 private void OnDeviceInitialize(EntityUid uid, AtmosDeviceComponent component, ComponentInit args)
 {
     JoinAtmosphere(component);
 }
 private void OnFoldableInit(EntityUid uid, FoldableComponent component, ComponentInit args)
 {
     SetFolded(component, component.IsFolded);
 }
        private void OnInit(EntityUid uid, PuddleComponent component, ComponentInit args)
        {
            var solution = _solutionContainerSystem.EnsureSolution(uid, component.SolutionName);

            solution.MaxVolume = FixedPoint2.New(1000);
        }
Exemple #15
0
        private void OnComponentInit(EntityUid uid, ServerStorageComponent storageComp, ComponentInit args)
        {
            base.Initialize();

            // ReSharper disable once StringLiteralTypo
            storageComp.Storage = _containerSystem.EnsureContainer <Container>(uid, "storagebase");
            storageComp.Storage.OccludesLight = storageComp.OccludesLight;
            UpdateStorageVisualization(uid, storageComp);
            RecalculateStorageUsed(storageComp);
            UpdateStorageUI(uid, storageComp);
        }
 private void OnKnockInit(EntityUid uid, KnockedDownComponent component, ComponentInit args)
 {
     _standingStateSystem.Down(uid);
 }
 private void OnInit(EntityUid uid, SignalSwitchComponent component, ComponentInit args)
 {
     _signalSystem.EnsureTransmitterPorts(uid, component.OnPort, component.OffPort);
 }
Exemple #18
0
 private void OnInit(EntityUid uid, PoweredLightComponent light, ComponentInit args)
 {
     light.LightBulbContainer = light.Owner.EnsureContainer <ContainerSlot>("light_bulb");
 }
 protected virtual void OnComponentInit(EntityUid uid, IdentityComponent component, ComponentInit args)
 {
     component.IdentityEntitySlot = _container.EnsureContainer <ContainerSlot>(uid, SlotName);
 }
 private void OnInit(EntityUid uid, LightReplacerComponent replacer, ComponentInit args)
 {
     replacer.InsertedBulbs = ContainerHelpers.EnsureContainer <Container>(replacer.Owner, "light_replacer_storage");
 }
Exemple #21
0
    private void InitSolution(EntityUid uid, SolutionContainerManagerComponent component, ComponentInit args)
    {
        foreach (var keyValue in component.Solutions)
        {
            var solutionHolder = keyValue.Value;
            if (solutionHolder.MaxVolume == FixedPoint2.Zero)
            {
                solutionHolder.MaxVolume = solutionHolder.TotalVolume > solutionHolder.InitialMaxVolume
                    ? solutionHolder.TotalVolume
                    : solutionHolder.InitialMaxVolume;
            }

            UpdateAppearance(uid, solutionHolder);
        }
    }
Exemple #22
0
        private void OnComponentInit(EntityUid uid, VendingMachineComponent component, ComponentInit args)
        {
            base.Initialize();

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

            InitializeFromPrototype(uid, component);
        }
 private void OnComponentInit(EntityUid uid, BarSignComponent component, ComponentInit args)
 {
     UpdateBarSignVisuals(component);
 }
        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);
            }
        }
Exemple #25
0
 private void OnComponentInit(EntityUid uid, SharedIdCardConsoleComponent component, ComponentInit args)
 {
     _itemSlotsSystem.AddItemSlot(uid, $"{component.Name}-privilegedId", component.PrivilegedIdSlot);
     _itemSlotsSystem.AddItemSlot(uid, $"{component.Name}-targetId", component.TargetIdSlot);
 }
        private void OnMapAdded(EntityUid uid, MapComponent component, ComponentInit args)
        {
            var msg = new MapChangedEvent(component.WorldMap, true);

            EntityManager.EventBus.RaiseLocalEvent(uid, msg);
        }
        /// Fly stuff

        private void OnFliesInit(EntityUid uid, FliesComponent component, ComponentInit args)
        {
            component.VirtFlies = EntityManager.SpawnEntity("AmbientSoundSourceFlies", Transform(uid).Coordinates);
            Transform(component.VirtFlies).AttachParent(uid);
        }
        private void OnGridInit(EntityUid uid, MapGridComponent component, ComponentInit args)
        {
            var msg = new GridInitializeEvent(uid, component.GridIndex);

            EntityManager.EventBus.RaiseLocalEvent(uid, msg);
        }
        private void OnComponentInit(EntityUid uid, MedicalScannerComponent scannerComponent, ComponentInit args)
        {
            base.Initialize();

            scannerComponent.BodyContainer = scannerComponent.Owner.EnsureContainer <ContainerSlot>($"{scannerComponent.Name}-bodyContainer");
            UpdateUserInterface(uid, scannerComponent);
        }
 private void OnSlowInit(EntityUid uid, SlowedDownComponent component, ComponentInit args)
 {
     _movementSpeedModifierSystem.RefreshMovementSpeedModifiers(uid);
 }