protected override void Init(MyObjectBuilder_DefinitionBase builder) { base.Init(builder); var ob = builder as MyObjectBuilder_VoxelMapCollectionDefinition; if (ob == null) { return; } MyDebug.AssertDebug(ob.StorageDefs != null); List <MyDefinitionId> defs = new List <MyDefinitionId>(); List <float> probabilities = new List <float>(); for (int i = 0; i < ob.StorageDefs.Length; i++) { var storage = ob.StorageDefs[i]; defs.Add(new MyDefinitionId(typeof(MyObjectBuilder_VoxelMapStorageDefinition), storage.Storage)); probabilities.Add(storage.Probability); } StorageFiles = new MyDiscreteSampler <MyDefinitionId>(defs, probabilities); Modifier = MyStringHash.GetOrCompute(ob.Modifier); }
public void Postprocess() { List<MySpawnGroupDefinition> spawnGroups = new List<MySpawnGroupDefinition>(); List<float> frequencies = new List<float>(); foreach (var spawnGroupId in m_spawnGroups) { MySpawnGroupDefinition spawnGroupDef = null; var defId = new MyDefinitionId(typeof(MyObjectBuilder_SpawnGroupDefinition), spawnGroupId); MyDefinitionManager.Static.TryGetDefinition(defId, out spawnGroupDef); Debug.Assert(spawnGroupDef != null, "Could not find spawn group for pirate antenna " + Name); if (spawnGroupDef != null) { spawnGroups.Add(spawnGroupDef); frequencies.Add(spawnGroupDef.Frequency); } } m_spawnGroups = null; if (frequencies.Count != 0) { SpawnGroupSampler = new MyDiscreteSampler<MySpawnGroupDefinition>(spawnGroups, frequencies); } }
public void Postprocess() { List <MySpawnGroupDefinition> spawnGroups = new List <MySpawnGroupDefinition>(); List <float> frequencies = new List <float>(); foreach (var spawnGroupId in m_spawnGroups) { MySpawnGroupDefinition spawnGroupDef = null; var defId = new MyDefinitionId(typeof(MyObjectBuilder_SpawnGroupDefinition), spawnGroupId); MyDefinitionManager.Static.TryGetDefinition(defId, out spawnGroupDef); Debug.Assert(spawnGroupDef != null, "Could not find spawn group for pirate antenna " + Name); if (spawnGroupDef != null) { spawnGroups.Add(spawnGroupDef); frequencies.Add(spawnGroupDef.Frequency); } } m_spawnGroups = null; if (frequencies.Count != 0) { SpawnGroupSampler = new MyDiscreteSampler <MySpawnGroupDefinition>(spawnGroups, frequencies); } }
protected override void Init(MyObjectBuilder_DefinitionBase builder) { base.Init(builder); var ob = builder as MyObjectBuilder_BotCollectionDefinition; if (ob == null) { return; } MyDebug.AssertDebug(ob.Bots != null); List <MyDefinitionId> bots = new List <MyDefinitionId>(); List <float> probabilities = new List <float>(); for (int i = 0; i < ob.Bots.Length; i++) { var bot = ob.Bots[i]; bots.Add(bot.Id); probabilities.Add(bot.Probability); } Bots = new MyDiscreteSampler <MyDefinitionId>(bots, probabilities); }
protected override void Init(MyObjectBuilder_DefinitionBase builder) { base.Init(builder); List <MyDefinitionId> values = new List <MyDefinitionId>(); List <float> densities = new List <float>(); foreach (MyPhysicalModelItem item in (builder as MyObjectBuilder_PhysicalModelCollectionDefinition).Items) { Type type = (Type)MyObjectBuilderType.ParseBackwardsCompatible(item.TypeId); MyDefinitionId id = new MyDefinitionId(type, item.SubtypeId); values.Add(id); densities.Add(item.Weight); } this.Items = new MyDiscreteSampler <MyDefinitionId>(values, densities); }
protected override void Init(MyObjectBuilder_DefinitionBase builder) { base.Init(builder); var ob = builder as MyObjectBuilder_PhysicalModelCollectionDefinition; MyDebug.AssertDebug(ob != null); MyDebug.AssertDebug(ob.Items != null); var definitions = new List<MyDefinitionId>(); var densities = new List<float>(); foreach (var item in ob.Items) { Type type = MyObjectBuilderType.ParseBackwardsCompatible(item.TypeId); var itemDef = new MyDefinitionId(type, item.SubtypeId); definitions.Add(itemDef); densities.Add(item.Weight); } Items = new MyDiscreteSampler<MyDefinitionId>(definitions, densities); }
protected override void Init(MyObjectBuilder_DefinitionBase builder) { base.Init(builder); var ob = builder as MyObjectBuilder_BotCollectionDefinition; if (ob == null) return; MyDebug.AssertDebug(ob.Bots != null); List<MyDefinitionId> bots = new List<MyDefinitionId>(); List<float> probabilities = new List<float>(); for (int i = 0; i < ob.Bots.Length; i++) { var bot = ob.Bots[i]; bots.Add(bot.Id); probabilities.Add(bot.Probability); } Bots = new MyDiscreteSampler<MyDefinitionId>(bots, probabilities); }
public void Postprocess() { List <MySpawnGroupDefinition> values = new List <MySpawnGroupDefinition>(); List <float> densities = new List <float>(); foreach (string str in this.m_spawnGroups) { MySpawnGroupDefinition definition = null; MyDefinitionId defId = new MyDefinitionId(typeof(MyObjectBuilder_SpawnGroupDefinition), str); MyDefinitionManager.Static.TryGetDefinition <MySpawnGroupDefinition>(defId, out definition); if (definition != null) { values.Add(definition); densities.Add(definition.Frequency); } } this.m_spawnGroups = null; if (densities.Count != 0) { this.SpawnGroupSampler = new MyDiscreteSampler <MySpawnGroupDefinition>(values, densities); } }
protected override void Init(MyObjectBuilder_DefinitionBase builder) { base.Init(builder); var ob = builder as MyObjectBuilder_PhysicalModelCollectionDefinition; MyDebug.AssertDebug(ob != null); MyDebug.AssertDebug(ob.Items != null); var definitions = new List <MyDefinitionId>(); var densities = new List <float>(); foreach (var item in ob.Items) { Type type = MyObjectBuilderType.ParseBackwardsCompatible(item.TypeId); var itemDef = new MyDefinitionId(type, item.SubtypeId); definitions.Add(itemDef); densities.Add(item.Weight); } Items = new MyDiscreteSampler <MyDefinitionId>(definitions, densities); }
protected override void Init(MyObjectBuilder_DefinitionBase builder) { base.Init(builder); var ob = builder as MyObjectBuilder_VoxelMapCollectionDefinition; if (ob == null) return; MyDebug.AssertDebug(ob.StorageDefs != null); List<MyDefinitionId> defs = new List<MyDefinitionId>(); List<float> probabilities = new List<float>(); for (int i = 0; i < ob.StorageDefs.Length; i++) { var storage = ob.StorageDefs[i]; defs.Add(new MyDefinitionId(typeof(MyObjectBuilder_VoxelMapStorageDefinition), storage.Storage)); probabilities.Add(storage.Probability); } StorageFiles = new MyDiscreteSampler<MyDefinitionId>(defs, probabilities); Modifier = MyStringHash.GetOrCompute(ob.Modifier); }
protected override void Init(MyObjectBuilder_DefinitionBase builder) { base.Init(builder); var ob = builder as MyObjectBuilder_GrowableEnvironmentItemDefinition; StepNameIndex = new Dictionary <string, int>(); List <float> stepProbabilities = new List <float>(); for (int i = 0; i < ob.GrowthSteps.Length; i++) { var step = ob.GrowthSteps[i]; Debug.Assert(step.Name != null && step.Name != "", String.Format("Growth step {0} in {1} is null!", i, ob.Id.SubtypeId)); StepNameIndex.Add(step.Name, i); stepProbabilities.Add(step.StartingProbability); } GrowthSteps = new ItemGrowthStep[ob.GrowthSteps.Length]; for (int i = 0; i < ob.GrowthSteps.Length; i++) { var step = ob.GrowthSteps[i]; int nextStep = -1; if (step.NextStep != null) { StepNameIndex.TryGetValue(step.NextStep, out nextStep); } Debug.Assert(step.TimeToNextStepInHours >= 0, "Time to next step for step {0} in {1} is negative!", step.Name, ob.Id.SubtypeId); var growthStep = new ItemGrowthStep() { Name = step.Name, NextStep = nextStep == i ? -1 : nextStep, // Self cycles are useless, protect the code from those. TransitionTime = (int)(step.TimeToNextStepInHours * 3600), ModelCollectionSubtypeId = MyStringHash.GetOrCompute(step.ModelCollectionSubtypeId), Actions = new Dictionary <string, EnvironmentItemAction>() }; if (step.Actions != null && step.Actions.Length > 0) { for (int j = 0; j < step.Actions.Length; j++) { var actionDef = step.Actions[j]; var action = new EnvironmentItemAction(); if (!actionDef.Id.IsNull()) { if (actionDef.NextStep != null && actionDef.NextStep != "" && StepNameIndex.ContainsKey(actionDef.NextStep)) { action.NextStep = StepNameIndex[actionDef.NextStep]; } else { action.NextStep = 0; } action.Id = actionDef.Id; action.Min = actionDef.Min; action.Max = actionDef.Max; } growthStep.Actions.Add(actionDef.Name, action); } } GrowthSteps[i] = growthStep; } CalculateSubtrees(); //DebugPrint(); StartingSteps = new MyDiscreteSampler <int>(StepNameIndex.Values, stepProbabilities); }
public Data(string model) { Collection = null; Model = model; }
public Data(MyDiscreteSampler <string> collection) { Collection = collection; Model = null; }