public void CosmicLocationTest()
    {
        var value = CosmicLocation.New(CosmicStructureType.Universe, null, Vector3 <HugeNumber> .Zero, out _);

        var json = JsonSerializer.Serialize(value);

        Console.WriteLine();
        Console.WriteLine(json);
        var deserialized = JsonSerializer.Deserialize <CosmicLocation>(json);

        Assert.AreEqual(value, deserialized);
        Assert.AreEqual(json, JsonSerializer.Serialize(deserialized));
    }
Exemple #2
0
 /// <summary>
 /// Determines whether this <see cref="ChildDefinition"/> instance's parameters are
 /// satisfied by the given <paramref name="location"/>, discounting <see cref="Density"/>
 /// and <see cref="Space"/>.
 /// </summary>
 /// <param name="location">A <see cref="Location"/> to test against this instance.</param>
 /// <returns><see langword="true"/> if this instance's parameters are satisfied by the given
 /// <paramref name="location"/>; otherwise <see langword="false"/>.</returns>
 public virtual bool IsSatisfiedBy(CosmicLocation location) => StructureType.HasFlag(location.StructureType);
Exemple #3
0
 /// <summary>
 /// Gets a new <see cref="CosmicLocation"/> as defined by this <see
 /// cref="ChildDefinition"/>.
 /// </summary>
 /// <param name="parent">The location which is to contain the new one.</param>
 /// <param name="position">
 /// The position of the new location relative to the center of the <paramref
 /// name="parent"/>.
 /// </param>
 /// <param name="children">
 /// <para>
 /// When this method returns, will be set to a <see cref="List{T}"/> of <see
 /// cref="CosmicLocation"/>s containing any child objects generated for the location during
 /// the creation process.
 /// </para>
 /// <para>
 /// This list may be useful, for instance, to ensure that these additional objects are also
 /// persisted to data storage.
 /// </para>
 /// </param>
 /// <returns>
 /// A new <see cref="CosmicLocation"/> as defined by this <see cref="ChildDefinition"/>.
 /// </returns>
 public virtual CosmicLocation?GetChild(CosmicLocation parent, Vector3 <HugeNumber> position, out List <CosmicLocation> children)
 => CosmicLocation.New(StructureType, parent, position, out children);