예제 #1
0
        public void AddStructure(Structure structure)
        {
            if (Structures.Any(x => x.Name == structure.Name))
            {
                return;
            }

            Structures.Add(structure);
        }
예제 #2
0
        public bool ContainsVoxelFilename(string filename, MyObjectBuilder_EntityBase[] additionalList)
        {
            bool contains = Structures.Any(s => s is StructureVoxelModel && Path.GetFileNameWithoutExtension(((StructureVoxelModel)s).Name).ToUpper() == Path.GetFileNameWithoutExtension(filename).ToUpper()) || SpaceEngineersCore.ManageDeleteVoxelList.Any(f => Path.GetFileNameWithoutExtension(f).ToUpper() == Path.GetFileNameWithoutExtension(filename).ToUpper());

            if (contains || additionalList == null)
            {
                return(contains);
            }

            contains |= additionalList.Any(s => s is MyObjectBuilder_VoxelMap && Path.GetFileNameWithoutExtension(((MyObjectBuilder_VoxelMap)s).StorageName).ToUpper() == Path.GetFileNameWithoutExtension(filename).ToUpper());

            return(contains);
        }
        /// <summary>
        ///     environment-id in {Category}/{Name} format
        /// </summary>
        /// <param name="environmentIdentifier"></param>
        /// <returns></returns>
        private async Task <EnvironmentExportDefinition> CreateExportDefinition(string environmentIdentifier)
        {
            var envSplit = environmentIdentifier.Split('/');

            var envCategory  = envSplit[0];
            var envName      = envSplit[1];
            var selectedKeys = new HashSet <string>(StringComparer.OrdinalIgnoreCase);

            if (Structures?.Any() == true)
            {
                foreach (var structure in Structures)
                {
                    var structSplit   = structure.Split('/');
                    var structName    = structSplit[0];
                    var structVersion = structSplit[1];

                    var request = await RestRequest.Make(Output)
                                  .Post(new Uri(new Uri(ConfigServiceEndpoint),
                                                $"v1/inspect/structure/compile/{envCategory}/{envName}/{structName}/{structVersion}"),
                                        new StringContent(string.Empty, Encoding.UTF8))
                                  .ReceiveObject <StructureInspectionResult>()
                                  .ReceiveString();

                    var inspectionResult = await request.Take <StructureInspectionResult>();

                    if (inspectionResult is null)
                    {
                        throw new Exception($"could not analyze used keys of '{structName}/{structVersion}' in '{envCategory}/{envName}', " +
                                            "no data received from service");
                    }

                    if (!inspectionResult.CompilationSuccessful)
                    {
                        throw new Exception($"could not analyze used keys of '{structName}/{structVersion}' in '{envCategory}/{envName}', " +
                                            "compilation unsuccessful");
                    }

                    foreach (var usedKey in inspectionResult.UsedKeys)
                    {
                        selectedKeys.Add(usedKey);
                    }
                }
            }

            return(new EnvironmentExportDefinition(envCategory, envName, selectedKeys.ToList()));
        }
        /// <inheritdoc />
        protected override bool CheckParameters()
        {
            // check Base-Parameters
            base.CheckParameters();

            if (Environments is null || !Environments.Any())
            {
                Output.WriteError($"no {nameof(Environments)} given -- see help for more information");
                return(false);
            }

            // if environment doesn't contain '/' or contains multiple of them...
            var errEnvironments = Environments.Where(e => !e.Contains('/') ||
                                                     e.IndexOf('/') != e.LastIndexOf('/'))
                                  .ToArray();

            // ... complain about them
            if (errEnvironments.Any())
            {
                Output.WriteError($"given environments contain errors: {string.Join("; ", errEnvironments)}");
                return(false);
            }

            // Structures may be null or empty - but if not, all entries need to be in correct format
            if (Structures?.Any() == true)
            {
                // if environment doesn't contain '/' or contains multiple of them...
                var errStructures = Structures.Where(s => !s.Contains('/') ||
                                                     s.IndexOf('/') != s.LastIndexOf('/'))
                                    .ToArray();

                // ... complain about them
                if (errStructures.Any())
                {
                    Output.WriteError($"given structures contain errors: {string.Join("; ", errStructures)}");
                    return(false);
                }
            }

            return(true);
        }
예제 #5
0
파일: Screen.cs 프로젝트: thelpi/Rpeggiator
 /// <inheritdoc />
 internal override void BehaviorAtNewFrame()
 {
     _enemies.ForEach(enemy => enemy.BehaviorAtNewFrame());
     _gateTriggers.ForEach(gt => gt.BehaviorAtNewFrame());
     _gates.ForEach(g => g.BehaviorAtNewFrame());
     _rifts.ForEach(r => r.BehaviorAtNewFrame());
     _actionnedItems.ForEach(di => di.BehaviorAtNewFrame());
     _enemies.ForEach(e => e.CheckIfHasBeenHit());
     _enemies.RemoveAll(e =>
     {
         bool death = e.CheckDeath(this);
         if (death && e.LootQuantity > 0)
         {
             _pickableItems.Add(PickableItem.Loot(e, e.LootItemType, e.LootQuantity));
         }
         return(death);
     });
     _rifts.RemoveAll(r => r.CurrentLifePoints.LowerEqual(0));
     _actionnedItems.RemoveAll(di => di.IsDone || Structures.Any(cw => cw.Overlap(di)));
     _pickableItems.RemoveAll(pi => pi.Disapear);
 }
예제 #6
0
파일: Cell.cs 프로젝트: EttienneS/karthus
 internal bool HasStructureValue(string v)
 {
     return(Structures.Any(s => s.HasValue(v)));
 }