Esempio n. 1
0
        private void CheckReactions()
        {
            foreach (var reaction in _prototypeManager.EnumeratePrototypes <ReactionPrototype>())
            {
                foreach (var reactant in reaction.Reactants.Keys)
                {
                    if (!_prototypeManager.HasIndex <ReagentPrototype>(reactant))
                    {
                        Logger.ErrorS(
                            "chem", "Reaction {reaction} has unknown reactant {reagent}.",
                            reaction.ID, reactant);
                    }
                }

                foreach (var product in reaction.Products.Keys)
                {
                    if (!_prototypeManager.HasIndex <ReagentPrototype>(product))
                    {
                        Logger.ErrorS(
                            "chem", "Reaction {reaction} has unknown product {product}.",
                            reaction.ID, product);
                    }
                }
            }
        }
Esempio n. 2
0
    private void AddInventoryFromPrototype(EntityUid uid, Dictionary <string, uint>?entries,
                                           InventoryType type,
                                           SharedVendingMachineComponent?component = null)
    {
        if (!Resolve(uid, ref component) || entries == null)
        {
            return;
        }

        var inventory = new List <VendingMachineInventoryEntry>();

        foreach (var(id, amount) in entries)
        {
            if (_prototypeManager.HasIndex <EntityPrototype>(id))
            {
                inventory.Add(new VendingMachineInventoryEntry(type, id, amount));
            }
        }

        switch (type)
        {
        case InventoryType.Regular:
            component.Inventory.AddRange(inventory);
            break;

        case InventoryType.Emagged:
            component.EmaggedInventory.AddRange(inventory);
            break;

        case InventoryType.Contraband:
            component.ContrabandInventory.AddRange(inventory);
            break;
        }
    }
Esempio n. 3
0
            private void VerifyEntitiesExist()
            {
                var fail          = false;
                var entities      = RootNode.GetNode <YamlSequenceNode>("entities");
                var reportedError = new HashSet <string>();

                foreach (var entityDef in entities.Cast <YamlMappingNode>())
                {
                    if (entityDef.TryGetNode("type", out var typeNode))
                    {
                        var type = typeNode.AsString();
                        if (!_prototypeManager.HasIndex <EntityPrototype>(type) && !reportedError.Contains(type))
                        {
                            Logger.Error("Missing prototype for map: {0}", type);
                            fail = true;
                            reportedError.Add(type);
                        }
                    }
                }

                if (fail)
                {
                    throw new InvalidOperationException(
                              "Found missing prototypes in map file. Missing prototypes have been dumped to logs.");
                }
            }
        private void OnInit(EntityUid uid, AccessReaderComponent reader, ComponentInit args)
        {
            var allTags = reader.AccessLists.SelectMany(c => c).Union(reader.DenyTags);

            foreach (var level in allTags)
            {
                if (!_prototypeManager.HasIndex <AccessLevelPrototype>(level))
                {
                    Logger.ErrorS("access", $"Invalid access level: {level}");
                }
            }
        }
        protected override void Startup()
        {
            base.Startup();

            foreach (var material in _materialIdRequirements.Keys)
            {
                if (!_prototypeManager.HasIndex <StackPrototype>(material))
                {
                    Logger.Error($"No {nameof(StackPrototype)} found with id {material}");
                }
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Spawns the players entity.
        /// </summary>
        /// <param name="session"></param>
        public void SpawnPlayerMob(IPlayerSession session)
        {
            // TODO: There's probably a much better place to do this.
            var prototype = "HumanMob";

            if (_prototypeManager.HasIndex <EntityPrototype>("HumanMob_Content"))
            {
                prototype = "HumanMob_Content";
            }
            IEntity entity = _entityManager.ForceSpawnEntityAt(prototype, new Vector2(0, 0), 1); //TODO: Fix this

            session.AttachToEntity(entity);
        }
Esempio n. 7
0
    public override void Initialize()
    {
        base.Initialize();

        DebugTools.Assert(_prototypeManager.HasIndex <ExplosionPrototype>(DefaultExplosionPrototypeId));

        // handled in ExplosionSystem.GridMap.cs
        SubscribeLocalEvent <GridRemovalEvent>(OnGridRemoved);
        SubscribeLocalEvent <GridStartupEvent>(OnGridStartup);
        SubscribeLocalEvent <ExplosionResistanceComponent, GetExplosionResistanceEvent>(OnGetResistance);
        SubscribeLocalEvent <TileChangedEvent>(OnTileChanged);

        SubscribeLocalEvent <RoundRestartCleanupEvent>(OnReset);

        // Handled by ExplosionSystem.Processing.cs
        SubscribeLocalEvent <MapChangedEvent>(OnMapChanged);

        // handled in ExplosionSystemAirtight.cs
        SubscribeLocalEvent <AirtightComponent, DamageChangedEvent>(OnAirtightDamaged);
        SubscribeCvars();
        InitAirtightMap();
    }
        private void TryWriteToTargetId(string newFullName, string newJobTitle, List <string> newAccessList)
        {
            if (!PrivilegedIdIsAuthorized() || _targetIdContainer.ContainedEntity == null)
            {
                return;
            }

            var targetIdEntity = _targetIdContainer.ContainedEntity;

            var targetIdComponent = targetIdEntity.GetComponent <IdCardComponent>();

            targetIdComponent.FullName = newFullName;
            targetIdComponent.JobTitle = newJobTitle;

            if (!newAccessList.TrueForAll(x => _prototypeManager.HasIndex <AccessLevelPrototype>(x)))
            {
                Logger.Warning("Tried to write unknown access tag.");
                return;
            }
            var targetIdAccess = targetIdEntity.GetComponent <AccessComponent>();

            targetIdAccess.SetTags(newAccessList);
        }
Esempio n. 9
0
        /// <summary>
        /// Called when the "Submit" button in the UI gets pressed.
        /// Writes data passed from the UI into the ID stored in <see cref="TargetIdSlot"/>, if present.
        /// </summary>
        private void TryWriteToTargetId(string newFullName, string newJobTitle, List <string> newAccessList)
        {
            if (TargetIdSlot.Item is not {
                Valid: true
            } targetIdEntity || !PrivilegedIdIsAuthorized())
            {
                return;
            }

            var cardSystem = EntitySystem.Get <IdCardSystem>();

            cardSystem.TryChangeFullName(targetIdEntity, newFullName);
            cardSystem.TryChangeJobTitle(targetIdEntity, newJobTitle);

            if (!newAccessList.TrueForAll(x => _prototypeManager.HasIndex <AccessLevelPrototype>(x)))
            {
                Logger.Warning("Tried to write unknown access tag.");
                return;
            }

            var accessSystem = EntitySystem.Get <AccessSystem>();

            accessSystem.TrySetTags(targetIdEntity, newAccessList);
        }