private void SimpleModify(MyObjectBuilderType obType, string subType, string modelRelativePath, float?falloff_min = null, float?intensity_min = null) { var lightDef = GetLightDefById(obType, subType); if (lightDef == null) { Log.Error($"Couldn't find def: {obType.ToString()}/{subType}"); return; } var backup = new BackupDefData(); if (modelRelativePath != null) { backup.Model = lightDef.Model; lightDef.Model = Path.Combine(ModContext.ModPath, modelRelativePath); } if (falloff_min.HasValue) { backup.LightFalloff = lightDef.LightFalloff; // MyBounds is struct, gets copied lightDef.LightFalloff.Min = falloff_min.Value; } lightDef.LightFalloff.Default = 1f; if (intensity_min.HasValue) { backup.LightIntensity = lightDef.LightIntensity; lightDef.LightIntensity.Min = intensity_min.Value; } AddDefBackup(lightDef.Id, backup); }
public override string ToString() { string typeId = !TypeId.IsNull ? TypeId.ToString() : "(null)"; string subtypeName = !string.IsNullOrEmpty(SubtypeName) ? SubtypeName : "(null)"; return(string.Format("{0}/{1}", typeId, subtypeName)); }
void Add(LightConfigurator settings, MyObjectBuilderType blockType, params string[] subtypes) { BlockHandling blockHandling; if (!monitorTypes.TryGetValue(blockType, out blockHandling)) { blockHandling = new BlockHandling(); monitorTypes.Add(blockType, blockHandling); } if (subtypes == null || subtypes.Length == 0) { blockHandling.ConfiguratorForAll = settings; } else { if (blockHandling.ConfiguratorPerSubtype == null) { blockHandling.ConfiguratorPerSubtype = new Dictionary <string, LightConfigurator>(); } foreach (var subtype in subtypes) { if (blockHandling.ConfiguratorPerSubtype.ContainsKey(subtype)) { SimpleLog.Error(this, $"Subtype '{subtype}' for type {blockType.ToString()} was already previously registered!"); continue; } blockHandling.ConfiguratorPerSubtype.Add(subtype, settings); } } }