protected override void CloseObjectSeed(MyObjectSeed objectSeed) { IMyAsteroidFieldDensityFunction func = objectSeed.UserData as IMyAsteroidFieldDensityFunction; if (func != null) { ChildrenRemoveDensityFunctionRemoved(func); } var bbox = objectSeed.BoundingVolume; MyGamePruningStructure.GetAllVoxelMapsInBox(ref bbox, m_tmpVoxelMapsList); String storageName = string.Format("{0}_{1}_{2}_{3}_{4}_{5}", objectSeed.Params.Type, objectSeed.CellId.X, objectSeed.CellId.Y, objectSeed.CellId.Z, objectSeed.Params.Index, objectSeed.Params.Seed); foreach (var voxelBase in m_tmpVoxelMapsList) { if (voxelBase.StorageName == storageName) { if (!voxelBase.Save) { voxelBase.Close(); } break; } } m_tmpVoxelMapsList.Clear(); }
protected void ChildrenRemoveDensityFunctionRemoved(IMyAsteroidFieldDensityFunction func) { foreach (var child in m_children) { child.ChildrenRemoveDensityFunctionRemoved(func); child.RemoveDensityFunctionRemoved(func); } }
protected void ChildrenAddDensityFunctionFilled(IMyAsteroidFieldDensityFunction func) { foreach (var child in m_children) { child.AddDensityFunctionFilled(func); child.ChildrenAddDensityFunctionFilled(func); } }
protected void ChildrenRemoveDensityFunctionRemoved(IMyAsteroidFieldDensityFunction func) { foreach (var child in m_children) { child.ChildrenRemoveDensityFunctionRemoved(func); child.RemoveDensityFunctionRemoved(func); } }
protected void ChildrenAddDensityFunctionFilled(IMyAsteroidFieldDensityFunction func) { foreach (var child in m_children) { child.AddDensityFunctionFilled(func); child.ChildrenAddDensityFunctionFilled(func); } }
protected void RemoveDensityFunctionFilled(IMyAsteroidFieldDensityFunction func) { m_densityFunctionsFilled.Remove(func); }
protected void AddDensityFunctionFilled(IMyAsteroidFieldDensityFunction func) { m_densityFunctionsFilled.Add(func); }
protected void AddDensityFunctionRemoved(IMyAsteroidFieldDensityFunction func) { m_densityFunctionsRemoved.Add(func); }
private void GenerateObject(MyProceduralCell cell, MyObjectSeed objectSeed, ref int index, MyRandom random, IMyModule densityFunctionFilled, IMyModule densityFunctionRemoved) { cell.AddObject(objectSeed); IMyAsteroidFieldDensityFunction func = objectSeed.UserData as IMyAsteroidFieldDensityFunction; if (func != null) { ChildrenAddDensityFunctionRemoved(func); } switch (objectSeed.Params.Type) { case MyObjectSeedType.Moon: break; case MyObjectSeedType.Planet: m_tmpClusterBoxes.Add(objectSeed.BoundingVolume); for (int i = 0; i < MOONS_MAX; ++i) { var direction = MyProceduralWorldGenerator.GetRandomDirection(random); var size = MathHelper.Lerp(MOON_SIZE_MIN, MOON_SIZE_MAX, random.NextDouble()); var distance = MathHelper.Lerp(MOON_DISTANCE_MIN, MOON_DISTANCE_MAX, random.NextDouble()); var position = objectSeed.BoundingVolume.Center + direction * (size + objectSeed.BoundingVolume.HalfExtents.Length() * 2 + distance); ProfilerShort.Begin("GetValue"); var value = densityFunctionFilled.GetValue(position.X, position.Y, position.Z); ProfilerShort.End(); if (value < MOON_DENSITY) // -1..+1 { var clusterObjectSeed = new MyObjectSeed(cell, position, size); clusterObjectSeed.Params.Seed = random.Next(); clusterObjectSeed.Params.Type = MyObjectSeedType.Moon; clusterObjectSeed.Params.Index = index++; clusterObjectSeed.UserData = new MySphereDensityFunction(position, MOON_SIZE_MAX / 2.0 * GRAVITY_SIZE_MULTIPLIER + FALLOFF, FALLOFF); bool overlaps = false; foreach (var box in m_tmpClusterBoxes) { if (overlaps |= clusterObjectSeed.BoundingVolume.Intersects(box)) { break; } } if (!overlaps) { m_tmpClusterBoxes.Add(clusterObjectSeed.BoundingVolume); GenerateObject(cell, clusterObjectSeed, ref index, random, densityFunctionFilled, densityFunctionRemoved); } } } m_tmpClusterBoxes.Clear(); break; case MyObjectSeedType.Empty: break; default: throw new InvalidBranchException(); break; } }
protected void RemoveDensityFunctionFilled(IMyAsteroidFieldDensityFunction func) { m_densityFunctionsFilled.Remove(func); }
protected void AddDensityFunctionFilled(IMyAsteroidFieldDensityFunction func) { m_densityFunctionsFilled.Add(func); }
public void AddDensityFunctionRemoved(IMyAsteroidFieldDensityFunction func) { m_densityFunctionsRemoved.Add(func); }