private void AddComponentLazy(ModSessionComponent component, Ob_ModSessionComponent config) { foreach (var dep in component.Dependencies) { if (m_dependencySatisfyingComponents.ContainsKey(dep)) { continue; } ModSessionComponentRegistry.CreateComponent factory; if (!_factories.TryGetValue(dep, out factory)) { throw new ArgumentException("Can't add " + component.GetType() + " since we don't have dependency " + dep + " loaded or a factory for it"); } AddComponentLazy(factory(), null); } // Safe to add to the end of the ordered list. var item = new RuntimeSessionComponent(component, config); foreach (var dep in component.Dependencies) { var depRes = m_dependencySatisfyingComponents[dep]; depRes.Dependents.Add(item); item.Dependencies.Add(item); item.Component.SatisfyDependency(depRes.Component); } Insert(item); m_orderedComponentList.Add(item); if (item.Config != null) { item.Component.LoadConfiguration(item.Config); } item.Component.Attached(this); ComponentAttached?.Invoke(item.Component); }
public override void LoadConfiguration(Ob_ModSessionComponent configOriginal) { var config = configOriginal as Ob_CompositeNameGenerator; if (config == null) { Log(MyLogSeverity.Critical, "Configuration type {0} doesn't match component type {1}", configOriginal.GetType(), GetType()); return; } var total = 0f; foreach (var k in config.Generators) { total += k.Weight; } m_generators.Clear(); var cs = 0f; foreach (var k in config.Generators) { cs += k.Weight / total; var nameGenDef = (Ob_ModSessionComponent)k.Generator; var component = ModSessionComponentRegistry.Get(nameGenDef).Activator(); component.LoadConfiguration(nameGenDef); m_generators.Add(new KeyValuePair <NameGeneratorBase, float>((NameGeneratorBase)component, cs)); } }
private void ReadComponent(MemoryStream stream, out ModSessionComponent com, out Ob_ModSessionComponent ob) { var code = stream.ReadInt32(); var desc = ModSessionComponentRegistry.Get(stream.ReadUInt64()); ob = desc.SerializeFromXml.Invoke(stream.ReadString()); com = desc.Activator.Invoke(); m_hashCodeToComponent.Add(code, com); Manager.FallbackLogger.Log(MyLogSeverity.Debug, "Read component of type {0} from bootstrapper. ID={1}", com.GetType().Name, code); }
public override void LoadConfiguration(Ob_ModSessionComponent configOriginal) { var config = configOriginal as Ob_BuildingDatabase; if (config == null) { Log(MyLogSeverity.Critical, "Configuration type {0} doesn't match component type {1}", configOriginal.GetType(), GetType()); return; } }
public override void LoadConfiguration(Ob_ModSessionComponent config) { var ob = config as Ob_InfinitePlanets; if (ob == null) { Log(MyLogSeverity.Critical, "Configuration type {0} doesn't match component type {1}", config.GetType(), GetType()); return; } _config = MyAPIGateway.Utilities.SerializeFromXML <Ob_InfinitePlanets>(MyAPIGateway.Utilities.SerializeToXML(config)); }
public override void LoadConfiguration(Ob_ModSessionComponent config) { if (config == null) { return; } if (config is Ob_SessionBootstrapper) { return; } Manager?.FallbackLogger.Log(MyLogSeverity.Critical, "Configuration type {0} doesn't match component type {1}", config.GetType(), GetType()); }
public override void LoadConfiguration(Ob_ModSessionComponent config) { if (config == null) { return; } if (config is Ob_BuildingControlCommands) { return; } Log(MyLogSeverity.Critical, "Configuration type {0} doesn't match component type {1}", config.GetType(), GetType()); }
public override void LoadConfiguration(Ob_ModSessionComponent config) { base.LoadConfiguration(config); var up = config as Ob_CustomLogger; if (up == null) { Log(MyLogSeverity.Critical, "Configuration type {0} doesn't match component type {1}", config.GetType(), GetType()); return; } m_file = up.Filename; }
public override void LoadConfiguration(Ob_ModSessionComponent configOriginal) { var config = configOriginal as Ob_StationGeneratorManager; if (config == null) { Log(MyLogSeverity.Critical, "Configuration type {0} doesn't match component type {1}", configOriginal.GetType(), GetType()); return; } BlockLimit = config.BlockLimitMultiplier; }
public override void LoadConfiguration(Ob_ModSessionComponent configBase) { var config = configBase as Ob_ProceduralStation; if (config == null) { Log(MyLogSeverity.Critical, "Configuration type {0} doesn't match component type {1}", configBase.GetType(), GetType()); return; } ConfigReference = config.Clone(); RebuildNoiseModules(); }
public override void LoadConfiguration(Ob_ModSessionComponent config) { if (config == null) { return; } if (config is Ob_ProceduralWorldManager) { return; } Log(MyLogSeverity.Critical, "Configuration type {0} doesn't match component type {1}", config.GetType(), GetType()); }
public override void LoadConfiguration(Ob_ModSessionComponent config) { if (config == null) { return; } var up = config as Ob_LoggerBase; if (up == null) { Log(MyLogSeverity.Critical, "Configuration type {0} doesn't match component type {1}", config.GetType(), GetType()); return; } LogLevel = up.LogLevel; }
public override void LoadConfiguration(Ob_ModSessionComponent configOriginal) { var config = configOriginal as Ob_ProceduralFactions; if (config == null) { Log(MyLogSeverity.Critical, "Configuration type {0} doesn't match component type {1}", configOriginal.GetType(), GetType()); return; } m_factionShiftBase = config.FactionShiftBase; m_factionDensity = config.FactionDensity; m_seed = config.Seed; RebuildNoiseModule(); }
public void Register(ModSessionComponent component, Ob_ModSessionComponent config = null) { foreach (var sat in component.SuppliedComponents) { if (m_dependencySatisfyingComponents.ContainsKey(sat)) { throw new ArgumentException("We already have a component satisfying the " + sat + " dependency; we can't have two."); } } if (!m_attached) { var rsc = new RuntimeSessionComponent(component, config); Insert(rsc); return; } m_componentsToModify.Enqueue(new RemoveOrAdd(component, false, config)); }
public override void LoadConfiguration(Ob_ModSessionComponent configOriginal) { var config = configOriginal as Ob_StatisticalNameGenerator; if (config == null) { Log(MyLogSeverity.Critical, "Configuration type {0} doesn't match component type {1}", configOriginal.GetType(), GetType()); return; } if (config.StatisticsDatabase.Equals("res:english", StringComparison.OrdinalIgnoreCase)) { m_names = EnglishNames; } else { m_names = UnpackDictionary(config.StatisticsDatabase); } }
public override void LoadConfiguration(Ob_ModSessionComponent config) { var up = config as Ob_AutomaticAsteroidFields; if (up == null) { Log(MyLogSeverity.Critical, "Configuration type {0} doesn't match component type {1}", config.GetType(), GetType()); return; } m_fieldsByPlanet.Clear(); foreach (var x in up.AsteroidFields) { foreach (var k in x.OnPlanets) { List <Ob_AsteroidField> fields; if (!m_fieldsByPlanet.TryGetValue(k, out fields)) { m_fieldsByPlanet[k] = fields = new List <Ob_AsteroidField>(); } fields.Add(x.Field); } } }
public static ModSessionComponentDescriptor Get(Ob_ModSessionComponent t) { ModSessionComponentDescriptor res; if (m_descByType.TryGetValue(t.GetType(), out res)) { return(res); } res = null; foreach (var v in m_descByKey.Values) { if (v.Tester.Invoke(t)) { res = v; break; } } if (res == null) { throw new ArgumentException("Couldn't find session component for object builder of type " + t.GetType()); } return(res); }
public override void LoadConfiguration(Ob_ModSessionComponent config) { var ob = config as Ob_AsteroidField; if (ob == null) { Log(MyLogSeverity.Critical, "Configuration type {0} doesn't match component type {1}", config.GetType(), GetType()); return; } Log(MyLogSeverity.Debug, "Loading configuration for {0}", GetType().Name); using (this.IndentUsing()) { Transform = ob.Transform; Log(MyLogSeverity.Debug, "Position is {0}", Transform.Translation); Log(MyLogSeverity.Debug, "Up is {0}", ob.Transform.Up); if (ob.ShapeSphere != null) { Shape = new AsteroidSphereShape(ob.ShapeSphere); Log(MyLogSeverity.Debug, "Shape is a sphere. Radius is {0}m, thickness is {1}m", (ob.ShapeSphere.InnerRadius + ob.ShapeSphere.OuterRadius) / 2, ob.ShapeSphere.OuterRadius - ob.ShapeSphere.InnerRadius); Log(MyLogSeverity.Debug, "Viewable at {0}", Vector3D.Transform( new Vector3D((ob.ShapeSphere.OuterRadius + ob.ShapeSphere.InnerRadius) / 2, 0, 0), Transform)); } else if (ob.ShapeRing != null) { Shape = new AsteroidRingShape(ob.ShapeRing); Log(MyLogSeverity.Debug, "Shape is a ring. Radius is {0}m, width is {1}m, height is {2}m", (ob.ShapeRing.InnerRadius + ob.ShapeRing.OuterRadius) / 2, ob.ShapeRing.OuterRadius - ob.ShapeRing.InnerRadius, (ob.ShapeRing.OuterRadius - ob.ShapeRing.InnerRadius) * ob.ShapeRing.VerticalScaleMult); Log(MyLogSeverity.Debug, "Viewable at {0}", Vector3D.Transform( new Vector3D((ob.ShapeRing.OuterRadius + ob.ShapeRing.InnerRadius) / 2, 0, 0), Transform)); } else { Log(MyLogSeverity.Debug, "Shape is unknown"); throw new ArgumentException(); } Log(MyLogSeverity.Debug, "Seed is {0}", ob.Seed); m_layers = ob.Layers ?? new AsteroidLayer[0]; for (var i = 0; i < m_layers.Length; i++) { var layer = m_layers[i]; Log(MyLogSeverity.Debug, "Layer {0}", i + 1); using (this.IndentUsing()) { Log(MyLogSeverity.Debug, "Density = {0}", layer.AsteroidDensity); Log(MyLogSeverity.Debug, "Asteroid size = {0} - {1}", layer.AsteroidMinSize, layer.AsteroidMaxSize); Log(MyLogSeverity.Debug, "Spacing {0}", layer.AsteroidSpacing); Log(MyLogSeverity.Debug, "Usable space {0}", layer.UsableRegion); Log(MyLogSeverity.Debug, "Prohibited ores {0}", string.Join(", ", layer.ProhibitsOre)); Log(MyLogSeverity.Debug, "Required ores {0}", string.Join(", ", layer.RequiresOre)); } } Seed = ob.Seed; } }
public abstract void LoadConfiguration(Ob_ModSessionComponent config);
public RuntimeSessionComponent(ModSessionComponent c, Ob_ModSessionComponent cfg) { Component = c; Config = cfg; }
public RemoveOrAdd(ModSessionComponent c, bool r, Ob_ModSessionComponent cfg = null) { Component = c; Remove = r; Config = cfg; }