mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-11-22 12:58:33 +01:00
copy base documentation for a lot of docfx unresolvable sources
This commit is contained in:
parent
84a6e5a29a
commit
444b5c6afb
23 changed files with 203 additions and 50 deletions
|
@ -44,7 +44,12 @@ namespace MLEM.Data.Content {
|
||||||
return this.Read<T>(assetName, default);
|
return this.Read<T>(assetName, default);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <summary>
|
||||||
|
/// Reloads the asset of the given type, with the given original name.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="originalAssetName">The original name of the asset.</param>
|
||||||
|
/// <param name="currentAsset">The current asset instance.</param>
|
||||||
|
/// <typeparam name="T">The asset's type.</typeparam>
|
||||||
protected override void ReloadAsset<T>(string originalAssetName, T currentAsset) {
|
protected override void ReloadAsset<T>(string originalAssetName, T currentAsset) {
|
||||||
this.Read(originalAssetName, currentAsset);
|
this.Read(originalAssetName, currentAsset);
|
||||||
}
|
}
|
||||||
|
@ -78,7 +83,9 @@ namespace MLEM.Data.Content {
|
||||||
throw new ContentLoadException($"Asset {assetName} not found. Tried files {string.Join(", ", triedFiles)}");
|
throw new ContentLoadException($"Asset {assetName} not found. Tried files {string.Join(", ", triedFiles)}");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <summary>
|
||||||
|
/// Unloads this content manager, disposing all of the assets that it loaded.
|
||||||
|
/// </summary>
|
||||||
public override void Unload() {
|
public override void Unload() {
|
||||||
foreach (var d in this.disposableAssets)
|
foreach (var d in this.disposableAssets)
|
||||||
d.Dispose();
|
d.Dispose();
|
||||||
|
@ -86,7 +93,9 @@ namespace MLEM.Data.Content {
|
||||||
base.Unload();
|
base.Unload();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <summary>
|
||||||
|
/// Initializes the component. Used to load non-graphical resources.
|
||||||
|
/// </summary>
|
||||||
public void Initialize() {
|
public void Initialize() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -82,7 +82,8 @@ namespace MLEM.Data {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <summary>Returns a string that represents the current object.</summary>
|
||||||
|
/// <returns>A string that represents the current object.</returns>
|
||||||
public override string ToString() {
|
public override string ToString() {
|
||||||
if (this.name == null) {
|
if (this.name == null) {
|
||||||
var included = new List<DynamicEnum>();
|
var included = new List<DynamicEnum>();
|
||||||
|
|
|
@ -3,15 +3,26 @@ using MLEM.Misc;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace MLEM.Data.Json {
|
namespace MLEM.Data.Json {
|
||||||
/// <inheritdoc />
|
/// <summary>
|
||||||
|
/// Converts a <see cref="Direction2"/> to and from JSON
|
||||||
|
/// </summary>
|
||||||
public class Direction2Converter : JsonConverter<Direction2> {
|
public class Direction2Converter : JsonConverter<Direction2> {
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <summary>Writes the JSON representation of the object.</summary>
|
||||||
|
/// <param name="writer">The <see cref="T:Newtonsoft.Json.JsonWriter" /> to write to.</param>
|
||||||
|
/// <param name="value">The value.</param>
|
||||||
|
/// <param name="serializer">The calling serializer.</param>
|
||||||
public override void WriteJson(JsonWriter writer, Direction2 value, JsonSerializer serializer) {
|
public override void WriteJson(JsonWriter writer, Direction2 value, JsonSerializer serializer) {
|
||||||
writer.WriteValue(value.ToString());
|
writer.WriteValue(value.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <summary>Reads the JSON representation of the object.</summary>
|
||||||
|
/// <param name="reader">The <see cref="T:Newtonsoft.Json.JsonReader" /> to read from.</param>
|
||||||
|
/// <param name="objectType">Type of the object.</param>
|
||||||
|
/// <param name="existingValue">The existing value of object being read. If there is no existing value then <c>null</c> will be used.</param>
|
||||||
|
/// <param name="hasExistingValue">The existing value has a value.</param>
|
||||||
|
/// <param name="serializer">The calling serializer.</param>
|
||||||
|
/// <returns>The object value.</returns>
|
||||||
public override Direction2 ReadJson(JsonReader reader, Type objectType, Direction2 existingValue, bool hasExistingValue, JsonSerializer serializer) {
|
public override Direction2 ReadJson(JsonReader reader, Type objectType, Direction2 existingValue, bool hasExistingValue, JsonSerializer serializer) {
|
||||||
Enum.TryParse<Direction2>(reader.Value.ToString(), out var dir);
|
Enum.TryParse<Direction2>(reader.Value.ToString(), out var dir);
|
||||||
return dir;
|
return dir;
|
||||||
|
|
|
@ -2,15 +2,26 @@ using System;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace MLEM.Data.Json {
|
namespace MLEM.Data.Json {
|
||||||
/// <inheritdoc />
|
/// <summary>
|
||||||
|
/// Converts a <see cref="DynamicEnum"/> to and from JSON
|
||||||
|
/// </summary>
|
||||||
public class DynamicEnumConverter : JsonConverter<DynamicEnum> {
|
public class DynamicEnumConverter : JsonConverter<DynamicEnum> {
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <summary>Writes the JSON representation of the object.</summary>
|
||||||
|
/// <param name="writer">The <see cref="T:Newtonsoft.Json.JsonWriter" /> to write to.</param>
|
||||||
|
/// <param name="value">The value.</param>
|
||||||
|
/// <param name="serializer">The calling serializer.</param>
|
||||||
public override void WriteJson(JsonWriter writer, DynamicEnum value, JsonSerializer serializer) {
|
public override void WriteJson(JsonWriter writer, DynamicEnum value, JsonSerializer serializer) {
|
||||||
writer.WriteValue(value.ToString());
|
writer.WriteValue(value.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <summary>Reads the JSON representation of the object.</summary>
|
||||||
|
/// <param name="reader">The <see cref="T:Newtonsoft.Json.JsonReader" /> to read from.</param>
|
||||||
|
/// <param name="objectType">Type of the object.</param>
|
||||||
|
/// <param name="existingValue">The existing value of object being read. If there is no existing value then <c>null</c> will be used.</param>
|
||||||
|
/// <param name="hasExistingValue">The existing value has a value.</param>
|
||||||
|
/// <param name="serializer">The calling serializer.</param>
|
||||||
|
/// <returns>The object value.</returns>
|
||||||
public override DynamicEnum ReadJson(JsonReader reader, Type objectType, DynamicEnum existingValue, bool hasExistingValue, JsonSerializer serializer) {
|
public override DynamicEnum ReadJson(JsonReader reader, Type objectType, DynamicEnum existingValue, bool hasExistingValue, JsonSerializer serializer) {
|
||||||
return DynamicEnum.Parse(objectType, reader.Value.ToString());
|
return DynamicEnum.Parse(objectType, reader.Value.ToString());
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,15 +4,26 @@ using Microsoft.Xna.Framework;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace MLEM.Data.Json {
|
namespace MLEM.Data.Json {
|
||||||
/// <inheritdoc />
|
/// <summary>
|
||||||
|
/// Converts a <see cref="Point"/> to and from JSON
|
||||||
|
/// </summary>
|
||||||
public class PointConverter : JsonConverter<Point> {
|
public class PointConverter : JsonConverter<Point> {
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <summary>Writes the JSON representation of the object.</summary>
|
||||||
|
/// <param name="writer">The <see cref="T:Newtonsoft.Json.JsonWriter" /> to write to.</param>
|
||||||
|
/// <param name="value">The value.</param>
|
||||||
|
/// <param name="serializer">The calling serializer.</param>
|
||||||
public override void WriteJson(JsonWriter writer, Point value, JsonSerializer serializer) {
|
public override void WriteJson(JsonWriter writer, Point value, JsonSerializer serializer) {
|
||||||
writer.WriteValue(value.X.ToString(CultureInfo.InvariantCulture) + " " + value.Y.ToString(CultureInfo.InvariantCulture));
|
writer.WriteValue(value.X.ToString(CultureInfo.InvariantCulture) + " " + value.Y.ToString(CultureInfo.InvariantCulture));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <summary>Reads the JSON representation of the object.</summary>
|
||||||
|
/// <param name="reader">The <see cref="T:Newtonsoft.Json.JsonReader" /> to read from.</param>
|
||||||
|
/// <param name="objectType">Type of the object.</param>
|
||||||
|
/// <param name="existingValue">The existing value of object being read. If there is no existing value then <c>null</c> will be used.</param>
|
||||||
|
/// <param name="hasExistingValue">The existing value has a value.</param>
|
||||||
|
/// <param name="serializer">The calling serializer.</param>
|
||||||
|
/// <returns>The object value.</returns>
|
||||||
public override Point ReadJson(JsonReader reader, Type objectType, Point existingValue, bool hasExistingValue, JsonSerializer serializer) {
|
public override Point ReadJson(JsonReader reader, Type objectType, Point existingValue, bool hasExistingValue, JsonSerializer serializer) {
|
||||||
var value = reader.Value.ToString().Split(' ');
|
var value = reader.Value.ToString().Split(' ');
|
||||||
return new Point(int.Parse(value[0], CultureInfo.InvariantCulture), int.Parse(value[1], CultureInfo.InvariantCulture));
|
return new Point(int.Parse(value[0], CultureInfo.InvariantCulture), int.Parse(value[1], CultureInfo.InvariantCulture));
|
||||||
|
|
|
@ -4,17 +4,28 @@ using Microsoft.Xna.Framework;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace MLEM.Data.Json {
|
namespace MLEM.Data.Json {
|
||||||
/// <inheritdoc />
|
/// <summary>
|
||||||
|
/// Converts a <see cref="Rectangle"/> to and from JSON
|
||||||
|
/// </summary>
|
||||||
public class RectangleConverter : JsonConverter<Rectangle> {
|
public class RectangleConverter : JsonConverter<Rectangle> {
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <summary>Writes the JSON representation of the object.</summary>
|
||||||
|
/// <param name="writer">The <see cref="T:Newtonsoft.Json.JsonWriter" /> to write to.</param>
|
||||||
|
/// <param name="value">The value.</param>
|
||||||
|
/// <param name="serializer">The calling serializer.</param>
|
||||||
public override void WriteJson(JsonWriter writer, Rectangle value, JsonSerializer serializer) {
|
public override void WriteJson(JsonWriter writer, Rectangle value, JsonSerializer serializer) {
|
||||||
writer.WriteValue(
|
writer.WriteValue(
|
||||||
value.X.ToString(CultureInfo.InvariantCulture) + " " + value.Y.ToString(CultureInfo.InvariantCulture) + " " +
|
value.X.ToString(CultureInfo.InvariantCulture) + " " + value.Y.ToString(CultureInfo.InvariantCulture) + " " +
|
||||||
value.Width.ToString(CultureInfo.InvariantCulture) + " " + value.Height.ToString(CultureInfo.InvariantCulture));
|
value.Width.ToString(CultureInfo.InvariantCulture) + " " + value.Height.ToString(CultureInfo.InvariantCulture));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <summary>Reads the JSON representation of the object.</summary>
|
||||||
|
/// <param name="reader">The <see cref="T:Newtonsoft.Json.JsonReader" /> to read from.</param>
|
||||||
|
/// <param name="objectType">Type of the object.</param>
|
||||||
|
/// <param name="existingValue">The existing value of object being read. If there is no existing value then <c>null</c> will be used.</param>
|
||||||
|
/// <param name="hasExistingValue">The existing value has a value.</param>
|
||||||
|
/// <param name="serializer">The calling serializer.</param>
|
||||||
|
/// <returns>The object value.</returns>
|
||||||
public override Rectangle ReadJson(JsonReader reader, Type objectType, Rectangle existingValue, bool hasExistingValue, JsonSerializer serializer) {
|
public override Rectangle ReadJson(JsonReader reader, Type objectType, Rectangle existingValue, bool hasExistingValue, JsonSerializer serializer) {
|
||||||
var value = reader.Value.ToString().Split(' ');
|
var value = reader.Value.ToString().Split(' ');
|
||||||
return new Rectangle(
|
return new Rectangle(
|
||||||
|
|
|
@ -4,17 +4,28 @@ using MLEM.Misc;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace MLEM.Data.Json {
|
namespace MLEM.Data.Json {
|
||||||
/// <inheritdoc />
|
/// <summary>
|
||||||
|
/// Converts a <see cref="RectangleF"/> to and from JSON
|
||||||
|
/// </summary>
|
||||||
public class RectangleFConverter : JsonConverter<RectangleF> {
|
public class RectangleFConverter : JsonConverter<RectangleF> {
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <summary>Writes the JSON representation of the object.</summary>
|
||||||
|
/// <param name="writer">The <see cref="T:Newtonsoft.Json.JsonWriter" /> to write to.</param>
|
||||||
|
/// <param name="value">The value.</param>
|
||||||
|
/// <param name="serializer">The calling serializer.</param>
|
||||||
public override void WriteJson(JsonWriter writer, RectangleF value, JsonSerializer serializer) {
|
public override void WriteJson(JsonWriter writer, RectangleF value, JsonSerializer serializer) {
|
||||||
writer.WriteValue(
|
writer.WriteValue(
|
||||||
value.X.ToString(CultureInfo.InvariantCulture) + " " + value.Y.ToString(CultureInfo.InvariantCulture) + " " +
|
value.X.ToString(CultureInfo.InvariantCulture) + " " + value.Y.ToString(CultureInfo.InvariantCulture) + " " +
|
||||||
value.Width.ToString(CultureInfo.InvariantCulture) + " " + value.Height.ToString(CultureInfo.InvariantCulture));
|
value.Width.ToString(CultureInfo.InvariantCulture) + " " + value.Height.ToString(CultureInfo.InvariantCulture));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <summary>Reads the JSON representation of the object.</summary>
|
||||||
|
/// <param name="reader">The <see cref="T:Newtonsoft.Json.JsonReader" /> to read from.</param>
|
||||||
|
/// <param name="objectType">Type of the object.</param>
|
||||||
|
/// <param name="existingValue">The existing value of object being read. If there is no existing value then <c>null</c> will be used.</param>
|
||||||
|
/// <param name="hasExistingValue">The existing value has a value.</param>
|
||||||
|
/// <param name="serializer">The calling serializer.</param>
|
||||||
|
/// <returns>The object value.</returns>
|
||||||
public override RectangleF ReadJson(JsonReader reader, Type objectType, RectangleF existingValue, bool hasExistingValue, JsonSerializer serializer) {
|
public override RectangleF ReadJson(JsonReader reader, Type objectType, RectangleF existingValue, bool hasExistingValue, JsonSerializer serializer) {
|
||||||
var value = reader.Value.ToString().Split(' ');
|
var value = reader.Value.ToString().Split(' ');
|
||||||
return new RectangleF(
|
return new RectangleF(
|
||||||
|
|
|
@ -33,14 +33,23 @@ namespace MLEM.Data.Json {
|
||||||
this(GetEntries(type, memberName)) {
|
this(GetEntries(type, memberName)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <summary>Writes the JSON representation of the object.</summary>
|
||||||
|
/// <param name="writer">The <see cref="T:Newtonsoft.Json.JsonWriter" /> to write to.</param>
|
||||||
|
/// <param name="value">The value.</param>
|
||||||
|
/// <param name="serializer">The calling serializer.</param>
|
||||||
public override void WriteJson(JsonWriter writer, T value, JsonSerializer serializer) {
|
public override void WriteJson(JsonWriter writer, T value, JsonSerializer serializer) {
|
||||||
if (!this.inverse.TryGetValue(value, out var key))
|
if (!this.inverse.TryGetValue(value, out var key))
|
||||||
throw new InvalidOperationException($"Cannot write {value} that is not a registered entry");
|
throw new InvalidOperationException($"Cannot write {value} that is not a registered entry");
|
||||||
writer.WriteValue(key);
|
writer.WriteValue(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <summary>Reads the JSON representation of the object.</summary>
|
||||||
|
/// <param name="reader">The <see cref="T:Newtonsoft.Json.JsonReader" /> to read from.</param>
|
||||||
|
/// <param name="objectType">Type of the object.</param>
|
||||||
|
/// <param name="existingValue">The existing value of object being read. If there is no existing value then <c>null</c> will be used.</param>
|
||||||
|
/// <param name="hasExistingValue">The existing value has a value.</param>
|
||||||
|
/// <param name="serializer">The calling serializer.</param>
|
||||||
|
/// <returns>The object value.</returns>
|
||||||
public override T ReadJson(JsonReader reader, Type objectType, T existingValue, bool hasExistingValue, JsonSerializer serializer) {
|
public override T ReadJson(JsonReader reader, Type objectType, T existingValue, bool hasExistingValue, JsonSerializer serializer) {
|
||||||
var val = reader.Value?.ToString();
|
var val = reader.Value?.ToString();
|
||||||
if (val == null)
|
if (val == null)
|
||||||
|
|
|
@ -4,15 +4,26 @@ using Microsoft.Xna.Framework;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace MLEM.Data.Json {
|
namespace MLEM.Data.Json {
|
||||||
/// <inheritdoc />
|
/// <summary>
|
||||||
|
/// Converts a <see cref="Vector2"/> to and from JSON
|
||||||
|
/// </summary>
|
||||||
public class Vector2Converter : JsonConverter<Vector2> {
|
public class Vector2Converter : JsonConverter<Vector2> {
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <summary>Writes the JSON representation of the object.</summary>
|
||||||
|
/// <param name="writer">The <see cref="T:Newtonsoft.Json.JsonWriter" /> to write to.</param>
|
||||||
|
/// <param name="value">The value.</param>
|
||||||
|
/// <param name="serializer">The calling serializer.</param>
|
||||||
public override void WriteJson(JsonWriter writer, Vector2 value, JsonSerializer serializer) {
|
public override void WriteJson(JsonWriter writer, Vector2 value, JsonSerializer serializer) {
|
||||||
writer.WriteValue(value.X.ToString(CultureInfo.InvariantCulture) + " " + value.Y.ToString(CultureInfo.InvariantCulture));
|
writer.WriteValue(value.X.ToString(CultureInfo.InvariantCulture) + " " + value.Y.ToString(CultureInfo.InvariantCulture));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <summary>Reads the JSON representation of the object.</summary>
|
||||||
|
/// <param name="reader">The <see cref="T:Newtonsoft.Json.JsonReader" /> to read from.</param>
|
||||||
|
/// <param name="objectType">Type of the object.</param>
|
||||||
|
/// <param name="existingValue">The existing value of object being read. If there is no existing value then <c>null</c> will be used.</param>
|
||||||
|
/// <param name="hasExistingValue">The existing value has a value.</param>
|
||||||
|
/// <param name="serializer">The calling serializer.</param>
|
||||||
|
/// <returns>The object value.</returns>
|
||||||
public override Vector2 ReadJson(JsonReader reader, Type objectType, Vector2 existingValue, bool hasExistingValue, JsonSerializer serializer) {
|
public override Vector2 ReadJson(JsonReader reader, Type objectType, Vector2 existingValue, bool hasExistingValue, JsonSerializer serializer) {
|
||||||
var value = reader.Value.ToString().Split(' ');
|
var value = reader.Value.ToString().Split(' ');
|
||||||
return new Vector2(float.Parse(value[0], CultureInfo.InvariantCulture), float.Parse(value[1], CultureInfo.InvariantCulture));
|
return new Vector2(float.Parse(value[0], CultureInfo.InvariantCulture), float.Parse(value[1], CultureInfo.InvariantCulture));
|
||||||
|
|
|
@ -148,7 +148,7 @@ namespace MLEM.Data {
|
||||||
this.LastPackTime = TimeSpan.Zero;
|
this.LastPackTime = TimeSpan.Zero;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <summary>Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.</summary>
|
||||||
public void Dispose() {
|
public void Dispose() {
|
||||||
this.Reset();
|
this.Reset();
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,16 @@ namespace MLEM.Extended.Extensions {
|
||||||
return new Misc.RectangleF(rect.X, rect.Y, rect.Width, rect.Height);
|
return new Misc.RectangleF(rect.X, rect.Y, rect.Width, rect.Height);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc cref="MLEM.Extensions.NumberExtensions.Penetrate"/>
|
/// <summary>
|
||||||
|
/// Calculates the amount that the rectangle <paramref name="rect"/> is penetrating the rectangle <paramref name="other"/> by.
|
||||||
|
/// If a penetration on both axes is occuring, the one with the lower value is returned.
|
||||||
|
/// This is useful for collision detection, as it can be used to push colliding objects out of each other.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="rect">The rectangle to do the penetration</param>
|
||||||
|
/// <param name="other">The rectangle that should be penetrated</param>
|
||||||
|
/// <param name="normal">The direction that the penetration occured in</param>
|
||||||
|
/// <param name="penetration">The amount that the penetration occured by, in the direction of <paramref name="normal"/></param>
|
||||||
|
/// <returns>Whether or not a penetration occured</returns>
|
||||||
public static bool Penetrate(this RectangleF rect, RectangleF other, out Vector2 normal, out float penetration) {
|
public static bool Penetrate(this RectangleF rect, RectangleF other, out Vector2 normal, out float penetration) {
|
||||||
return rect.ToMlem().Penetrate(other.ToMlem(), out normal, out penetration);
|
return rect.ToMlem().Penetrate(other.ToMlem(), out normal, out penetration);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,17 +9,35 @@ namespace MLEM.Extended.Extensions {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static class SpriteBatchExtensions {
|
public static class SpriteBatchExtensions {
|
||||||
|
|
||||||
/// <inheritdoc cref="SpriteBatch.Draw(Texture2D,Rectangle,Rectangle?,Color,float,Vector2,SpriteEffects,float)"/>
|
/// <summary>Submit a sprite for drawing in the current batch.</summary>
|
||||||
|
/// <param name="batch">The sprite batch to draw with.</param>
|
||||||
|
/// <param name="texture">A texture.</param>
|
||||||
|
/// <param name="destinationRectangle">The drawing bounds on screen.</param>
|
||||||
|
/// <param name="sourceRectangle">An optional region on the texture which will be rendered. If null - draws full texture.</param>
|
||||||
|
/// <param name="color">A color mask.</param>
|
||||||
|
/// <param name="rotation">A rotation of this sprite.</param>
|
||||||
|
/// <param name="origin">Center of the rotation. 0,0 by default.</param>
|
||||||
|
/// <param name="effects">Modificators for drawing. Can be combined.</param>
|
||||||
|
/// <param name="layerDepth">A depth of the layer of this sprite.</param>
|
||||||
public static void Draw(this SpriteBatch batch, Texture2D texture, RectangleF destinationRectangle, Rectangle? sourceRectangle, Color color, float rotation, Vector2 origin, SpriteEffects effects, float layerDepth) {
|
public static void Draw(this SpriteBatch batch, Texture2D texture, RectangleF destinationRectangle, Rectangle? sourceRectangle, Color color, float rotation, Vector2 origin, SpriteEffects effects, float layerDepth) {
|
||||||
batch.Draw(texture, destinationRectangle.ToMlem(), sourceRectangle, color, rotation, origin, effects, layerDepth);
|
batch.Draw(texture, destinationRectangle.ToMlem(), sourceRectangle, color, rotation, origin, effects, layerDepth);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc cref="SpriteBatch.Draw(Texture2D,Rectangle,Rectangle?,Color)"/>
|
/// <summary>Submit a sprite for drawing in the current batch.</summary>
|
||||||
|
/// <param name="batch">The sprite batch to draw with.</param>
|
||||||
|
/// <param name="texture">A texture.</param>
|
||||||
|
/// <param name="destinationRectangle">The drawing bounds on screen.</param>
|
||||||
|
/// <param name="sourceRectangle">An optional region on the texture which will be rendered. If null - draws full texture.</param>
|
||||||
|
/// <param name="color">A color mask.</param>
|
||||||
public static void Draw(this SpriteBatch batch, Texture2D texture, RectangleF destinationRectangle, Rectangle? sourceRectangle, Color color) {
|
public static void Draw(this SpriteBatch batch, Texture2D texture, RectangleF destinationRectangle, Rectangle? sourceRectangle, Color color) {
|
||||||
batch.Draw(texture, destinationRectangle, sourceRectangle, color, 0, Vector2.Zero, SpriteEffects.None, 0);
|
batch.Draw(texture, destinationRectangle, sourceRectangle, color, 0, Vector2.Zero, SpriteEffects.None, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc cref="SpriteBatch.Draw(Texture2D,Rectangle,Color)"/>
|
/// <summary>Submit a sprite for drawing in the current batch.</summary>
|
||||||
|
/// <param name="batch">The sprite batch to draw with.</param>
|
||||||
|
/// <param name="texture">A texture.</param>
|
||||||
|
/// <param name="destinationRectangle">The drawing bounds on screen.</param>
|
||||||
|
/// <param name="color">A color mask.</param>
|
||||||
public static void Draw(this SpriteBatch batch, Texture2D texture, RectangleF destinationRectangle, Color color) {
|
public static void Draw(this SpriteBatch batch, Texture2D texture, RectangleF destinationRectangle, Color color) {
|
||||||
batch.Draw(texture, destinationRectangle, null, color);
|
batch.Draw(texture, destinationRectangle, null, color);
|
||||||
}
|
}
|
||||||
|
@ -38,6 +56,7 @@ namespace MLEM.Extended.Extensions {
|
||||||
for (var x = 0; x < tileCount.X; x++)
|
for (var x = 0; x < tileCount.X; x++)
|
||||||
batch.DrawRectangle(start + new Vector2(x, y) * tileSize, tileSize, gridColor, gridThickness / 2);
|
batch.DrawRectangle(start + new Vector2(x, y) * tileSize, tileSize, gridColor, gridThickness / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
var size = tileSize * tileCount.ToVector2() + new Vector2(gridThickness);
|
var size = tileSize * tileCount.ToVector2() + new Vector2(gridThickness);
|
||||||
batch.DrawRectangle(start - new Vector2(gridThickness / 2), size, gridColor, gridThickness / 2);
|
batch.DrawRectangle(start - new Vector2(gridThickness / 2), size, gridColor, gridThickness / 2);
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,12 +51,15 @@ namespace MLEM.Extended.Tiled {
|
||||||
return this.Layer == other.Layer && this.X == other.X && this.Y == other.Y;
|
return this.Layer == other.Layer && this.X == other.X && this.Y == other.Y;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <summary>Indicates whether this instance and a specified object are equal.</summary>
|
||||||
|
/// <param name="obj">The object to compare with the current instance.</param>
|
||||||
|
/// <returns>true if <paramref name="obj">obj</paramref> and this instance are the same type and represent the same value; otherwise, false.</returns>
|
||||||
public override bool Equals(object obj) {
|
public override bool Equals(object obj) {
|
||||||
return obj is LayerPosition other && this.Equals(other);
|
return obj is LayerPosition other && this.Equals(other);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <summary>Returns the hash code for this instance.</summary>
|
||||||
|
/// <returns>A 32-bit signed integer that is the hash code for this instance.</returns>
|
||||||
public override int GetHashCode() {
|
public override int GetHashCode() {
|
||||||
var hashCode = this.Layer.GetHashCode();
|
var hashCode = this.Layer.GetHashCode();
|
||||||
hashCode = (hashCode * 397) ^ this.X;
|
hashCode = (hashCode * 397) ^ this.X;
|
||||||
|
|
|
@ -110,19 +110,37 @@ namespace MLEM.Extensions {
|
||||||
return tex;
|
return tex;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc cref="SpriteBatch.Draw(Texture2D,Rectangle,Rectangle?,Color,float,Vector2,SpriteEffects,float)"/>
|
/// <summary>Submit a sprite for drawing in the current batch.</summary>
|
||||||
|
/// <param name="batch">The sprite batch to draw with.</param>
|
||||||
|
/// <param name="texture">A texture.</param>
|
||||||
|
/// <param name="destinationRectangle">The drawing bounds on screen.</param>
|
||||||
|
/// <param name="sourceRectangle">An optional region on the texture which will be rendered. If null - draws full texture.</param>
|
||||||
|
/// <param name="color">A color mask.</param>
|
||||||
|
/// <param name="rotation">A rotation of this sprite.</param>
|
||||||
|
/// <param name="origin">Center of the rotation. 0,0 by default.</param>
|
||||||
|
/// <param name="effects">Modificators for drawing. Can be combined.</param>
|
||||||
|
/// <param name="layerDepth">A depth of the layer of this sprite.</param>
|
||||||
public static void Draw(this SpriteBatch batch, Texture2D texture, RectangleF destinationRectangle, Rectangle? sourceRectangle, Color color, float rotation, Vector2 origin, SpriteEffects effects, float layerDepth) {
|
public static void Draw(this SpriteBatch batch, Texture2D texture, RectangleF destinationRectangle, Rectangle? sourceRectangle, Color color, float rotation, Vector2 origin, SpriteEffects effects, float layerDepth) {
|
||||||
var source = sourceRectangle ?? new Rectangle(0, 0, texture.Width, texture.Height);
|
var source = sourceRectangle ?? new Rectangle(0, 0, texture.Width, texture.Height);
|
||||||
var scale = new Vector2(1F / source.Width, 1F / source.Height) * destinationRectangle.Size;
|
var scale = new Vector2(1F / source.Width, 1F / source.Height) * destinationRectangle.Size;
|
||||||
batch.Draw(texture, destinationRectangle.Location, sourceRectangle, color, rotation, origin, scale, effects, layerDepth);
|
batch.Draw(texture, destinationRectangle.Location, sourceRectangle, color, rotation, origin, scale, effects, layerDepth);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc cref="SpriteBatch.Draw(Texture2D,Rectangle,Rectangle?,Color)"/>
|
/// <summary>Submit a sprite for drawing in the current batch.</summary>
|
||||||
|
/// <param name="batch">The sprite batch to draw with.</param>
|
||||||
|
/// <param name="texture">A texture.</param>
|
||||||
|
/// <param name="destinationRectangle">The drawing bounds on screen.</param>
|
||||||
|
/// <param name="sourceRectangle">An optional region on the texture which will be rendered. If null - draws full texture.</param>
|
||||||
|
/// <param name="color">A color mask.</param>
|
||||||
public static void Draw(this SpriteBatch batch, Texture2D texture, RectangleF destinationRectangle, Rectangle? sourceRectangle, Color color) {
|
public static void Draw(this SpriteBatch batch, Texture2D texture, RectangleF destinationRectangle, Rectangle? sourceRectangle, Color color) {
|
||||||
batch.Draw(texture, destinationRectangle, sourceRectangle, color, 0, Vector2.Zero, SpriteEffects.None, 0);
|
batch.Draw(texture, destinationRectangle, sourceRectangle, color, 0, Vector2.Zero, SpriteEffects.None, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc cref="SpriteBatch.Draw(Texture2D,Rectangle,Color)"/>
|
/// <summary>Submit a sprite for drawing in the current batch.</summary>
|
||||||
|
/// <param name="batch">The sprite batch to draw with.</param>
|
||||||
|
/// <param name="texture">A texture.</param>
|
||||||
|
/// <param name="destinationRectangle">The drawing bounds on screen.</param>
|
||||||
|
/// <param name="color">A color mask.</param>
|
||||||
public static void Draw(this SpriteBatch batch, Texture2D texture, RectangleF destinationRectangle, Color color) {
|
public static void Draw(this SpriteBatch batch, Texture2D texture, RectangleF destinationRectangle, Color color) {
|
||||||
batch.Draw(texture, destinationRectangle, null, color);
|
batch.Draw(texture, destinationRectangle, null, color);
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,7 +104,7 @@ namespace MLEM.Extensions {
|
||||||
return x >= 0 && y >= 0 && x < this.texture.Width && y < this.texture.Height;
|
return x >= 0 && y >= 0 && x < this.texture.Width && y < this.texture.Height;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <summary>Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.</summary>
|
||||||
public void Dispose() {
|
public void Dispose() {
|
||||||
this.Store();
|
this.Store();
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,8 @@ namespace MLEM.Input {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <summary>Returns this generic input, converted to a string.</summary>
|
||||||
|
/// <returns>This generic input, converted to a string.</returns>
|
||||||
public override string ToString() {
|
public override string ToString() {
|
||||||
switch (this.Type) {
|
switch (this.Type) {
|
||||||
case InputType.Mouse:
|
case InputType.Mouse:
|
||||||
|
@ -39,12 +40,15 @@ namespace MLEM.Input {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <summary>Indicates whether this instance and a specified object are equal.</summary>
|
||||||
|
/// <param name="obj">The object to compare with the current instance.</param>
|
||||||
|
/// <returns><see langword="true" /> if <paramref name="obj" /> and this instance are the same type and represent the same value; otherwise, <see langword="false" />.</returns>
|
||||||
public override bool Equals(object obj) {
|
public override bool Equals(object obj) {
|
||||||
return obj is GenericInput o && this.Type == o.Type && this.value == o.value;
|
return obj is GenericInput o && this.Type == o.Type && this.value == o.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <summary>Returns the hash code for this instance.</summary>
|
||||||
|
/// <returns>A 32-bit signed integer that is the hash code for this instance.</returns>
|
||||||
public override int GetHashCode() {
|
public override int GetHashCode() {
|
||||||
return ((int) this.Type * 397) ^ this.value;
|
return ((int) this.Type * 397) ^ this.value;
|
||||||
}
|
}
|
||||||
|
|
|
@ -147,7 +147,10 @@ namespace MLEM.Input {
|
||||||
return string.Join(joiner, this.combinations.Select(c => c.ToString(combinationJoiner, inputName)));
|
return string.Join(joiner, this.combinations.Select(c => c.ToString(combinationJoiner, inputName)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <summary>
|
||||||
|
/// Converts this keybind into a string, separating every included <see cref="Combination"/> by a comma
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>This keybind as a string</returns>
|
||||||
public override string ToString() {
|
public override string ToString() {
|
||||||
return this.ToString(", ");
|
return this.ToString(", ");
|
||||||
}
|
}
|
||||||
|
|
|
@ -129,12 +129,15 @@ namespace MLEM.Misc {
|
||||||
return this.Left.Equals(other.Left) && this.Right.Equals(other.Right) && this.Top.Equals(other.Top) && this.Bottom.Equals(other.Bottom);
|
return this.Left.Equals(other.Left) && this.Right.Equals(other.Right) && this.Top.Equals(other.Top) && this.Bottom.Equals(other.Bottom);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <summary>Indicates whether this instance and a specified object are equal.</summary>
|
||||||
|
/// <param name="obj">The object to compare with the current instance.</param>
|
||||||
|
/// <returns><see langword="true" /> if <paramref name="obj" /> and this instance are the same type and represent the same value; otherwise, <see langword="false" />.</returns>
|
||||||
public override bool Equals(object obj) {
|
public override bool Equals(object obj) {
|
||||||
return obj is Padding other && this.Equals(other);
|
return obj is Padding other && this.Equals(other);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <summary>Returns the hash code for this instance.</summary>
|
||||||
|
/// <returns>A 32-bit signed integer that is the hash code for this instance.</returns>
|
||||||
public override int GetHashCode() {
|
public override int GetHashCode() {
|
||||||
var hashCode = this.Left.GetHashCode();
|
var hashCode = this.Left.GetHashCode();
|
||||||
hashCode = (hashCode * 397) ^ this.Right.GetHashCode();
|
hashCode = (hashCode * 397) ^ this.Right.GetHashCode();
|
||||||
|
|
|
@ -163,17 +163,20 @@ namespace MLEM.Misc {
|
||||||
return this.X <= value.X && value.X + value.Width <= this.X + this.Width && this.Y <= value.Y && value.Y + value.Height <= this.Y + this.Height;
|
return this.X <= value.X && value.X + value.Width <= this.X + this.Width && this.Y <= value.Y && value.Y + value.Height <= this.Y + this.Height;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <summary>Indicates whether this instance and a specified object are equal.</summary>
|
||||||
|
/// <param name="obj">The object to compare with the current instance.</param>
|
||||||
|
/// <returns><see langword="true" /> if <paramref name="obj" /> and this instance are the same type and represent the same value; otherwise, <see langword="false" />.</returns>
|
||||||
public override bool Equals(object obj) {
|
public override bool Equals(object obj) {
|
||||||
return obj is RectangleF f && this == f;
|
return obj is RectangleF f && this == f;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc cref="Equals(object)"/>
|
||||||
public bool Equals(RectangleF other) {
|
public bool Equals(RectangleF other) {
|
||||||
return this == other;
|
return this == other;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <summary>Returns the hash code for this instance.</summary>
|
||||||
|
/// <returns>A 32-bit signed integer that is the hash code for this instance.</returns>
|
||||||
public override int GetHashCode() {
|
public override int GetHashCode() {
|
||||||
return (((17 * 23 + this.X.GetHashCode()) * 23 + this.Y.GetHashCode()) * 23 + this.Width.GetHashCode()) * 23 + this.Height.GetHashCode();
|
return (((17 * 23 + this.X.GetHashCode()) * 23 + this.Y.GetHashCode()) * 23 + this.Width.GetHashCode()) * 23 + this.Height.GetHashCode();
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,11 +2,11 @@ using System;
|
||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
|
|
||||||
namespace MLEM.Misc {
|
namespace MLEM.Misc {
|
||||||
/// <inheritdoc />
|
/// <inheritdoc cref="Sound.SoundEffectInstanceHandler"/>
|
||||||
[Obsolete("This class has been moved to MLEM.Sound.SoundEffectInstanceHandler in 5.1.0")]
|
[Obsolete("This class has been moved to MLEM.Sound.SoundEffectInstanceHandler in 5.1.0")]
|
||||||
public class SoundEffectInstanceHandler : Sound.SoundEffectInstanceHandler {
|
public class SoundEffectInstanceHandler : Sound.SoundEffectInstanceHandler {
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc cref="Sound.SoundEffectInstanceHandler(Game)"/>
|
||||||
public SoundEffectInstanceHandler(Game game) : base(game) {
|
public SoundEffectInstanceHandler(Game game) : base(game) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -356,7 +356,7 @@ namespace MLEM.Misc {
|
||||||
this.batchChanged = true;
|
this.batchChanged = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <summary>Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.</summary>
|
||||||
public void Dispose() {
|
public void Dispose() {
|
||||||
this.spriteEffect.Dispose();
|
this.spriteEffect.Dispose();
|
||||||
this.indices?.Dispose();
|
this.indices?.Dispose();
|
||||||
|
|
|
@ -214,14 +214,17 @@ namespace MLEM.Pathfinding {
|
||||||
this.F = this.G + distance * defaultCost;
|
this.F = this.G + distance * defaultCost;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <summary>Indicates whether this instance and a specified object are equal.</summary>
|
||||||
|
/// <param name="obj">The object to compare with the current instance.</param>
|
||||||
|
/// <returns><see langword="true" /> if <paramref name="obj" /> and this instance are the same type and represent the same value; otherwise, <see langword="false" />.</returns>
|
||||||
public override bool Equals(object obj) {
|
public override bool Equals(object obj) {
|
||||||
if (obj == this)
|
if (obj == this)
|
||||||
return true;
|
return true;
|
||||||
return obj is PathPoint<T> point && point.Pos.Equals(this.Pos);
|
return obj is PathPoint<T> point && point.Pos.Equals(this.Pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <summary>Returns the hash code for this instance.</summary>
|
||||||
|
/// <returns>A 32-bit signed integer that is the hash code for this instance.</returns>
|
||||||
public override int GetHashCode() {
|
public override int GetHashCode() {
|
||||||
return this.Pos.GetHashCode();
|
return this.Pos.GetHashCode();
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,11 +109,14 @@ namespace MLEM.Sound {
|
||||||
return this.Add(effect.CreateInstance(), onStopped, emitter);
|
return this.Add(effect.CreateInstance(), onStopped, emitter);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <summary>Returns an enumerator that iterates through the collection.</summary>
|
||||||
|
/// <returns>An enumerator that can be used to iterate through the collection.</returns>
|
||||||
public IEnumerator<Entry> GetEnumerator() {
|
public IEnumerator<Entry> GetEnumerator() {
|
||||||
return this.playingSounds.GetEnumerator();
|
return this.playingSounds.GetEnumerator();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>Returns an enumerator that iterates through a collection.</summary>
|
||||||
|
/// <returns>An <see cref="T:System.Collections.IEnumerator"></see> object that can be used to iterate through the collection.</returns>
|
||||||
IEnumerator IEnumerable.GetEnumerator() {
|
IEnumerator IEnumerable.GetEnumerator() {
|
||||||
return this.GetEnumerator();
|
return this.GetEnumerator();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue