-
-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# Conflicts: # SL-CustomObjects/Assets/DONT TOUCH/Scripts/Schematic.cs # SL-CustomObjects/Assets/DONT TOUCH/Scripts/SchematicManager/Updater.cs
- Loading branch information
Showing
957 changed files
with
1,414 additions
and
116,635 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
namespace MapEditorReborn.API.Enums | ||
{ | ||
using System; | ||
|
||
[Flags] | ||
internal enum GravityGunMode | ||
{ | ||
Movement = 1, | ||
Rotate = 2, | ||
Gravity = 4, | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
namespace MapEditorReborn.API.Enums | ||
{ | ||
public enum LoadMapOnEventMode | ||
{ | ||
/// <summary> | ||
/// Picks a random map from the available maps. | ||
/// </summary> | ||
Random, | ||
|
||
/// <summary> | ||
/// Merges multiple maps into one and loads all of them. | ||
/// </summary> | ||
Merge | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
namespace MapEditorReborn.API.Extensions | ||
{ | ||
using System; | ||
using System.Globalization; | ||
|
||
public static class BitwiseExtensions | ||
{ | ||
public static T IncludeAll<T>(this Enum value) | ||
{ | ||
Type type = value.GetType(); | ||
object result = value; | ||
string[] names = Enum.GetNames(type); | ||
foreach (var name in names) | ||
{ | ||
((Enum)result).Include(Enum.Parse(type, name)); | ||
} | ||
|
||
return (T)result; | ||
//Enum.Parse(type, result.ToString()); | ||
} | ||
|
||
/// <summary> | ||
/// Includes an enumerated type and returns the new value | ||
/// </summary> | ||
public static T Include<T>(this Enum value, T append) | ||
{ | ||
Type type = value.GetType(); | ||
|
||
//determine the values | ||
object result = value; | ||
var parsed = new _Value(append, type); | ||
if (parsed.Signed is long) | ||
{ | ||
result = Convert.ToInt64(value) | (long)parsed.Signed; | ||
} | ||
else if (parsed.Unsigned is ulong) | ||
{ | ||
result = Convert.ToUInt64(value) | (ulong)parsed.Unsigned; | ||
} | ||
|
||
//return the final value | ||
return (T)Enum.Parse(type, result.ToString()); | ||
} | ||
|
||
/// <summary> | ||
/// Check to see if a flags enumeration has a specific flag set. | ||
/// </summary> | ||
/// <param name="variable">Flags enumeration to check</param> | ||
/// <param name="value">Flag to check for</param> | ||
/// <returns></returns> | ||
public static bool HasFlag(this Enum variable, Enum value) | ||
{ | ||
if (variable == null) | ||
return false; | ||
|
||
if (value == null) | ||
throw new ArgumentNullException("value"); | ||
|
||
// Not as good as the .NET 4 version of this function, | ||
// but should be good enough | ||
if (!Enum.IsDefined(variable.GetType(), value)) | ||
{ | ||
throw new ArgumentException(string.Format( | ||
"Enumeration type mismatch. The flag is of type '{0}', " + | ||
"was expecting '{1}'.", value.GetType(), | ||
variable.GetType())); | ||
} | ||
|
||
ulong num = Convert.ToUInt64(value); | ||
return ((Convert.ToUInt64(variable) & num) == num); | ||
} | ||
|
||
public static T SetFlag<T>(this T flags, T flag, bool value) where T : struct, IComparable, IFormattable, IConvertible | ||
{ | ||
int flagsInt = flags.ToInt32(NumberFormatInfo.CurrentInfo); | ||
int flagInt = flag.ToInt32(NumberFormatInfo.CurrentInfo); | ||
if (value) | ||
{ | ||
flagsInt |= flagInt; | ||
} | ||
else | ||
{ | ||
flagsInt &= ~flagInt; | ||
} | ||
return (T)(Object)flagsInt; | ||
} | ||
|
||
|
||
/// <summary> | ||
/// Removes an enumerated type and returns the new value | ||
/// </summary> | ||
public static T Remove<T>(this Enum value, T remove) | ||
{ | ||
Type type = value.GetType(); | ||
|
||
//determine the values | ||
object result = value; | ||
var parsed = new _Value(remove, type); | ||
if (parsed.Signed is long) | ||
{ | ||
result = Convert.ToInt64(value) & ~(long)parsed.Signed; | ||
} | ||
else if (parsed.Unsigned is ulong) | ||
{ | ||
result = Convert.ToUInt64(value) & ~(ulong)parsed.Unsigned; | ||
} | ||
|
||
//return the final value | ||
return (T)Enum.Parse(type, result.ToString()); | ||
} | ||
|
||
//class to simplfy narrowing values between | ||
//a ulong and long since either value should | ||
//cover any lesser value | ||
private class _Value | ||
{ | ||
//cached comparisons for tye to use | ||
private static readonly Type _UInt32 = typeof(long); | ||
private static readonly Type _UInt64 = typeof(ulong); | ||
|
||
public readonly long? Signed; | ||
public readonly ulong? Unsigned; | ||
|
||
public _Value(object value, Type type) | ||
{ | ||
//make sure it is even an enum to work with | ||
if (!type.IsEnum) | ||
{ | ||
throw new ArgumentException( | ||
"Value provided is not an enumerated type!"); | ||
} | ||
|
||
//then check for the enumerated value | ||
Type compare = Enum.GetUnderlyingType(type); | ||
|
||
//if this is an unsigned long then the only | ||
//value that can hold it would be a ulong | ||
if (compare.Equals(_UInt32) || compare.Equals(_UInt64)) | ||
{ | ||
Unsigned = Convert.ToUInt64(value); | ||
} | ||
//otherwise, a long should cover anything else | ||
else | ||
{ | ||
Signed = Convert.ToInt64(value); | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.