diff --git a/Intersect (Core)/Async/AsyncValueGenerator`1.cs b/Framework/Intersect.Framework.Core/Async/AsyncValueGenerator`1.cs similarity index 100% rename from Intersect (Core)/Async/AsyncValueGenerator`1.cs rename to Framework/Intersect.Framework.Core/Async/AsyncValueGenerator`1.cs diff --git a/Intersect (Core)/Async/CancellableGenerator`1.cs b/Framework/Intersect.Framework.Core/Async/CancellableGenerator`1.cs similarity index 100% rename from Intersect (Core)/Async/CancellableGenerator`1.cs rename to Framework/Intersect.Framework.Core/Async/CancellableGenerator`1.cs diff --git a/Intersect (Core)/Attributes/RelatedTableAttribute.cs b/Framework/Intersect.Framework.Core/Attributes/RelatedTableAttribute.cs similarity index 100% rename from Intersect (Core)/Attributes/RelatedTableAttribute.cs rename to Framework/Intersect.Framework.Core/Attributes/RelatedTableAttribute.cs diff --git a/Intersect (Core)/Attributes/RelatedVariableTypeAttribute.cs b/Framework/Intersect.Framework.Core/Attributes/RelatedVariableTypeAttribute.cs similarity index 100% rename from Intersect (Core)/Attributes/RelatedVariableTypeAttribute.cs rename to Framework/Intersect.Framework.Core/Attributes/RelatedVariableTypeAttribute.cs diff --git a/Intersect (Core)/Enums/ChatMessageType.cs b/Framework/Intersect.Framework.Core/Chatting/ChatMessageType.cs similarity index 100% rename from Intersect (Core)/Enums/ChatMessageType.cs rename to Framework/Intersect.Framework.Core/Chatting/ChatMessageType.cs diff --git a/Intersect (Core)/Enums/ChatboxChannel.cs b/Framework/Intersect.Framework.Core/Chatting/ChatboxChannel.cs similarity index 100% rename from Intersect (Core)/Enums/ChatboxChannel.cs rename to Framework/Intersect.Framework.Core/Chatting/ChatboxChannel.cs diff --git a/Intersect (Core)/Collections/DatabaseObjectLookup.cs b/Framework/Intersect.Framework.Core/Collections/DatabaseObjectLookup.cs similarity index 97% rename from Intersect (Core)/Collections/DatabaseObjectLookup.cs rename to Framework/Intersect.Framework.Core/Collections/DatabaseObjectLookup.cs index 134e62adcb..a99c71915e 100644 --- a/Intersect (Core)/Collections/DatabaseObjectLookup.cs +++ b/Framework/Intersect.Framework.Core/Collections/DatabaseObjectLookup.cs @@ -73,7 +73,7 @@ public List ValueList } catch (Exception exception) { - Log.Warn( + LegacyLogging.Logger?.Warn( exception, $@"{StoredType.Name}[Count={mIdMap.Count},NullCount={mIdMap.Count(pair => pair.Value == null)}]" ); @@ -363,10 +363,10 @@ internal virtual bool InternalSet(IDatabaseObject value, bool overwrite) private static string MessageNoConstructor(Type type, params string[] constructorMessage) { - var joinedConstructorMessage = string.Join(",", constructorMessage ?? new string[] { }); + var joinedConstructorMessage = string.Join(',', constructorMessage); var builder = new StringBuilder(); - builder.AppendLine($@"No ({joinedConstructorMessage}) constructor for type '{type?.Name}'."); - builder.AppendLine(ReflectionUtils.StringifyConstructors(type)); + builder.AppendLine($@"No ({joinedConstructorMessage}) constructor for type '{type.Name}'."); + builder.AppendLine(type.StringifyConstructors()); return builder.ToString(); } diff --git a/Intersect (Core)/Collections/IGameObjectLookup.cs b/Framework/Intersect.Framework.Core/Collections/IGameObjectLookup.cs similarity index 100% rename from Intersect (Core)/Collections/IGameObjectLookup.cs rename to Framework/Intersect.Framework.Core/Collections/IGameObjectLookup.cs diff --git a/Intersect (Core)/Collections/ILookup.cs b/Framework/Intersect.Framework.Core/Collections/ILookup.cs similarity index 100% rename from Intersect (Core)/Collections/ILookup.cs rename to Framework/Intersect.Framework.Core/Collections/ILookup.cs diff --git a/Framework/Intersect.Framework.Core/Collections/ListExtensions.cs b/Framework/Intersect.Framework.Core/Collections/ListExtensions.cs new file mode 100644 index 0000000000..7d21e1dfb1 --- /dev/null +++ b/Framework/Intersect.Framework.Core/Collections/ListExtensions.cs @@ -0,0 +1,7 @@ +namespace Intersect.Collections; + +public static partial class ListExtensions +{ + public static IReadOnlyList WrapReadOnly(this IList list) => + new ReadOnlyList(list); +} \ No newline at end of file diff --git a/Intersect (Core)/Collections/ReadOnlyList.cs b/Framework/Intersect.Framework.Core/Collections/ReadOnlyList.cs similarity index 75% rename from Intersect (Core)/Collections/ReadOnlyList.cs rename to Framework/Intersect.Framework.Core/Collections/ReadOnlyList.cs index f8b74568e0..e0245215f3 100644 --- a/Intersect (Core)/Collections/ReadOnlyList.cs +++ b/Framework/Intersect.Framework.Core/Collections/ReadOnlyList.cs @@ -15,10 +15,4 @@ public partial class ReadOnlyList : IReadOnlyList public ReadOnlyList(IList backingList) => this.backingList = backingList; -} - -public static partial class ListExtensions -{ - public static IReadOnlyList WrapReadOnly(this IList list) => - new ReadOnlyList(list); -} +} \ No newline at end of file diff --git a/Intersect (Core)/Collections/SanitizedValue.cs b/Framework/Intersect.Framework.Core/Collections/SanitizedValue.cs similarity index 100% rename from Intersect (Core)/Collections/SanitizedValue.cs rename to Framework/Intersect.Framework.Core/Collections/SanitizedValue.cs diff --git a/Intersect (Core)/Color.cs b/Framework/Intersect.Framework.Core/Color.cs similarity index 100% rename from Intersect (Core)/Color.cs rename to Framework/Intersect.Framework.Core/Color.cs diff --git a/Intersect (Core)/ColorF.cs b/Framework/Intersect.Framework.Core/ColorF.cs similarity index 100% rename from Intersect (Core)/ColorF.cs rename to Framework/Intersect.Framework.Core/ColorF.cs diff --git a/Framework/Intersect.Framework.Core/Compression/IAssetPacker.cs b/Framework/Intersect.Framework.Core/Compression/IAssetPacker.cs new file mode 100644 index 0000000000..b339a043ab --- /dev/null +++ b/Framework/Intersect.Framework.Core/Compression/IAssetPacker.cs @@ -0,0 +1,38 @@ +namespace Intersect.Compression; + +public interface IAssetPacker : IDisposable +{ + /// + /// The location given at the creation of this object defining where we can find our asset packs. + /// + string PackageLocation { get; } + + /// + /// A list of all packages currently being cached. + /// + List CachedPackages { get; } + + /// + /// A list of all files contained within the asset packs. + /// + List FileList { get; } + + /// + /// Retrieve an asset from the asset packages. + /// + /// The asset to retrieve. + /// Returns a containing the requested file. + MemoryStream GetAsset(string fileName); + + /// + /// Checks whether or not an asset is contained within the loaded index file. This check is case insensitive! + /// + /// The file to look for. + /// Returns whether or not the file was found in the loaded Asset Packs. + bool Contains(string fileName); + + /// + /// Updates our cache timers and disposes of items no longer within the caching time limit. + /// + void UpdateCache(); +} \ No newline at end of file diff --git a/Intersect (Core)/Compression/LZ4.cs b/Framework/Intersect.Framework.Core/Compression/LZ4.cs similarity index 100% rename from Intersect (Core)/Compression/LZ4.cs rename to Framework/Intersect.Framework.Core/Compression/LZ4.cs diff --git a/Intersect (Core)/Config/BankOptions.cs b/Framework/Intersect.Framework.Core/Config/BankOptions.cs similarity index 100% rename from Intersect (Core)/Config/BankOptions.cs rename to Framework/Intersect.Framework.Core/Config/BankOptions.cs diff --git a/Intersect (Core)/Config/ChatOptions.cs b/Framework/Intersect.Framework.Core/Config/ChatOptions.cs similarity index 100% rename from Intersect (Core)/Config/ChatOptions.cs rename to Framework/Intersect.Framework.Core/Config/ChatOptions.cs diff --git a/Intersect (Core)/Config/CombatOptions.cs b/Framework/Intersect.Framework.Core/Config/CombatOptions.cs similarity index 100% rename from Intersect (Core)/Config/CombatOptions.cs rename to Framework/Intersect.Framework.Core/Config/CombatOptions.cs diff --git a/Intersect (Core)/Config/DatabaseOptions.cs b/Framework/Intersect.Framework.Core/Config/DatabaseOptions.cs similarity index 100% rename from Intersect (Core)/Config/DatabaseOptions.cs rename to Framework/Intersect.Framework.Core/Config/DatabaseOptions.cs diff --git a/Intersect (Core)/Config/DatabaseType.cs b/Framework/Intersect.Framework.Core/Config/DatabaseType.cs similarity index 100% rename from Intersect (Core)/Config/DatabaseType.cs rename to Framework/Intersect.Framework.Core/Config/DatabaseType.cs diff --git a/Intersect (Core)/Config/EquipmentOptions.cs b/Framework/Intersect.Framework.Core/Config/EquipmentOptions.cs similarity index 100% rename from Intersect (Core)/Config/EquipmentOptions.cs rename to Framework/Intersect.Framework.Core/Config/EquipmentOptions.cs diff --git a/Framework/Intersect.Framework.Core/Config/FloodThreshholds.cs b/Framework/Intersect.Framework.Core/Config/FloodThreshholds.cs new file mode 100644 index 0000000000..d0139395ad --- /dev/null +++ b/Framework/Intersect.Framework.Core/Config/FloodThreshholds.cs @@ -0,0 +1,39 @@ +namespace Intersect.Config; + +public partial class FloodThreshholds +{ + /// + /// The largest a single packet should be before it's considered flooding. + /// + public int MaxPacketSize { get; set; } = 10240; + + /// + /// The maximum number of packets we should receive from a cient before we consider them to be flooding. + /// + public int MaxPacketPerSec { get; set; } = 50; + + /// + /// The number of packets received per second on average that we will accept before kicking the client for flooding. + /// + public int KickAvgPacketPerSec { get; set; } = 30; + + public static FloodThreshholds Editor() + { + return new FloodThreshholds() + { + MaxPacketSize = int.MaxValue, + MaxPacketPerSec = int.MaxValue, + KickAvgPacketPerSec = int.MaxValue + }; + } + + public static FloodThreshholds NotLoggedIn() + { + return new FloodThreshholds() + { + MaxPacketSize = 10240, + MaxPacketPerSec = 5, + KickAvgPacketPerSec = 3, + }; + } +} \ No newline at end of file diff --git a/Intersect (Core)/Config/Guilds/GuildOptions.cs b/Framework/Intersect.Framework.Core/Config/Guilds/GuildOptions.cs similarity index 100% rename from Intersect (Core)/Config/Guilds/GuildOptions.cs rename to Framework/Intersect.Framework.Core/Config/Guilds/GuildOptions.cs diff --git a/Intersect (Core)/Config/Guilds/GuildPermissions.cs b/Framework/Intersect.Framework.Core/Config/Guilds/GuildPermissions.cs similarity index 100% rename from Intersect (Core)/Config/Guilds/GuildPermissions.cs rename to Framework/Intersect.Framework.Core/Config/Guilds/GuildPermissions.cs diff --git a/Intersect (Core)/Config/Guilds/GuildRank.cs b/Framework/Intersect.Framework.Core/Config/Guilds/GuildRank.cs similarity index 100% rename from Intersect (Core)/Config/Guilds/GuildRank.cs rename to Framework/Intersect.Framework.Core/Config/Guilds/GuildRank.cs diff --git a/Intersect (Core)/Config/InstancingOptions.cs b/Framework/Intersect.Framework.Core/Config/InstancingOptions.cs similarity index 100% rename from Intersect (Core)/Config/InstancingOptions.cs rename to Framework/Intersect.Framework.Core/Config/InstancingOptions.cs diff --git a/Intersect (Core)/Config/ItemOptions.cs b/Framework/Intersect.Framework.Core/Config/ItemOptions.cs similarity index 100% rename from Intersect (Core)/Config/ItemOptions.cs rename to Framework/Intersect.Framework.Core/Config/ItemOptions.cs diff --git a/Intersect (Core)/Config/LayerOptions.cs b/Framework/Intersect.Framework.Core/Config/LayerOptions.cs similarity index 100% rename from Intersect (Core)/Config/LayerOptions.cs rename to Framework/Intersect.Framework.Core/Config/LayerOptions.cs diff --git a/Intersect (Core)/Config/LoggingOptions.cs b/Framework/Intersect.Framework.Core/Config/LoggingOptions.cs similarity index 100% rename from Intersect (Core)/Config/LoggingOptions.cs rename to Framework/Intersect.Framework.Core/Config/LoggingOptions.cs diff --git a/Intersect (Core)/Config/LootOptions.cs b/Framework/Intersect.Framework.Core/Config/LootOptions.cs similarity index 100% rename from Intersect (Core)/Config/LootOptions.cs rename to Framework/Intersect.Framework.Core/Config/LootOptions.cs diff --git a/Intersect (Core)/Config/MapOptions.cs b/Framework/Intersect.Framework.Core/Config/MapOptions.cs similarity index 100% rename from Intersect (Core)/Config/MapOptions.cs rename to Framework/Intersect.Framework.Core/Config/MapOptions.cs diff --git a/Intersect (Core)/Config/MetricsOptions.cs b/Framework/Intersect.Framework.Core/Config/MetricsOptions.cs similarity index 100% rename from Intersect (Core)/Config/MetricsOptions.cs rename to Framework/Intersect.Framework.Core/Config/MetricsOptions.cs diff --git a/Intersect (Core)/Config/NpcOptions.cs b/Framework/Intersect.Framework.Core/Config/NpcOptions.cs similarity index 100% rename from Intersect (Core)/Config/NpcOptions.cs rename to Framework/Intersect.Framework.Core/Config/NpcOptions.cs diff --git a/Intersect (Core)/Config/Options.cs b/Framework/Intersect.Framework.Core/Config/Options.cs similarity index 99% rename from Intersect (Core)/Config/Options.cs rename to Framework/Intersect.Framework.Core/Config/Options.cs index 7ac36402ed..877b9b9229 100644 --- a/Intersect (Core)/Config/Options.cs +++ b/Framework/Intersect.Framework.Core/Config/Options.cs @@ -252,7 +252,6 @@ public static bool LoadFromDisk() Instance.SmtpValid = Instance.SmtpSettings.IsValid(); Instance.SendingToClient = false; Instance.FixAnimatedSprites(); - Log.Default.Configuration.LogLevel = Instance.Logging.Level; File.WriteAllText(configPath, JsonConvert.SerializeObject(Instance, Formatting.Indented)); Instance.SendingToClient = true; optionsCompressed = JsonConvert.SerializeObject(Instance); diff --git a/Intersect (Core)/Config/PacketOptions.cs b/Framework/Intersect.Framework.Core/Config/PacketOptions.cs similarity index 100% rename from Intersect (Core)/Config/PacketOptions.cs rename to Framework/Intersect.Framework.Core/Config/PacketOptions.cs diff --git a/Intersect (Core)/Config/PacketSecurityOptions.cs b/Framework/Intersect.Framework.Core/Config/PacketSecurityOptions.cs similarity index 74% rename from Intersect (Core)/Config/PacketSecurityOptions.cs rename to Framework/Intersect.Framework.Core/Config/PacketSecurityOptions.cs index 0cc83f0077..f9e49409a2 100644 --- a/Intersect (Core)/Config/PacketSecurityOptions.cs +++ b/Framework/Intersect.Framework.Core/Config/PacketSecurityOptions.cs @@ -76,42 +76,4 @@ public partial class PacketSecurityOptions [JsonProperty("FloodThreshholds")] public FloodThreshholds Threshholds = FloodThreshholds.NotLoggedIn(); #endregion -} - -public partial class FloodThreshholds -{ - /// - /// The largest a single packet should be before it's considered flooding. - /// - public int MaxPacketSize { get; set; } = 10240; - - /// - /// The maximum number of packets we should receive from a cient before we consider them to be flooding. - /// - public int MaxPacketPerSec { get; set; } = 50; - - /// - /// The number of packets received per second on average that we will accept before kicking the client for flooding. - /// - public int KickAvgPacketPerSec { get; set; } = 30; - - public static FloodThreshholds Editor() - { - return new FloodThreshholds() - { - MaxPacketSize = int.MaxValue, - MaxPacketPerSec = int.MaxValue, - KickAvgPacketPerSec = int.MaxValue - }; - } - - public static FloodThreshholds NotLoggedIn() - { - return new FloodThreshholds() - { - MaxPacketSize = 10240, - MaxPacketPerSec = 5, - KickAvgPacketPerSec = 3, - }; - } -} +} \ No newline at end of file diff --git a/Intersect (Core)/Config/PaperdollOptions.cs b/Framework/Intersect.Framework.Core/Config/PaperdollOptions.cs similarity index 100% rename from Intersect (Core)/Config/PaperdollOptions.cs rename to Framework/Intersect.Framework.Core/Config/PaperdollOptions.cs diff --git a/Intersect (Core)/Config/PartyOptions.cs b/Framework/Intersect.Framework.Core/Config/PartyOptions.cs similarity index 100% rename from Intersect (Core)/Config/PartyOptions.cs rename to Framework/Intersect.Framework.Core/Config/PartyOptions.cs diff --git a/Intersect (Core)/Config/Passability.cs b/Framework/Intersect.Framework.Core/Config/Passability.cs similarity index 100% rename from Intersect (Core)/Config/Passability.cs rename to Framework/Intersect.Framework.Core/Config/Passability.cs diff --git a/Intersect (Core)/Config/PlayerOptions.cs b/Framework/Intersect.Framework.Core/Config/PlayerOptions.cs similarity index 100% rename from Intersect (Core)/Config/PlayerOptions.cs rename to Framework/Intersect.Framework.Core/Config/PlayerOptions.cs diff --git a/Intersect (Core)/Config/ProcessingOptions.cs b/Framework/Intersect.Framework.Core/Config/ProcessingOptions.cs similarity index 100% rename from Intersect (Core)/Config/ProcessingOptions.cs rename to Framework/Intersect.Framework.Core/Config/ProcessingOptions.cs diff --git a/Intersect (Core)/Config/QuestOptions.cs b/Framework/Intersect.Framework.Core/Config/QuestOptions.cs similarity index 100% rename from Intersect (Core)/Config/QuestOptions.cs rename to Framework/Intersect.Framework.Core/Config/QuestOptions.cs diff --git a/Intersect (Core)/Config/SecurityOptions.cs b/Framework/Intersect.Framework.Core/Config/SecurityOptions.cs similarity index 100% rename from Intersect (Core)/Config/SecurityOptions.cs rename to Framework/Intersect.Framework.Core/Config/SecurityOptions.cs diff --git a/Intersect (Core)/Config/SmtpSettings.cs b/Framework/Intersect.Framework.Core/Config/SmtpSettings.cs similarity index 100% rename from Intersect (Core)/Config/SmtpSettings.cs rename to Framework/Intersect.Framework.Core/Config/SmtpSettings.cs diff --git a/Intersect (Core)/Config/SpriteOptions.cs b/Framework/Intersect.Framework.Core/Config/SpriteOptions.cs similarity index 100% rename from Intersect (Core)/Config/SpriteOptions.cs rename to Framework/Intersect.Framework.Core/Config/SpriteOptions.cs diff --git a/Intersect (Core)/Configuration/ClientConfiguration.cs b/Framework/Intersect.Framework.Core/Configuration/ClientConfiguration.cs similarity index 98% rename from Intersect (Core)/Configuration/ClientConfiguration.cs rename to Framework/Intersect.Framework.Core/Configuration/ClientConfiguration.cs index 27e1b38769..1c4d6f87f1 100644 --- a/Intersect (Core)/Configuration/ClientConfiguration.cs +++ b/Framework/Intersect.Framework.Core/Configuration/ClientConfiguration.cs @@ -3,6 +3,7 @@ using Intersect.Enums; using Intersect.Logging; +using Intersect.Models; using Intersect.Utilities; using Newtonsoft.Json; @@ -14,6 +15,11 @@ namespace Intersect.Configuration; /// public sealed partial class ClientConfiguration : IConfiguration { + public ClientConfiguration() + { + ConfigurationHelper.CacheName = $"{Host}.{Port}"; + } + public static string ResourcesDirectory { get; set; } = "resources"; public static string DefaultPath => Path.Combine(ResourcesDirectory, "config.json"); diff --git a/Intersect (Core)/Configuration/ConfigurationHelper.cs b/Framework/Intersect.Framework.Core/Configuration/ConfigurationHelper.cs similarity index 88% rename from Intersect (Core)/Configuration/ConfigurationHelper.cs rename to Framework/Intersect.Framework.Core/Configuration/ConfigurationHelper.cs index 64cc1df921..f7981c9655 100644 --- a/Intersect (Core)/Configuration/ConfigurationHelper.cs +++ b/Framework/Intersect.Framework.Core/Configuration/ConfigurationHelper.cs @@ -9,6 +9,8 @@ namespace Intersect.Configuration; public static partial class ConfigurationHelper { + public static string CacheName { get; set; } = default!; + public static T Load(T configuration, string filePath, bool failQuietly = false) where T : IConfiguration { @@ -27,7 +29,7 @@ public static T Load(T configuration, string filePath, bool failQuietly = fal } catch (Exception exception) { - Log.Error(exception); + LegacyLogging.Logger?.Error(exception); throw; } @@ -57,7 +59,7 @@ public static T Save(T configuration, string filePath, bool failQuietly = fal } catch (Exception exception) { - Log.Error(exception); + LegacyLogging.Logger?.Error(exception); throw; } @@ -77,7 +79,7 @@ public static T LoadSafely(T configuration, string filePath = null) } catch (Exception exception) { - Log.Warn(exception); + LegacyLogging.Logger?.Warn(exception); } finally { @@ -87,7 +89,7 @@ public static T LoadSafely(T configuration, string filePath = null) } catch (Exception exception) { - Log.Error(exception); + LegacyLogging.Logger?.Error(exception); } } diff --git a/Intersect (Core)/Enums/DisplayDirection.cs b/Framework/Intersect.Framework.Core/Configuration/Features/Video/DisplayDirection.cs similarity index 100% rename from Intersect (Core)/Enums/DisplayDirection.cs rename to Framework/Intersect.Framework.Core/Configuration/Features/Video/DisplayDirection.cs diff --git a/Intersect (Core)/Enums/DisplayMode.cs b/Framework/Intersect.Framework.Core/Configuration/Features/Video/DisplayMode.cs similarity index 100% rename from Intersect (Core)/Enums/DisplayMode.cs rename to Framework/Intersect.Framework.Core/Configuration/Features/Video/DisplayMode.cs diff --git a/Intersect (Core)/Configuration/IConfigurable.cs b/Framework/Intersect.Framework.Core/Configuration/IConfigurable.cs similarity index 100% rename from Intersect (Core)/Configuration/IConfigurable.cs rename to Framework/Intersect.Framework.Core/Configuration/IConfigurable.cs diff --git a/Intersect (Core)/Configuration/IConfiguration.cs b/Framework/Intersect.Framework.Core/Configuration/IConfiguration.cs similarity index 100% rename from Intersect (Core)/Configuration/IConfiguration.cs rename to Framework/Intersect.Framework.Core/Configuration/IConfiguration.cs diff --git a/Intersect (Core)/Core/IApplicationContext.cs b/Framework/Intersect.Framework.Core/Core/IApplicationContext.cs similarity index 96% rename from Intersect (Core)/Core/IApplicationContext.cs rename to Framework/Intersect.Framework.Core/Core/IApplicationContext.cs index 9d05b8dd2c..7217c07c1e 100644 --- a/Intersect (Core)/Core/IApplicationContext.cs +++ b/Framework/Intersect.Framework.Core/Core/IApplicationContext.cs @@ -37,7 +37,7 @@ public interface IApplicationContext : IDisposable /// /// The application-specific logger. /// - Logger Logger { get; } + ILogger Logger { get; } /// /// The network helper for the application. @@ -66,5 +66,5 @@ public interface IApplicationContext : IDisposable /// Start the application with a . /// /// the instance being used - LockingActionQueue StartWithActionQueue(); + ILockingActionQueue StartWithActionQueue(); } diff --git a/Intersect (Core)/Core/IApplicationService.cs b/Framework/Intersect.Framework.Core/Core/IApplicationService.cs similarity index 100% rename from Intersect (Core)/Core/IApplicationService.cs rename to Framework/Intersect.Framework.Core/Core/IApplicationService.cs diff --git a/Intersect (Core)/Core/ICommandLineOptions.cs b/Framework/Intersect.Framework.Core/Core/ICommandLineOptions.cs similarity index 100% rename from Intersect (Core)/Core/ICommandLineOptions.cs rename to Framework/Intersect.Framework.Core/Core/ICommandLineOptions.cs diff --git a/Intersect (Core)/Enums/GameObjectType.cs b/Framework/Intersect.Framework.Core/Descriptors/GameObjectType.cs similarity index 100% rename from Intersect (Core)/Enums/GameObjectType.cs rename to Framework/Intersect.Framework.Core/Descriptors/GameObjectType.cs diff --git a/Intersect (Core)/Enums/GameObjectTypeExtensions.cs b/Framework/Intersect.Framework.Core/Descriptors/GameObjectTypeExtensions.cs similarity index 100% rename from Intersect (Core)/Enums/GameObjectTypeExtensions.cs rename to Framework/Intersect.Framework.Core/Descriptors/GameObjectTypeExtensions.cs diff --git a/Framework/Intersect.Framework.Core/Direction.cs b/Framework/Intersect.Framework.Core/Direction.cs new file mode 100644 index 0000000000..3bf8502179 --- /dev/null +++ b/Framework/Intersect.Framework.Core/Direction.cs @@ -0,0 +1,22 @@ +namespace Intersect.Enums; + +public enum Direction +{ + None = -1, + + Up, + + Down, + + Left, + + Right, + + UpLeft, + + UpRight, + + DownRight, + + DownLeft, +} \ No newline at end of file diff --git a/Intersect (Core)/Enums/Direction.cs b/Framework/Intersect.Framework.Core/DirectionExtensions.cs similarity index 96% rename from Intersect (Core)/Enums/Direction.cs rename to Framework/Intersect.Framework.Core/DirectionExtensions.cs index 53c753d829..62778fa143 100644 --- a/Intersect (Core)/Enums/Direction.cs +++ b/Framework/Intersect.Framework.Core/DirectionExtensions.cs @@ -2,27 +2,6 @@ namespace Intersect.Enums; -public enum Direction -{ - None = -1, - - Up, - - Down, - - Left, - - Right, - - UpLeft, - - UpRight, - - DownRight, - - DownLeft, -} - public static class DirectionExtensions { public static Direction GetOpposite(this Direction direction) => diff --git a/Intersect (Core)/Enums/EntityType.cs b/Framework/Intersect.Framework.Core/Entities/EntityType.cs similarity index 100% rename from Intersect (Core)/Enums/EntityType.cs rename to Framework/Intersect.Framework.Core/Entities/EntityType.cs diff --git a/Intersect (Core)/Utilities/ExperienceCurve.cs b/Framework/Intersect.Framework.Core/Entities/ExperienceCurve.cs similarity index 95% rename from Intersect (Core)/Utilities/ExperienceCurve.cs rename to Framework/Intersect.Framework.Core/Entities/ExperienceCurve.cs index 1f5a341fdb..292ef473a6 100644 --- a/Intersect (Core)/Utilities/ExperienceCurve.cs +++ b/Framework/Intersect.Framework.Core/Entities/ExperienceCurve.cs @@ -7,7 +7,6 @@ namespace Intersect.Server.Utilities; public partial class ExperienceCurve { - public const string DEFAULT_EXPERIENCE_FORMULA = "Floor(BaseExp * Pow(Gain, Level - 1))"; public const string PARAM_BASE_EXP = "BaseExp"; @@ -46,7 +45,7 @@ protected virtual void Exp(FunctionArgs args) { if (args.Parameters == null || args.Parameters.Length < 3) { - Log.Error("Tried to execute Exp with fewer than three arguments."); + LegacyLogging.Logger?.Error("Tried to execute Exp with fewer than three arguments."); args.Result = 0L; } diff --git a/Intersect (Core)/Enums/Gender.cs b/Framework/Intersect.Framework.Core/Entities/Gender.cs similarity index 100% rename from Intersect (Core)/Enums/Gender.cs rename to Framework/Intersect.Framework.Core/Entities/Gender.cs diff --git a/Intersect (Core)/Enums/NpcAggression.cs b/Framework/Intersect.Framework.Core/Entities/NpcAggression.cs similarity index 100% rename from Intersect (Core)/Enums/NpcAggression.cs rename to Framework/Intersect.Framework.Core/Entities/NpcAggression.cs diff --git a/Intersect (Core)/Enums/SpellEffect.cs b/Framework/Intersect.Framework.Core/Entities/SpellEffect.cs similarity index 100% rename from Intersect (Core)/Enums/SpellEffect.cs rename to Framework/Intersect.Framework.Core/Entities/SpellEffect.cs diff --git a/Intersect (Core)/Enums/TargetType.cs b/Framework/Intersect.Framework.Core/Entities/TargetType.cs similarity index 100% rename from Intersect (Core)/Enums/TargetType.cs rename to Framework/Intersect.Framework.Core/Entities/TargetType.cs diff --git a/Intersect (Core)/Enums/Vital.cs b/Framework/Intersect.Framework.Core/Entities/Vital.cs similarity index 100% rename from Intersect (Core)/Enums/Vital.cs rename to Framework/Intersect.Framework.Core/Entities/Vital.cs diff --git a/Intersect (Core)/ErrorHandling/ExceptionInfo.cs b/Framework/Intersect.Framework.Core/ErrorHandling/ExceptionInfo.cs similarity index 100% rename from Intersect (Core)/ErrorHandling/ExceptionInfo.cs rename to Framework/Intersect.Framework.Core/ErrorHandling/ExceptionInfo.cs diff --git a/Intersect (Core)/ErrorHandling/ExceptionRepeater.cs b/Framework/Intersect.Framework.Core/ErrorHandling/ExceptionRepeater.cs similarity index 100% rename from Intersect (Core)/ErrorHandling/ExceptionRepeater.cs rename to Framework/Intersect.Framework.Core/ErrorHandling/ExceptionRepeater.cs diff --git a/Intersect (Core)/GameObjects/AnimationBase.cs b/Framework/Intersect.Framework.Core/GameObjects/AnimationBase.cs similarity index 96% rename from Intersect (Core)/GameObjects/AnimationBase.cs rename to Framework/Intersect.Framework.Core/GameObjects/AnimationBase.cs index bcfca57d0e..6e08f5f72b 100644 --- a/Intersect (Core)/GameObjects/AnimationBase.cs +++ b/Framework/Intersect.Framework.Core/GameObjects/AnimationBase.cs @@ -1,5 +1,4 @@ using System.ComponentModel.DataAnnotations.Schema; - using Intersect.Models; using Microsoft.EntityFrameworkCore; @@ -21,7 +20,7 @@ public AnimationLayer() } } - public string Sprite { get; set; } = ""; + public string Sprite { get; set; } = string.Empty; public int FrameCount { get; set; } = 1; diff --git a/Intersect (Core)/GameObjects/Annotations/EditorBooleanAttribute.cs b/Framework/Intersect.Framework.Core/GameObjects/Annotations/EditorBooleanAttribute.cs similarity index 100% rename from Intersect (Core)/GameObjects/Annotations/EditorBooleanAttribute.cs rename to Framework/Intersect.Framework.Core/GameObjects/Annotations/EditorBooleanAttribute.cs diff --git a/Intersect (Core)/GameObjects/Annotations/EditorDictionaryAttribute.cs b/Framework/Intersect.Framework.Core/GameObjects/Annotations/EditorDictionaryAttribute.cs similarity index 98% rename from Intersect (Core)/GameObjects/Annotations/EditorDictionaryAttribute.cs rename to Framework/Intersect.Framework.Core/GameObjects/Annotations/EditorDictionaryAttribute.cs index 6d983f544b..fae1e433eb 100644 --- a/Intersect (Core)/GameObjects/Annotations/EditorDictionaryAttribute.cs +++ b/Framework/Intersect.Framework.Core/GameObjects/Annotations/EditorDictionaryAttribute.cs @@ -1,8 +1,7 @@ using System.Globalization; using System.Reflection; - +using Intersect.Framework.Reflection; using Intersect.Localization; -using Intersect.Reflection; #if !DEBUG using Intersect.Logging; @@ -48,7 +47,7 @@ public override string Format(Type stringsType, object value) #if DEBUG throw error; #else - Log.Error(error); + LegacyLogging.Logger?.Error(error); return base.Format(stringsType, value); #endif } diff --git a/Intersect (Core)/GameObjects/Annotations/EditorDisplayAttribute.cs b/Framework/Intersect.Framework.Core/GameObjects/Annotations/EditorDisplayAttribute.cs similarity index 100% rename from Intersect (Core)/GameObjects/Annotations/EditorDisplayAttribute.cs rename to Framework/Intersect.Framework.Core/GameObjects/Annotations/EditorDisplayAttribute.cs diff --git a/Intersect (Core)/GameObjects/Annotations/EditorEnumAttribute.cs b/Framework/Intersect.Framework.Core/GameObjects/Annotations/EditorEnumAttribute.cs similarity index 100% rename from Intersect (Core)/GameObjects/Annotations/EditorEnumAttribute.cs rename to Framework/Intersect.Framework.Core/GameObjects/Annotations/EditorEnumAttribute.cs diff --git a/Intersect (Core)/GameObjects/Annotations/EditorFieldType.cs b/Framework/Intersect.Framework.Core/GameObjects/Annotations/EditorFieldType.cs similarity index 100% rename from Intersect (Core)/GameObjects/Annotations/EditorFieldType.cs rename to Framework/Intersect.Framework.Core/GameObjects/Annotations/EditorFieldType.cs diff --git a/Intersect (Core)/GameObjects/Annotations/EditorFormattedAttribute.cs b/Framework/Intersect.Framework.Core/GameObjects/Annotations/EditorFormattedAttribute.cs similarity index 97% rename from Intersect (Core)/GameObjects/Annotations/EditorFormattedAttribute.cs rename to Framework/Intersect.Framework.Core/GameObjects/Annotations/EditorFormattedAttribute.cs index 80dc873a76..1e3d10b6d4 100644 --- a/Intersect (Core)/GameObjects/Annotations/EditorFormattedAttribute.cs +++ b/Framework/Intersect.Framework.Core/GameObjects/Annotations/EditorFormattedAttribute.cs @@ -1,6 +1,7 @@ using System.Reflection; using Intersect.Localization; +using Intersect.Logging; #if !DEBUG using Intersect.Logging; @@ -46,7 +47,7 @@ public override string Format(Type stringsType, object value) #if DEBUG throw error; #else - Log.Error(error); + LegacyLogging.Logger?.Error(error); return base.Format(stringsType, value); #endif } diff --git a/Intersect (Core)/GameObjects/Annotations/EditorLabelAttribute.cs b/Framework/Intersect.Framework.Core/GameObjects/Annotations/EditorLabelAttribute.cs similarity index 100% rename from Intersect (Core)/GameObjects/Annotations/EditorLabelAttribute.cs rename to Framework/Intersect.Framework.Core/GameObjects/Annotations/EditorLabelAttribute.cs diff --git a/Intersect (Core)/GameObjects/Annotations/EditorReferenceAttribute.cs b/Framework/Intersect.Framework.Core/GameObjects/Annotations/EditorReferenceAttribute.cs similarity index 92% rename from Intersect (Core)/GameObjects/Annotations/EditorReferenceAttribute.cs rename to Framework/Intersect.Framework.Core/GameObjects/Annotations/EditorReferenceAttribute.cs index 8802b0818e..b2b1c9528f 100644 --- a/Intersect (Core)/GameObjects/Annotations/EditorReferenceAttribute.cs +++ b/Framework/Intersect.Framework.Core/GameObjects/Annotations/EditorReferenceAttribute.cs @@ -52,9 +52,9 @@ public override string Format(Type stringsType, object value) else { var lookup = DescriptorType - .GetProperties(BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy) - .FirstOrDefault(propertyInfo => propertyInfo.PropertyType == typeof(DatabaseObjectLookup))? - .GetValue(null) as DatabaseObjectLookup; + .GetFields(BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy) + .FirstOrDefault(fieldInfo => fieldInfo.FieldType == typeof(DatabaseObjectLookup))? + .GetValue(null) as DatabaseObjectLookup; if (lookup == default) { diff --git a/Intersect (Core)/GameObjects/Annotations/EditorTimeAttribute.cs b/Framework/Intersect.Framework.Core/GameObjects/Annotations/EditorTimeAttribute.cs similarity index 100% rename from Intersect (Core)/GameObjects/Annotations/EditorTimeAttribute.cs rename to Framework/Intersect.Framework.Core/GameObjects/Annotations/EditorTimeAttribute.cs diff --git a/Intersect (Core)/GameObjects/ClassBase.cs b/Framework/Intersect.Framework.Core/GameObjects/ClassBase.cs similarity index 100% rename from Intersect (Core)/GameObjects/ClassBase.cs rename to Framework/Intersect.Framework.Core/GameObjects/ClassBase.cs diff --git a/Intersect (Core)/GameObjects/Conditions/ConditionList.cs b/Framework/Intersect.Framework.Core/GameObjects/Conditions/ConditionList.cs similarity index 81% rename from Intersect (Core)/GameObjects/Conditions/ConditionList.cs rename to Framework/Intersect.Framework.Core/GameObjects/Conditions/ConditionList.cs index 9613049437..ed94786251 100644 --- a/Intersect (Core)/GameObjects/Conditions/ConditionList.cs +++ b/Framework/Intersect.Framework.Core/GameObjects/Conditions/ConditionList.cs @@ -1,4 +1,5 @@ -using Intersect.GameObjects.Events; +using Intersect.Framework.Core.Serialization; +using Intersect.GameObjects.Events; using Newtonsoft.Json; @@ -26,6 +27,7 @@ public void Load(string data) this, new JsonSerializerSettings() { + SerializationBinder = new IntersectTypeSerializationBinder(), TypeNameHandling = TypeNameHandling.Auto, DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate, ObjectCreationHandling = ObjectCreationHandling.Replace @@ -39,6 +41,7 @@ public string Data() this, new JsonSerializerSettings() { + SerializationBinder = new IntersectTypeSerializationBinder(), TypeNameHandling = TypeNameHandling.Auto, DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate } diff --git a/Intersect (Core)/GameObjects/Conditions/ConditionLists.cs b/Framework/Intersect.Framework.Core/GameObjects/Conditions/ConditionLists.cs similarity index 89% rename from Intersect (Core)/GameObjects/Conditions/ConditionLists.cs rename to Framework/Intersect.Framework.Core/GameObjects/Conditions/ConditionLists.cs index 775f7acb85..e52fce7d58 100644 --- a/Intersect (Core)/GameObjects/Conditions/ConditionLists.cs +++ b/Framework/Intersect.Framework.Core/GameObjects/Conditions/ConditionLists.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json; +using Intersect.Framework.Core.Serialization; +using Newtonsoft.Json; using Newtonsoft.Json.Linq; namespace Intersect.GameObjects.Conditions; @@ -27,9 +28,10 @@ public void Load(string data) Lists, new JsonSerializerSettings() { + SerializationBinder = new IntersectTypeSerializationBinder(), TypeNameHandling = TypeNameHandling.Auto, DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate, - ObjectCreationHandling = ObjectCreationHandling.Replace + ObjectCreationHandling = ObjectCreationHandling.Replace, } ); } @@ -40,6 +42,7 @@ public string Data() Lists, new JsonSerializerSettings() { + SerializationBinder = new IntersectTypeSerializationBinder(), TypeNameHandling = TypeNameHandling.Auto, DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate } diff --git a/Framework/Intersect.Framework.Core/GameObjects/Conditions/ConditionTypes.cs b/Framework/Intersect.Framework.Core/GameObjects/Conditions/ConditionTypes.cs new file mode 100644 index 0000000000..38ba51f3b7 --- /dev/null +++ b/Framework/Intersect.Framework.Core/GameObjects/Conditions/ConditionTypes.cs @@ -0,0 +1,42 @@ +namespace Intersect.GameObjects.Events; + +public enum ConditionTypes +{ + VariableIs = 0, + + HasItem = 4, + + ClassIs, + + KnowsSpell, + + LevelOrStat, + + SelfSwitch, //Only works for events.. not for checking if you can destroy a resource or something like that + + AccessIs, + + TimeBetween, + + CanStartQuest, + + QuestInProgress, + + QuestCompleted, + + NoNpcsOnMap, + + GenderIs, + + MapIs, + + IsItemEquipped, + + HasFreeInventorySlots, + + InGuildWithRank, + + MapZoneTypeIs, + + CheckEquipment, +} \ No newline at end of file diff --git a/Intersect (Core)/GameObjects/Crafting/CraftBase.cs b/Framework/Intersect.Framework.Core/GameObjects/Crafting/CraftBase.cs similarity index 100% rename from Intersect (Core)/GameObjects/Crafting/CraftBase.cs rename to Framework/Intersect.Framework.Core/GameObjects/Crafting/CraftBase.cs diff --git a/Intersect (Core)/GameObjects/Crafting/CraftingTableBase.cs b/Framework/Intersect.Framework.Core/GameObjects/Crafting/CraftingTableBase.cs similarity index 100% rename from Intersect (Core)/GameObjects/Crafting/CraftingTableBase.cs rename to Framework/Intersect.Framework.Core/GameObjects/Crafting/CraftingTableBase.cs diff --git a/Intersect (Core)/GameObjects/Drop.cs b/Framework/Intersect.Framework.Core/GameObjects/Drop.cs similarity index 100% rename from Intersect (Core)/GameObjects/Drop.cs rename to Framework/Intersect.Framework.Core/GameObjects/Drop.cs diff --git a/Intersect (Core)/GameObjects/EquipmentProperties.ShouldBeGenerated.cs b/Framework/Intersect.Framework.Core/GameObjects/EquipmentProperties.ShouldBeGenerated.cs similarity index 100% rename from Intersect (Core)/GameObjects/EquipmentProperties.ShouldBeGenerated.cs rename to Framework/Intersect.Framework.Core/GameObjects/EquipmentProperties.ShouldBeGenerated.cs diff --git a/Intersect (Core)/GameObjects/EquipmentProperties.cs b/Framework/Intersect.Framework.Core/GameObjects/EquipmentProperties.cs similarity index 100% rename from Intersect (Core)/GameObjects/EquipmentProperties.cs rename to Framework/Intersect.Framework.Core/GameObjects/EquipmentProperties.cs diff --git a/Intersect (Core)/Enums/Access.cs b/Framework/Intersect.Framework.Core/GameObjects/Events/Access.cs similarity index 100% rename from Intersect (Core)/Enums/Access.cs rename to Framework/Intersect.Framework.Core/GameObjects/Events/Access.cs diff --git a/Intersect (Core)/GameObjects/Events/Commands/EventCommands.cs b/Framework/Intersect.Framework.Core/GameObjects/Events/Commands/EventCommands.cs similarity index 99% rename from Intersect (Core)/GameObjects/Events/Commands/EventCommands.cs rename to Framework/Intersect.Framework.Core/GameObjects/Events/Commands/EventCommands.cs index a3a356e3a4..ab5c3fbe1e 100644 --- a/Intersect (Core)/GameObjects/Events/Commands/EventCommands.cs +++ b/Framework/Intersect.Framework.Core/GameObjects/Events/Commands/EventCommands.cs @@ -1,4 +1,5 @@ using Intersect.Enums; +using Intersect.Framework.Core.Serialization; using Newtonsoft.Json; namespace Intersect.GameObjects.Events.Commands; @@ -17,6 +18,7 @@ Dictionary> copyLists typeof(EventCommand), new JsonSerializerSettings() { + SerializationBinder = new IntersectTypeSerializationBinder(), Formatting = Formatting.None, TypeNameHandling = TypeNameHandling.Auto, DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate, diff --git a/Intersect (Core)/Enums/CommonEventTrigger.cs b/Framework/Intersect.Framework.Core/GameObjects/Events/CommonEventTrigger.cs similarity index 100% rename from Intersect (Core)/Enums/CommonEventTrigger.cs rename to Framework/Intersect.Framework.Core/GameObjects/Events/CommonEventTrigger.cs diff --git a/Intersect (Core)/GameObjects/Events/Condition.cs b/Framework/Intersect.Framework.Core/GameObjects/Events/Condition.cs similarity index 93% rename from Intersect (Core)/GameObjects/Events/Condition.cs rename to Framework/Intersect.Framework.Core/GameObjects/Events/Condition.cs index e521e24832..0cba1cf0a7 100644 --- a/Intersect (Core)/GameObjects/Events/Condition.cs +++ b/Framework/Intersect.Framework.Core/GameObjects/Events/Condition.cs @@ -2,47 +2,6 @@ namespace Intersect.GameObjects.Events; -public enum ConditionTypes -{ - VariableIs = 0, - - HasItem = 4, - - ClassIs, - - KnowsSpell, - - LevelOrStat, - - SelfSwitch, //Only works for events.. not for checking if you can destroy a resource or something like that - - AccessIs, - - TimeBetween, - - CanStartQuest, - - QuestInProgress, - - QuestCompleted, - - NoNpcsOnMap, - - GenderIs, - - MapIs, - - IsItemEquipped, - - HasFreeInventorySlots, - - InGuildWithRank, - - MapZoneTypeIs, - - CheckEquipment, -} - public partial class Condition { public virtual ConditionTypes Type { get; } diff --git a/Intersect (Core)/GameObjects/Events/Enums.cs b/Framework/Intersect.Framework.Core/GameObjects/Events/Enums.cs similarity index 100% rename from Intersect (Core)/GameObjects/Events/Enums.cs rename to Framework/Intersect.Framework.Core/GameObjects/Events/Enums.cs diff --git a/Intersect (Core)/GameObjects/Events/EventBase.cs b/Framework/Intersect.Framework.Core/GameObjects/Events/EventBase.cs similarity index 93% rename from Intersect (Core)/GameObjects/Events/EventBase.cs rename to Framework/Intersect.Framework.Core/GameObjects/Events/EventBase.cs index ef1d04e16e..95a1045b93 100644 --- a/Intersect (Core)/GameObjects/Events/EventBase.cs +++ b/Framework/Intersect.Framework.Core/GameObjects/Events/EventBase.cs @@ -1,5 +1,5 @@ using System.ComponentModel.DataAnnotations.Schema; - +using Intersect.Framework.Core.Serialization; using Intersect.Models; using Newtonsoft.Json; @@ -83,6 +83,7 @@ public string PagesJson value, new JsonSerializerSettings() { + SerializationBinder = new IntersectTypeSerializationBinder(), TypeNameHandling = TypeNameHandling.Auto, DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate, ObjectCreationHandling = ObjectCreationHandling.Replace @@ -101,6 +102,7 @@ public List Pages Pages, new JsonSerializerSettings() { + SerializationBinder = new IntersectTypeSerializationBinder(), TypeNameHandling = TypeNameHandling.Auto, DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate, ObjectCreationHandling = ObjectCreationHandling.Replace @@ -126,6 +128,7 @@ public List Pages this, Formatting.Indented, new JsonSerializerSettings() { + SerializationBinder = new IntersectTypeSerializationBinder(), TypeNameHandling = TypeNameHandling.Auto, DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate, ObjectCreationHandling = ObjectCreationHandling.Replace } @@ -188,6 +191,7 @@ public override void Load(string json, bool keepCreationTime = false) this, new JsonSerializerSettings() { + SerializationBinder = new IntersectTypeSerializationBinder(), TypeNameHandling = TypeNameHandling.Auto, DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate, ObjectCreationHandling = ObjectCreationHandling.Replace diff --git a/Intersect (Core)/GameObjects/Events/EventGraphic.cs b/Framework/Intersect.Framework.Core/GameObjects/Events/EventGraphic.cs similarity index 100% rename from Intersect (Core)/GameObjects/Events/EventGraphic.cs rename to Framework/Intersect.Framework.Core/GameObjects/Events/EventGraphic.cs diff --git a/Intersect (Core)/Enums/EventGraphicType.cs b/Framework/Intersect.Framework.Core/GameObjects/Events/EventGraphicType.cs similarity index 100% rename from Intersect (Core)/Enums/EventGraphicType.cs rename to Framework/Intersect.Framework.Core/GameObjects/Events/EventGraphicType.cs diff --git a/Intersect (Core)/GameObjects/Events/EventMoveRoute.cs b/Framework/Intersect.Framework.Core/GameObjects/Events/EventMoveRoute.cs similarity index 100% rename from Intersect (Core)/GameObjects/Events/EventMoveRoute.cs rename to Framework/Intersect.Framework.Core/GameObjects/Events/EventMoveRoute.cs diff --git a/Intersect (Core)/GameObjects/Events/EventMovement.cs b/Framework/Intersect.Framework.Core/GameObjects/Events/EventMovement.cs similarity index 100% rename from Intersect (Core)/GameObjects/Events/EventMovement.cs rename to Framework/Intersect.Framework.Core/GameObjects/Events/EventMovement.cs diff --git a/Intersect (Core)/Enums/EventMovementFrequency.cs b/Framework/Intersect.Framework.Core/GameObjects/Events/EventMovementFrequency.cs similarity index 100% rename from Intersect (Core)/Enums/EventMovementFrequency.cs rename to Framework/Intersect.Framework.Core/GameObjects/Events/EventMovementFrequency.cs diff --git a/Intersect (Core)/Enums/EventMovementSpeed.cs b/Framework/Intersect.Framework.Core/GameObjects/Events/EventMovementSpeed.cs similarity index 100% rename from Intersect (Core)/Enums/EventMovementSpeed.cs rename to Framework/Intersect.Framework.Core/GameObjects/Events/EventMovementSpeed.cs diff --git a/Intersect (Core)/Enums/EventMovementType.cs b/Framework/Intersect.Framework.Core/GameObjects/Events/EventMovementType.cs similarity index 100% rename from Intersect (Core)/Enums/EventMovementType.cs rename to Framework/Intersect.Framework.Core/GameObjects/Events/EventMovementType.cs diff --git a/Intersect (Core)/GameObjects/Events/EventPage.cs b/Framework/Intersect.Framework.Core/GameObjects/Events/EventPage.cs similarity index 100% rename from Intersect (Core)/GameObjects/Events/EventPage.cs rename to Framework/Intersect.Framework.Core/GameObjects/Events/EventPage.cs diff --git a/Intersect (Core)/Enums/EventRenderLayer.cs b/Framework/Intersect.Framework.Core/GameObjects/Events/EventRenderLayer.cs similarity index 100% rename from Intersect (Core)/Enums/EventRenderLayer.cs rename to Framework/Intersect.Framework.Core/GameObjects/Events/EventRenderLayer.cs diff --git a/Intersect (Core)/Enums/EventTrigger.cs b/Framework/Intersect.Framework.Core/GameObjects/Events/EventTrigger.cs similarity index 100% rename from Intersect (Core)/Enums/EventTrigger.cs rename to Framework/Intersect.Framework.Core/GameObjects/Events/EventTrigger.cs diff --git a/Intersect (Core)/GameObjects/Events/MoveRouteAction.cs b/Framework/Intersect.Framework.Core/GameObjects/Events/MoveRouteAction.cs similarity index 100% rename from Intersect (Core)/GameObjects/Events/MoveRouteAction.cs rename to Framework/Intersect.Framework.Core/GameObjects/Events/MoveRouteAction.cs diff --git a/Intersect (Core)/Enums/StringVariableComparator.cs b/Framework/Intersect.Framework.Core/GameObjects/Events/StringVariableComparator.cs similarity index 100% rename from Intersect (Core)/Enums/StringVariableComparator.cs rename to Framework/Intersect.Framework.Core/GameObjects/Events/StringVariableComparator.cs diff --git a/Intersect (Core)/Enums/VariableComparator.cs b/Framework/Intersect.Framework.Core/GameObjects/Events/VariableComparator.cs similarity index 100% rename from Intersect (Core)/Enums/VariableComparator.cs rename to Framework/Intersect.Framework.Core/GameObjects/Events/VariableComparator.cs diff --git a/Intersect (Core)/GameObjects/Events/VariableMod.cs b/Framework/Intersect.Framework.Core/GameObjects/Events/VariableMod.cs similarity index 83% rename from Intersect (Core)/GameObjects/Events/VariableMod.cs rename to Framework/Intersect.Framework.Core/GameObjects/Events/VariableMod.cs index ac9b7f947b..2e8ca016e8 100644 --- a/Intersect (Core)/GameObjects/Events/VariableMod.cs +++ b/Framework/Intersect.Framework.Core/GameObjects/Events/VariableMod.cs @@ -12,7 +12,7 @@ public partial class VariableMod public partial class IntegerVariableMod : VariableMod { - public Enums.VariableMod ModType { get; set; } = Enums.VariableMod.Set; + public VariableModType ModType { get; set; } = VariableModType.Set; public long Value { get; set; } @@ -34,7 +34,7 @@ public partial class BooleanVariableMod : VariableMod public partial class StringVariableMod : VariableMod { - public Enums.VariableMod ModType { get; set; } = Enums.VariableMod.Set; + public VariableModType ModType { get; set; } = VariableModType.Set; public string Value { get; set; } diff --git a/Intersect (Core)/Enums/VariableMod.cs b/Framework/Intersect.Framework.Core/GameObjects/Events/VariableModType.cs similarity index 98% rename from Intersect (Core)/Enums/VariableMod.cs rename to Framework/Intersect.Framework.Core/GameObjects/Events/VariableModType.cs index 1972a3347c..9529ef907d 100644 --- a/Intersect (Core)/Enums/VariableMod.cs +++ b/Framework/Intersect.Framework.Core/GameObjects/Events/VariableModType.cs @@ -2,7 +2,7 @@ namespace Intersect.Enums; -public enum VariableMod +public enum VariableModType { Set = 0, diff --git a/Intersect (Core)/Enums/VariableType.cs b/Framework/Intersect.Framework.Core/GameObjects/Events/VariableType.cs similarity index 100% rename from Intersect (Core)/Enums/VariableType.cs rename to Framework/Intersect.Framework.Core/GameObjects/Events/VariableType.cs diff --git a/Intersect (Core)/GameObjects/GuildVariableBase.cs b/Framework/Intersect.Framework.Core/GameObjects/GuildVariableBase.cs similarity index 100% rename from Intersect (Core)/GameObjects/GuildVariableBase.cs rename to Framework/Intersect.Framework.Core/GameObjects/GuildVariableBase.cs diff --git a/Intersect (Core)/GameObjects/IGameObject.cs b/Framework/Intersect.Framework.Core/GameObjects/IGameObject.cs similarity index 100% rename from Intersect (Core)/GameObjects/IGameObject.cs rename to Framework/Intersect.Framework.Core/GameObjects/IGameObject.cs diff --git a/Intersect (Core)/GameObjects/ItemBase.cs b/Framework/Intersect.Framework.Core/GameObjects/ItemBase.cs similarity index 100% rename from Intersect (Core)/GameObjects/ItemBase.cs rename to Framework/Intersect.Framework.Core/GameObjects/ItemBase.cs diff --git a/Intersect (Core)/Enums/ConsumableType.cs b/Framework/Intersect.Framework.Core/GameObjects/Items/ConsumableType.cs similarity index 100% rename from Intersect (Core)/Enums/ConsumableType.cs rename to Framework/Intersect.Framework.Core/GameObjects/Items/ConsumableType.cs diff --git a/Intersect (Core)/Enums/ItemEffect.cs b/Framework/Intersect.Framework.Core/GameObjects/Items/ItemEffect.cs similarity index 100% rename from Intersect (Core)/Enums/ItemEffect.cs rename to Framework/Intersect.Framework.Core/GameObjects/Items/ItemEffect.cs diff --git a/Intersect (Core)/Enums/ItemHandling.cs b/Framework/Intersect.Framework.Core/GameObjects/Items/ItemHandling.cs similarity index 100% rename from Intersect (Core)/Enums/ItemHandling.cs rename to Framework/Intersect.Framework.Core/GameObjects/Items/ItemHandling.cs diff --git a/Intersect (Core)/Network/Packets/Server/ItemProperties.cs b/Framework/Intersect.Framework.Core/GameObjects/Items/ItemProperties.cs similarity index 100% rename from Intersect (Core)/Network/Packets/Server/ItemProperties.cs rename to Framework/Intersect.Framework.Core/GameObjects/Items/ItemProperties.cs diff --git a/Intersect (Core)/Enums/ItemType.cs b/Framework/Intersect.Framework.Core/GameObjects/Items/ItemType.cs similarity index 100% rename from Intersect (Core)/Enums/ItemType.cs rename to Framework/Intersect.Framework.Core/GameObjects/Items/ItemType.cs diff --git a/Intersect (Core)/Enums/Stat.cs b/Framework/Intersect.Framework.Core/GameObjects/Items/Stat.cs similarity index 100% rename from Intersect (Core)/Enums/Stat.cs rename to Framework/Intersect.Framework.Core/GameObjects/Items/Stat.cs diff --git a/Intersect (Core)/GameObjects/LightBase.cs b/Framework/Intersect.Framework.Core/GameObjects/LightBase.cs similarity index 100% rename from Intersect (Core)/GameObjects/LightBase.cs rename to Framework/Intersect.Framework.Core/GameObjects/LightBase.cs diff --git a/Intersect (Core)/GameObjects/Maps/MapAttribute.cs b/Framework/Intersect.Framework.Core/GameObjects/Maps/MapAttribute.cs similarity index 84% rename from Intersect (Core)/GameObjects/Maps/MapAttribute.cs rename to Framework/Intersect.Framework.Core/GameObjects/Maps/MapAttribute.cs index aec10a137c..ca0c15e1ec 100644 --- a/Intersect (Core)/GameObjects/Maps/MapAttribute.cs +++ b/Framework/Intersect.Framework.Core/GameObjects/Maps/MapAttribute.cs @@ -10,35 +10,35 @@ public abstract partial class MapAttribute { [EditorLabel("Attributes", "AttributeType")] [EditorDictionary("Attributes", "AttributeTypes", FieldType = EditorFieldType.Pivot)] - public abstract Enums.MapAttribute Type { get; } + public abstract MapAttributeType Type { get; } - public static MapAttribute CreateAttribute(Enums.MapAttribute type) + public static MapAttribute CreateAttribute(MapAttributeType type) { switch (type) { - case Enums.MapAttribute.Walkable: + case MapAttributeType.Walkable: return null; - case Enums.MapAttribute.Blocked: + case MapAttributeType.Blocked: return new MapBlockedAttribute(); - case Enums.MapAttribute.Item: + case MapAttributeType.Item: return new MapItemAttribute(); - case Enums.MapAttribute.ZDimension: + case MapAttributeType.ZDimension: return new MapZDimensionAttribute(); - case Enums.MapAttribute.NpcAvoid: + case MapAttributeType.NpcAvoid: return new MapNpcAvoidAttribute(); - case Enums.MapAttribute.Warp: + case MapAttributeType.Warp: return new MapWarpAttribute(); - case Enums.MapAttribute.Sound: + case MapAttributeType.Sound: return new MapSoundAttribute(); - case Enums.MapAttribute.Resource: + case MapAttributeType.Resource: return new MapResourceAttribute(); - case Enums.MapAttribute.Animation: + case MapAttributeType.Animation: return new MapAnimationAttribute(); - case Enums.MapAttribute.GrappleStone: + case MapAttributeType.GrappleStone: return new MapGrappleStoneAttribute(); - case Enums.MapAttribute.Slide: + case MapAttributeType.Slide: return new MapSlideAttribute(); - case Enums.MapAttribute.Critter: + case MapAttributeType.Critter: return new MapCritterAttribute(); } @@ -58,12 +58,12 @@ public string Data() public partial class MapBlockedAttribute : MapAttribute { - public override Enums.MapAttribute Type => Enums.MapAttribute.Blocked; + public override MapAttributeType Type => MapAttributeType.Blocked; } public partial class MapItemAttribute : MapAttribute { - public override Enums.MapAttribute Type => Enums.MapAttribute.Item; + public override MapAttributeType Type => MapAttributeType.Item; [EditorLabel("Attributes", "Item")] [EditorReference(typeof(ItemBase), nameof(ItemBase.Name))] @@ -88,7 +88,7 @@ public override MapAttribute Clone() public partial class MapZDimensionAttribute : MapAttribute { - public override Enums.MapAttribute Type => Enums.MapAttribute.ZDimension; + public override MapAttributeType Type => MapAttributeType.ZDimension; [EditorLabel("Attributes", "ZGateway")] [EditorFormatted("Attributes", "FormatZLevel")] @@ -110,12 +110,12 @@ public override MapAttribute Clone() public partial class MapNpcAvoidAttribute : MapAttribute { - public override Enums.MapAttribute Type => Enums.MapAttribute.NpcAvoid; + public override MapAttributeType Type => MapAttributeType.NpcAvoid; } public partial class MapWarpAttribute : MapAttribute { - public override Enums.MapAttribute Type => Enums.MapAttribute.Warp; + public override MapAttributeType Type => MapAttributeType.Warp; [EditorLabel("Attributes", "Map")] [EditorReference(typeof(MapBase), nameof(MapBase.Name))] @@ -164,7 +164,7 @@ public override MapAttribute Clone() public partial class MapSoundAttribute : MapAttribute { - public override Enums.MapAttribute Type => Enums.MapAttribute.Sound; + public override MapAttributeType Type => MapAttributeType.Sound; [EditorLabel("Attributes", "Sound")] [EditorDisplay( @@ -194,7 +194,7 @@ public override MapAttribute Clone() public partial class MapResourceAttribute : MapAttribute { - public override Enums.MapAttribute Type => Enums.MapAttribute.Resource; + public override MapAttributeType Type => MapAttributeType.Resource; [EditorLabel("Attributes", "Resource")] [EditorReference(typeof(ResourceBase), nameof(ResourceBase.Name))] @@ -216,7 +216,7 @@ public override MapAttribute Clone() public partial class MapAnimationAttribute : MapAttribute { - public override Enums.MapAttribute Type => Enums.MapAttribute.Animation; + public override MapAttributeType Type => MapAttributeType.Animation; [EditorLabel("Attributes", "MapAnimation")] [EditorReference(typeof(AnimationBase), nameof(AnimationBase.Name))] @@ -238,12 +238,12 @@ public override MapAttribute Clone() public partial class MapGrappleStoneAttribute : MapAttribute { - public override Enums.MapAttribute Type => Enums.MapAttribute.GrappleStone; + public override MapAttributeType Type => MapAttributeType.GrappleStone; } public partial class MapSlideAttribute : MapAttribute { - public override Enums.MapAttribute Type => Enums.MapAttribute.Slide; + public override MapAttributeType Type => MapAttributeType.Slide; [EditorLabel("Attributes", "Direction")] [EditorDictionary(nameof(Direction), "WarpDirections")] @@ -260,7 +260,7 @@ public override MapAttribute Clone() public partial class MapCritterAttribute : MapAttribute { - public override Enums.MapAttribute Type => Enums.MapAttribute.Critter; + public override MapAttributeType Type => MapAttributeType.Critter; [EditorLabel("Attributes", "CritterSprite")] [EditorDisplay( diff --git a/Intersect (Core)/Enums/MapAttribute.cs b/Framework/Intersect.Framework.Core/GameObjects/Maps/MapAttributeType.cs similarity index 85% rename from Intersect (Core)/Enums/MapAttribute.cs rename to Framework/Intersect.Framework.Core/GameObjects/Maps/MapAttributeType.cs index 22cb974753..89b15b49f5 100644 --- a/Intersect (Core)/Enums/MapAttribute.cs +++ b/Framework/Intersect.Framework.Core/GameObjects/Maps/MapAttributeType.cs @@ -1,6 +1,6 @@ namespace Intersect.Enums; -public enum MapAttribute : byte +public enum MapAttributeType : byte { Walkable = 0, diff --git a/Intersect (Core)/GameObjects/Maps/MapAutotiles.cs b/Framework/Intersect.Framework.Core/GameObjects/Maps/MapAutotiles.cs similarity index 99% rename from Intersect (Core)/GameObjects/Maps/MapAutotiles.cs rename to Framework/Intersect.Framework.Core/GameObjects/Maps/MapAutotiles.cs index 41f5e76018..da76cd0cba 100644 --- a/Intersect (Core)/GameObjects/Maps/MapAutotiles.cs +++ b/Framework/Intersect.Framework.Core/GameObjects/Maps/MapAutotiles.cs @@ -536,14 +536,14 @@ public void CacheRenderState(int x, int y, string layerName) if (mMyMap == null) { - Log.Error($"{nameof(mMyMap)}=null"); + LegacyLogging.Logger?.Error($"{nameof(mMyMap)}=null"); return; } if (mMyMap.Layers == null) { - Log.Error($"{nameof(mMyMap.Layers)}=null"); + LegacyLogging.Logger?.Error($"{nameof(mMyMap.Layers)}=null"); return; } @@ -556,7 +556,7 @@ public void CacheRenderState(int x, int y, string layerName) var layer = mMyMap.Layers[layerName]; if (mMyMap.Layers[layerName] == null) { - Log.Error($"{nameof(layer)}=null"); + LegacyLogging.Logger?.Error($"{nameof(layer)}=null"); return; } @@ -601,14 +601,14 @@ public void CalculateAutotile(int x, int y, string layerName, MapBase[,] surroun // Exit out if we don//t have an auatotile if (mMyMap == null) { - Log.Error($"{nameof(mMyMap)}=null"); + LegacyLogging.Logger?.Error($"{nameof(mMyMap)}=null"); return; } if (mMyMap.Layers == null) { - Log.Error($"{nameof(mMyMap.Layers)}=null"); + LegacyLogging.Logger?.Error($"{nameof(mMyMap.Layers)}=null"); return; } @@ -621,7 +621,7 @@ public void CalculateAutotile(int x, int y, string layerName, MapBase[,] surroun var layer = mMyMap.Layers[layerName]; if (mMyMap.Layers[layerName] == null) { - Log.Error($"{nameof(layer)}=null"); + LegacyLogging.Logger?.Error($"{nameof(layer)}=null"); return; } diff --git a/Intersect (Core)/GameObjects/Maps/MapBase.cs b/Framework/Intersect.Framework.Core/GameObjects/Maps/MapBase.cs similarity index 97% rename from Intersect (Core)/GameObjects/Maps/MapBase.cs rename to Framework/Intersect.Framework.Core/GameObjects/Maps/MapBase.cs index f81170c86a..838ca9c2d9 100644 --- a/Intersect (Core)/GameObjects/Maps/MapBase.cs +++ b/Framework/Intersect.Framework.Core/GameObjects/Maps/MapBase.cs @@ -2,6 +2,7 @@ using Intersect.Collections; using Intersect.Compression; using Intersect.Enums; +using Intersect.Framework.Core.Serialization; using Intersect.GameObjects.Events; using Intersect.Models; @@ -13,8 +14,9 @@ public partial class MapBase : DatabaseObject { [NotMapped] [JsonIgnore] - protected JsonSerializerSettings mJsonSerializerSettings { get; } = new JsonSerializerSettings() + protected JsonSerializerSettings mJsonSerializerSettings { get; } = new() { + SerializationBinder = new IntersectTypeSerializationBinder(), TypeNameHandling = TypeNameHandling.Auto, DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate, ObjectCreationHandling = ObjectCreationHandling.Replace @@ -238,6 +240,7 @@ public string LocalEventsJson LocalEvents, new JsonSerializerSettings() { + SerializationBinder = new IntersectTypeSerializationBinder(), TypeNameHandling = TypeNameHandling.Auto, DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate, ObjectCreationHandling = ObjectCreationHandling.Replace @@ -247,6 +250,7 @@ public string LocalEventsJson value, LocalEvents, new JsonSerializerSettings { + SerializationBinder = new IntersectTypeSerializationBinder(), TypeNameHandling = TypeNameHandling.Auto, DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate, ObjectCreationHandling = ObjectCreationHandling.Replace diff --git a/Intersect (Core)/Enums/MapInstanceType.cs b/Framework/Intersect.Framework.Core/GameObjects/Maps/MapInstanceType.cs similarity index 100% rename from Intersect (Core)/Enums/MapInstanceType.cs rename to Framework/Intersect.Framework.Core/GameObjects/Maps/MapInstanceType.cs diff --git a/Intersect (Core)/GameObjects/Maps/MapList/MapList.cs b/Framework/Intersect.Framework.Core/GameObjects/Maps/MapList/MapList.cs similarity index 97% rename from Intersect (Core)/GameObjects/Maps/MapList/MapList.cs rename to Framework/Intersect.Framework.Core/GameObjects/Maps/MapList/MapList.cs index 72115c133c..06cec31c6a 100644 --- a/Intersect (Core)/GameObjects/Maps/MapList/MapList.cs +++ b/Framework/Intersect.Framework.Core/GameObjects/Maps/MapList/MapList.cs @@ -1,6 +1,6 @@ using System.ComponentModel.DataAnnotations.Schema; using Intersect.Collections; - +using Intersect.Framework.Core.Serialization; using Newtonsoft.Json; namespace Intersect.GameObjects.Maps.MapList; @@ -26,6 +26,7 @@ public string JsonData this, new JsonSerializerSettings() { + SerializationBinder = new IntersectTypeSerializationBinder(), TypeNameHandling = TypeNameHandling.Auto, DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate, ObjectCreationHandling = ObjectCreationHandling.Replace @@ -35,6 +36,7 @@ public string JsonData value, this, new JsonSerializerSettings() { + SerializationBinder = new IntersectTypeSerializationBinder(), TypeNameHandling = TypeNameHandling.Auto, DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate, ObjectCreationHandling = ObjectCreationHandling.Replace diff --git a/Intersect (Core)/GameObjects/Maps/MapList/MapListFolder.cs b/Framework/Intersect.Framework.Core/GameObjects/Maps/MapList/MapListFolder.cs similarity index 100% rename from Intersect (Core)/GameObjects/Maps/MapList/MapListFolder.cs rename to Framework/Intersect.Framework.Core/GameObjects/Maps/MapList/MapListFolder.cs diff --git a/Intersect (Core)/GameObjects/Maps/MapList/MapListItem.cs b/Framework/Intersect.Framework.Core/GameObjects/Maps/MapList/MapListItem.cs similarity index 100% rename from Intersect (Core)/GameObjects/Maps/MapList/MapListItem.cs rename to Framework/Intersect.Framework.Core/GameObjects/Maps/MapList/MapListItem.cs diff --git a/Intersect (Core)/GameObjects/Maps/MapList/MapListMap.cs b/Framework/Intersect.Framework.Core/GameObjects/Maps/MapList/MapListMap.cs similarity index 100% rename from Intersect (Core)/GameObjects/Maps/MapList/MapListMap.cs rename to Framework/Intersect.Framework.Core/GameObjects/Maps/MapList/MapListMap.cs diff --git a/Intersect (Core)/GameObjects/Maps/MapNpcSpawn.cs b/Framework/Intersect.Framework.Core/GameObjects/Maps/MapNpcSpawn.cs similarity index 100% rename from Intersect (Core)/GameObjects/Maps/MapNpcSpawn.cs rename to Framework/Intersect.Framework.Core/GameObjects/Maps/MapNpcSpawn.cs diff --git a/Intersect (Core)/GameObjects/Maps/MapResourceSpawn.cs b/Framework/Intersect.Framework.Core/GameObjects/Maps/MapResourceSpawn.cs similarity index 100% rename from Intersect (Core)/GameObjects/Maps/MapResourceSpawn.cs rename to Framework/Intersect.Framework.Core/GameObjects/Maps/MapResourceSpawn.cs diff --git a/Intersect (Core)/GameObjects/Maps/MapTile.cs b/Framework/Intersect.Framework.Core/GameObjects/Maps/MapTile.cs similarity index 100% rename from Intersect (Core)/GameObjects/Maps/MapTile.cs rename to Framework/Intersect.Framework.Core/GameObjects/Maps/MapTile.cs diff --git a/Intersect (Core)/Enums/MapZone.cs b/Framework/Intersect.Framework.Core/GameObjects/Maps/MapZone.cs similarity index 100% rename from Intersect (Core)/Enums/MapZone.cs rename to Framework/Intersect.Framework.Core/GameObjects/Maps/MapZone.cs diff --git a/Intersect (Core)/Enums/NpcSpawnDirection.cs b/Framework/Intersect.Framework.Core/GameObjects/Maps/NpcSpawnDirection.cs similarity index 100% rename from Intersect (Core)/Enums/NpcSpawnDirection.cs rename to Framework/Intersect.Framework.Core/GameObjects/Maps/NpcSpawnDirection.cs diff --git a/Intersect (Core)/Enums/WarpDirection.cs b/Framework/Intersect.Framework.Core/GameObjects/Maps/WarpDirection.cs similarity index 100% rename from Intersect (Core)/Enums/WarpDirection.cs rename to Framework/Intersect.Framework.Core/GameObjects/Maps/WarpDirection.cs diff --git a/Intersect (Core)/GameObjects/NpcBase.cs b/Framework/Intersect.Framework.Core/GameObjects/NpcBase.cs similarity index 100% rename from Intersect (Core)/GameObjects/NpcBase.cs rename to Framework/Intersect.Framework.Core/GameObjects/NpcBase.cs diff --git a/Intersect (Core)/GameObjects/ProjectileBase.cs b/Framework/Intersect.Framework.Core/GameObjects/ProjectileBase.cs similarity index 100% rename from Intersect (Core)/GameObjects/ProjectileBase.cs rename to Framework/Intersect.Framework.Core/GameObjects/ProjectileBase.cs diff --git a/Intersect (Core)/Enums/GrappleOption.cs b/Framework/Intersect.Framework.Core/GameObjects/Projectiles/GrappleOption.cs similarity index 100% rename from Intersect (Core)/Enums/GrappleOption.cs rename to Framework/Intersect.Framework.Core/GameObjects/Projectiles/GrappleOption.cs diff --git a/Intersect (Core)/GameObjects/QuestBase.cs b/Framework/Intersect.Framework.Core/GameObjects/QuestBase.cs similarity index 97% rename from Intersect (Core)/GameObjects/QuestBase.cs rename to Framework/Intersect.Framework.Core/GameObjects/QuestBase.cs index dfc6f0e0df..7d067b61b9 100644 --- a/Intersect (Core)/GameObjects/QuestBase.cs +++ b/Framework/Intersect.Framework.Core/GameObjects/QuestBase.cs @@ -1,6 +1,7 @@ using System.ComponentModel.DataAnnotations.Schema; using Intersect.Enums; +using Intersect.Framework.Core.Serialization; using Intersect.GameObjects.Conditions; using Intersect.GameObjects.Events; using Intersect.Localization; @@ -127,6 +128,7 @@ public string LocalEventsJson AddEvents, Formatting.Indented, new JsonSerializerSettings() { + SerializationBinder = new IntersectTypeSerializationBinder(), TypeNameHandling = TypeNameHandling.Auto, DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate, ObjectCreationHandling = ObjectCreationHandling.Replace @@ -136,6 +138,7 @@ public string LocalEventsJson value, AddEvents, new JsonSerializerSettings() { + SerializationBinder = new IntersectTypeSerializationBinder(), TypeNameHandling = TypeNameHandling.Auto, DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate, ObjectCreationHandling = ObjectCreationHandling.Replace diff --git a/Intersect (Core)/Enums/QuestObjective.cs b/Framework/Intersect.Framework.Core/GameObjects/Quests/QuestObjective.cs similarity index 100% rename from Intersect (Core)/Enums/QuestObjective.cs rename to Framework/Intersect.Framework.Core/GameObjects/Quests/QuestObjective.cs diff --git a/Intersect (Core)/GameObjects/Ranges/ItemRange.cs b/Framework/Intersect.Framework.Core/GameObjects/Ranges/ItemRange.cs similarity index 100% rename from Intersect (Core)/GameObjects/Ranges/ItemRange.cs rename to Framework/Intersect.Framework.Core/GameObjects/Ranges/ItemRange.cs diff --git a/Intersect (Core)/GameObjects/ResourceBase.cs b/Framework/Intersect.Framework.Core/GameObjects/ResourceBase.cs similarity index 100% rename from Intersect (Core)/GameObjects/ResourceBase.cs rename to Framework/Intersect.Framework.Core/GameObjects/ResourceBase.cs diff --git a/Intersect (Core)/GameObjects/ShopBase.cs b/Framework/Intersect.Framework.Core/GameObjects/ShopBase.cs similarity index 100% rename from Intersect (Core)/GameObjects/ShopBase.cs rename to Framework/Intersect.Framework.Core/GameObjects/ShopBase.cs diff --git a/Intersect (Core)/GameObjects/SpellBase.cs b/Framework/Intersect.Framework.Core/GameObjects/SpellBase.cs similarity index 100% rename from Intersect (Core)/GameObjects/SpellBase.cs rename to Framework/Intersect.Framework.Core/GameObjects/SpellBase.cs diff --git a/Intersect (Core)/Enums/SpellTargetType.cs b/Framework/Intersect.Framework.Core/GameObjects/Spells/SpellTargetType.cs similarity index 100% rename from Intersect (Core)/Enums/SpellTargetType.cs rename to Framework/Intersect.Framework.Core/GameObjects/Spells/SpellTargetType.cs diff --git a/Intersect (Core)/Enums/SpellType.cs b/Framework/Intersect.Framework.Core/GameObjects/Spells/SpellType.cs similarity index 100% rename from Intersect (Core)/Enums/SpellType.cs rename to Framework/Intersect.Framework.Core/GameObjects/Spells/SpellType.cs diff --git a/Intersect (Core)/GameObjects/Switches and Variables/IVariableBase.cs b/Framework/Intersect.Framework.Core/GameObjects/Switches and Variables/IVariableBase.cs similarity index 100% rename from Intersect (Core)/GameObjects/Switches and Variables/IVariableBase.cs rename to Framework/Intersect.Framework.Core/GameObjects/Switches and Variables/IVariableBase.cs diff --git a/Intersect (Core)/GameObjects/Switches and Variables/PlayerVariableBase.cs b/Framework/Intersect.Framework.Core/GameObjects/Switches and Variables/PlayerVariableBase.cs similarity index 100% rename from Intersect (Core)/GameObjects/Switches and Variables/PlayerVariableBase.cs rename to Framework/Intersect.Framework.Core/GameObjects/Switches and Variables/PlayerVariableBase.cs diff --git a/Intersect (Core)/GameObjects/Switches and Variables/ServerVariableBase.cs b/Framework/Intersect.Framework.Core/GameObjects/Switches and Variables/ServerVariableBase.cs similarity index 100% rename from Intersect (Core)/GameObjects/Switches and Variables/ServerVariableBase.cs rename to Framework/Intersect.Framework.Core/GameObjects/Switches and Variables/ServerVariableBase.cs diff --git a/Intersect (Core)/GameObjects/Switches and Variables/VariableValue.cs b/Framework/Intersect.Framework.Core/GameObjects/Switches and Variables/VariableValue.cs similarity index 96% rename from Intersect (Core)/GameObjects/Switches and Variables/VariableValue.cs rename to Framework/Intersect.Framework.Core/GameObjects/Switches and Variables/VariableValue.cs index 58fda9e7ce..04133af2b5 100644 --- a/Intersect (Core)/GameObjects/Switches and Variables/VariableValue.cs +++ b/Framework/Intersect.Framework.Core/GameObjects/Switches and Variables/VariableValue.cs @@ -124,7 +124,7 @@ public static bool TryParse(string value, out JObject jObject) return true; } - Log.Warn(new ArgumentNullException(nameof(jObject), @"Invalid variable value stored in the database.")); + LegacyLogging.Logger?.Warn(new ArgumentNullException(nameof(jObject), @"Invalid variable value stored in the database.")); } catch (Exception exception) { @@ -132,7 +132,7 @@ public static bool TryParse(string value, out JObject jObject) #if DEBUG /* Only log in DEBUG in case the variable contains * sensitive information. */ - Log.Warn(exception); + LegacyLogging.Logger?.Warn(exception); #endif } diff --git a/Intersect (Core)/GameObjects/TilesetBase.cs b/Framework/Intersect.Framework.Core/GameObjects/TilesetBase.cs similarity index 100% rename from Intersect (Core)/GameObjects/TilesetBase.cs rename to Framework/Intersect.Framework.Core/GameObjects/TilesetBase.cs diff --git a/Intersect (Core)/GameObjects/TimeBase.cs b/Framework/Intersect.Framework.Core/GameObjects/TimeBase.cs similarity index 100% rename from Intersect (Core)/GameObjects/TimeBase.cs rename to Framework/Intersect.Framework.Core/GameObjects/TimeBase.cs diff --git a/Intersect (Core)/GameObjects/UserVariableBase.cs b/Framework/Intersect.Framework.Core/GameObjects/UserVariableBase.cs similarity index 100% rename from Intersect (Core)/GameObjects/UserVariableBase.cs rename to Framework/Intersect.Framework.Core/GameObjects/UserVariableBase.cs diff --git a/Intersect (Core)/GameObjects/VariableDescriptor.cs b/Framework/Intersect.Framework.Core/GameObjects/VariableDescriptor.cs similarity index 100% rename from Intersect (Core)/GameObjects/VariableDescriptor.cs rename to Framework/Intersect.Framework.Core/GameObjects/VariableDescriptor.cs diff --git a/Intersect (Core)/IO/Files/FileSystemHelper.cs b/Framework/Intersect.Framework.Core/IO/Files/FileSystemHelper.cs similarity index 98% rename from Intersect (Core)/IO/Files/FileSystemHelper.cs rename to Framework/Intersect.Framework.Core/IO/Files/FileSystemHelper.cs index 1eb26a50c3..cf8264677f 100644 --- a/Intersect (Core)/IO/Files/FileSystemHelper.cs +++ b/Framework/Intersect.Framework.Core/IO/Files/FileSystemHelper.cs @@ -54,7 +54,7 @@ public static bool EnsureDirectoryExists(string directoryPath) } catch (Exception exception) { - Log.Error(exception); + LegacyLogging.Logger?.Error(exception); return false; } @@ -154,7 +154,7 @@ public static string WriteToTemporaryFolder(string name, Stream stream) temporaryFileStream.Write(buffer, 0, read); } } - + return temporaryFilePath; } } diff --git a/Framework/Intersect.Framework.Core/Intersect.Framework.Core.csproj b/Framework/Intersect.Framework.Core/Intersect.Framework.Core.csproj new file mode 100644 index 0000000000..f0c0511e7f --- /dev/null +++ b/Framework/Intersect.Framework.Core/Intersect.Framework.Core.csproj @@ -0,0 +1,27 @@ + + + + warnings + + + + + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + + diff --git a/Intersect (Core)/Localization/BooleanStyle.cs b/Framework/Intersect.Framework.Core/Localization/BooleanStyle.cs similarity index 100% rename from Intersect (Core)/Localization/BooleanStyle.cs rename to Framework/Intersect.Framework.Core/Localization/BooleanStyle.cs diff --git a/Intersect (Core)/Localization/LocaleDictionary.cs b/Framework/Intersect.Framework.Core/Localization/LocaleDictionary.cs similarity index 100% rename from Intersect (Core)/Localization/LocaleDictionary.cs rename to Framework/Intersect.Framework.Core/Localization/LocaleDictionary.cs diff --git a/Intersect (Core)/Localization/Localized.cs b/Framework/Intersect.Framework.Core/Localization/Localized.cs similarity index 100% rename from Intersect (Core)/Localization/Localized.cs rename to Framework/Intersect.Framework.Core/Localization/Localized.cs diff --git a/Intersect (Core)/Localization/LocalizedString.cs b/Framework/Intersect.Framework.Core/Localization/LocalizedString.cs similarity index 57% rename from Intersect (Core)/Localization/LocalizedString.cs rename to Framework/Intersect.Framework.Core/Localization/LocalizedString.cs index 9ca965271e..cce3f05c5a 100644 --- a/Intersect (Core)/Localization/LocalizedString.cs +++ b/Framework/Intersect.Framework.Core/Localization/LocalizedString.cs @@ -1,28 +1,4 @@ -using Newtonsoft.Json; - -namespace Intersect.Localization; - - -public partial class LocalizedStringConverter : JsonConverter -{ - - public override void WriteJson(JsonWriter writer, LocalizedString value, JsonSerializer serializer) - { - writer.WriteValue(value?.ToString()); - } - - public override LocalizedString ReadJson( - JsonReader reader, - Type objectType, - LocalizedString existingValue, - bool hasExistingValue, - JsonSerializer serializer - ) - { - return reader.Value as string; - } - -} +namespace Intersect.Localization; [Serializable] public partial class LocalizedString : Localized diff --git a/Framework/Intersect.Framework.Core/Localization/LocalizedStringConverter.cs b/Framework/Intersect.Framework.Core/Localization/LocalizedStringConverter.cs new file mode 100644 index 0000000000..81ec9c0f1c --- /dev/null +++ b/Framework/Intersect.Framework.Core/Localization/LocalizedStringConverter.cs @@ -0,0 +1,24 @@ +using Newtonsoft.Json; + +namespace Intersect.Localization; + +public partial class LocalizedStringConverter : JsonConverter +{ + + public override void WriteJson(JsonWriter writer, LocalizedString value, JsonSerializer serializer) + { + writer.WriteValue(value?.ToString()); + } + + public override LocalizedString ReadJson( + JsonReader reader, + Type objectType, + LocalizedString existingValue, + bool hasExistingValue, + JsonSerializer serializer + ) + { + return reader.Value as string; + } + +} \ No newline at end of file diff --git a/Intersect (Core)/Logging/Formatting/DefaultFormatter.cs b/Framework/Intersect.Framework.Core/Logging/Formatting/DefaultFormatter.cs similarity index 100% rename from Intersect (Core)/Logging/Formatting/DefaultFormatter.cs rename to Framework/Intersect.Framework.Core/Logging/Formatting/DefaultFormatter.cs diff --git a/Intersect (Core)/Logging/Formatting/ILogFormatter.cs b/Framework/Intersect.Framework.Core/Logging/Formatting/ILogFormatter.cs similarity index 100% rename from Intersect (Core)/Logging/Formatting/ILogFormatter.cs rename to Framework/Intersect.Framework.Core/Logging/Formatting/ILogFormatter.cs diff --git a/Intersect (Core)/Logging/ILogger.cs b/Framework/Intersect.Framework.Core/Logging/ILogger.cs similarity index 100% rename from Intersect (Core)/Logging/ILogger.cs rename to Framework/Intersect.Framework.Core/Logging/ILogger.cs diff --git a/Framework/Intersect.Framework.Core/Logging/LegacyLogging.cs b/Framework/Intersect.Framework.Core/Logging/LegacyLogging.cs new file mode 100644 index 0000000000..8aa4fcd634 --- /dev/null +++ b/Framework/Intersect.Framework.Core/Logging/LegacyLogging.cs @@ -0,0 +1,6 @@ +namespace Intersect.Logging; + +public static class LegacyLogging +{ + public static ILogger? Logger { get; set; } +} \ No newline at end of file diff --git a/Intersect (Core)/Logging/LogConfiguration.cs b/Framework/Intersect.Framework.Core/Logging/LogConfiguration.cs similarity index 63% rename from Intersect (Core)/Logging/LogConfiguration.cs rename to Framework/Intersect.Framework.Core/Logging/LogConfiguration.cs index 5498c2a8b2..5b0640f1f8 100644 --- a/Intersect (Core)/Logging/LogConfiguration.cs +++ b/Framework/Intersect.Framework.Core/Logging/LogConfiguration.cs @@ -1,14 +1,14 @@ using System.Collections.Immutable; using System.Diagnostics; -using Intersect.Immutability; using Intersect.Logging.Formatting; using Intersect.Logging.Output; +using Microsoft.Extensions.Logging; namespace Intersect.Logging; /// -/// Configuration class for . +/// Configuration class for . /// public sealed partial class LogConfiguration { @@ -20,14 +20,8 @@ public sealed partial class LogConfiguration private static readonly ImmutableList DefaultOutputs = ImmutableList.Create() ?? throw new InvalidOperationException(); - private Immutable> mFormatters; - private LogLevel mLogLevel; - private Immutable> mOutputs; - - private Immutable mTag; - public static LogConfiguration Default => new LogConfiguration { Formatters = DefaultFormatters, @@ -41,13 +35,9 @@ public sealed partial class LogConfiguration Tag = null }; - public ILogFormatter Formatter => mFormatters.Value?[0] ?? DefaultFormatter; + public ILogFormatter Formatter => Formatters.FirstOrDefault() ?? DefaultFormatter; - public IReadOnlyList Formatters - { - get => mFormatters.Value ?? DefaultFormatters; - set => mFormatters.Value = value; - } + public IReadOnlyList? Formatters { get; init; } public LogLevel LogLevel { @@ -55,17 +45,9 @@ public LogLevel LogLevel set => mLogLevel = value; } - public IReadOnlyList Outputs - { - get => mOutputs.Value ?? DefaultOutputs; - set => mOutputs.Value = value; - } + public IReadOnlyList Outputs { get; init; } - public string Tag - { - get => mTag; - set => mTag.Value = value; - } + public string Tag { get; init; } internal LogConfiguration Clone() => MemberwiseClone() as LogConfiguration ?? throw new InvalidOperationException(); diff --git a/Intersect (Core)/Logging/LogLevel.cs b/Framework/Intersect.Framework.Core/Logging/LogLevel.cs similarity index 100% rename from Intersect (Core)/Logging/LogLevel.cs rename to Framework/Intersect.Framework.Core/Logging/LogLevel.cs diff --git a/Intersect (Core)/Logging/Output/ILogOutput.cs b/Framework/Intersect.Framework.Core/Logging/Output/ILogOutput.cs similarity index 100% rename from Intersect (Core)/Logging/Output/ILogOutput.cs rename to Framework/Intersect.Framework.Core/Logging/Output/ILogOutput.cs diff --git a/Intersect (Core)/Utilities/MathHelper.cs b/Framework/Intersect.Framework.Core/MathHelper.cs similarity index 100% rename from Intersect (Core)/Utilities/MathHelper.cs rename to Framework/Intersect.Framework.Core/MathHelper.cs diff --git a/Intersect (Core)/Utilities/DatabaseUtils.cs b/Framework/Intersect.Framework.Core/Memory/DatabaseUtils.cs similarity index 100% rename from Intersect (Core)/Utilities/DatabaseUtils.cs rename to Framework/Intersect.Framework.Core/Memory/DatabaseUtils.cs diff --git a/Intersect (Core)/Memory/IBuffer.cs b/Framework/Intersect.Framework.Core/Memory/IBuffer.cs similarity index 100% rename from Intersect (Core)/Memory/IBuffer.cs rename to Framework/Intersect.Framework.Core/Memory/IBuffer.cs diff --git a/Intersect (Core)/Utilities/StreamUtils.cs b/Framework/Intersect.Framework.Core/Memory/StreamExtensions.cs similarity index 81% rename from Intersect (Core)/Utilities/StreamUtils.cs rename to Framework/Intersect.Framework.Core/Memory/StreamExtensions.cs index dd18aa5ddd..7d3e883c2a 100644 --- a/Intersect (Core)/Utilities/StreamUtils.cs +++ b/Framework/Intersect.Framework.Core/Memory/StreamExtensions.cs @@ -1,10 +1,10 @@ namespace Intersect.Utilities; -public static partial class StreamUtils +public static partial class StreamExtensions { - public static void Pipe(Stream input, Stream output) + public static void Pipe(this Stream input, Stream output) { if (input == null) { diff --git a/Intersect (Core)/Models/DatabaseObject.cs b/Framework/Intersect.Framework.Core/Models/DatabaseObject.cs similarity index 97% rename from Intersect (Core)/Models/DatabaseObject.cs rename to Framework/Intersect.Framework.Core/Models/DatabaseObject.cs index b4eb16e5d7..ab76f1b3fe 100644 --- a/Intersect (Core)/Models/DatabaseObject.cs +++ b/Framework/Intersect.Framework.Core/Models/DatabaseObject.cs @@ -2,7 +2,7 @@ using System.Runtime.CompilerServices; using Intersect.Collections; using Intersect.Enums; - +using Intersect.Framework.Core.Serialization; using Newtonsoft.Json; namespace Intersect.Models; @@ -63,6 +63,7 @@ public virtual void Load(string json, bool keepCreationTime = false) JsonConvert.PopulateObject( json, this, new JsonSerializerSettings { + SerializationBinder = new IntersectTypeSerializationBinder(), ObjectCreationHandling = ObjectCreationHandling.Replace } ); diff --git a/Intersect (Core)/Extensions/GameObjectInfoAttribute.cs b/Framework/Intersect.Framework.Core/Models/GameObjectInfoAttribute.cs similarity index 100% rename from Intersect (Core)/Extensions/GameObjectInfoAttribute.cs rename to Framework/Intersect.Framework.Core/Models/GameObjectInfoAttribute.cs diff --git a/Intersect (Core)/Models/IDatabaseObject.cs b/Framework/Intersect.Framework.Core/Models/IDatabaseObject.cs similarity index 60% rename from Intersect (Core)/Models/IDatabaseObject.cs rename to Framework/Intersect.Framework.Core/Models/IDatabaseObject.cs index d6b0de65d8..ab8fffe90e 100644 --- a/Intersect (Core)/Models/IDatabaseObject.cs +++ b/Framework/Intersect.Framework.Core/Models/IDatabaseObject.cs @@ -6,24 +6,23 @@ namespace Intersect.Models; public interface IDatabaseObject : INamedObject { + public GameObjectType Type { get; } - GameObjectType Type { get; } + public string DatabaseTable { get; } - string DatabaseTable { get; } + public long TimeCreated { get; set; } - long TimeCreated { get; set; } + public string JsonData { get; } - string JsonData { get; } + public void Load(string json, bool keepCreationTime = false); - void Load(string json, bool keepCreationTime = false); + public void MakeBackup(); - void MakeBackup(); + public void RestoreBackup(); - void RestoreBackup(); + public void DeleteBackup(); - void DeleteBackup(); - - void Delete(); + public void Delete(); } diff --git a/Intersect (Core)/Models/IFolderable.cs b/Framework/Intersect.Framework.Core/Models/IFolderable.cs similarity index 82% rename from Intersect (Core)/Models/IFolderable.cs rename to Framework/Intersect.Framework.Core/Models/IFolderable.cs index ca1f2a392b..473edd04e2 100644 --- a/Intersect (Core)/Models/IFolderable.cs +++ b/Framework/Intersect.Framework.Core/Models/IFolderable.cs @@ -7,6 +7,6 @@ public interface IFolderable /// /// Used to group editor items together into folders with the same name /// - string Folder { get; set; } + public string Folder { get; set; } } diff --git a/Intersect (Core)/Models/INamedObject.cs b/Framework/Intersect.Framework.Core/Models/INamedObject.cs similarity index 67% rename from Intersect (Core)/Models/INamedObject.cs rename to Framework/Intersect.Framework.Core/Models/INamedObject.cs index 0a5efa0229..715dfc7534 100644 --- a/Intersect (Core)/Models/INamedObject.cs +++ b/Framework/Intersect.Framework.Core/Models/INamedObject.cs @@ -3,7 +3,6 @@ public interface INamedObject : IObject { - - string Name { get; set; } + public string Name { get; set; } } diff --git a/Intersect (Core)/Models/IObject.cs b/Framework/Intersect.Framework.Core/Models/IObject.cs similarity index 69% rename from Intersect (Core)/Models/IObject.cs rename to Framework/Intersect.Framework.Core/Models/IObject.cs index 5f4a1d5ba4..04b771db87 100644 --- a/Intersect (Core)/Models/IObject.cs +++ b/Framework/Intersect.Framework.Core/Models/IObject.cs @@ -3,7 +3,6 @@ public interface IObject { - - Guid Id { get; } + public Guid Id { get; } } diff --git a/Intersect (Core)/Models/ObjectCacheData.cs b/Framework/Intersect.Framework.Core/Models/ObjectCacheData.cs similarity index 100% rename from Intersect (Core)/Models/ObjectCacheData.cs rename to Framework/Intersect.Framework.Core/Models/ObjectCacheData.cs diff --git a/Intersect (Core)/Models/ObjectCacheKey.cs b/Framework/Intersect.Framework.Core/Models/ObjectCacheKey.cs similarity index 100% rename from Intersect (Core)/Models/ObjectCacheKey.cs rename to Framework/Intersect.Framework.Core/Models/ObjectCacheKey.cs diff --git a/Intersect (Core)/Models/ObjectDataDiskCache.cs b/Framework/Intersect.Framework.Core/Models/ObjectDataDiskCache.cs similarity index 95% rename from Intersect (Core)/Models/ObjectDataDiskCache.cs rename to Framework/Intersect.Framework.Core/Models/ObjectDataDiskCache.cs index 6919cdb8a5..b149866df9 100644 --- a/Intersect (Core)/Models/ObjectDataDiskCache.cs +++ b/Framework/Intersect.Framework.Core/Models/ObjectDataDiskCache.cs @@ -11,15 +11,12 @@ namespace Intersect.Models; public static class ObjectDataDiskCache -{ - private static string InstanceName = $"{ClientConfiguration.Instance.Host}.{ClientConfiguration.Instance.Port}"; - - private static string RootCacheDirectory => Path.Combine( +{ private static string RootCacheDirectory => Path.Combine( Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), ".intersect", (Assembly.GetEntryAssembly() ?? Assembly.GetExecutingAssembly()).GetName().Name ?? throw new InvalidOperationException(), - InstanceName + ConfigurationHelper.CacheName ); private static SymmetricAlgorithm CreateCryptoServiceProvider(string identifier, out string nonce) @@ -31,7 +28,7 @@ private static SymmetricAlgorithm CreateCryptoServiceProvider(string identifier, private static SymmetricAlgorithm CreateCryptoServiceProvider(string identifier, string nonce) { - var instanceNameData = Encoding.UTF8.GetBytes(InstanceName); + var instanceNameData = Encoding.UTF8.GetBytes(ConfigurationHelper.CacheName); var identifierData = Encoding.UTF8.GetBytes(identifier); #if DIAGNOSTIC var start = Stopwatch.GetTimestamp(); @@ -130,7 +127,7 @@ public static bool TryLoad(Guid id, [NotNullWhen(true)] out ObjectCacheData objectCacheData) } catch (Exception exception) { - Log.Error(exception); + LegacyLogging.Logger?.Error(exception); return false; } } diff --git a/Intersect (Core)/Enums/VariableDataType.cs b/Framework/Intersect.Framework.Core/Models/VariableDataType.cs similarity index 100% rename from Intersect (Core)/Enums/VariableDataType.cs rename to Framework/Intersect.Framework.Core/Models/VariableDataType.cs diff --git a/Intersect (Core)/Network/IPacketHandler.cs b/Framework/Intersect.Framework.Core/Network/AbstractPacketHandler.cs similarity index 55% rename from Intersect (Core)/Network/IPacketHandler.cs rename to Framework/Intersect.Framework.Core/Network/AbstractPacketHandler.cs index 37ba5c5ca1..2713f974df 100644 --- a/Intersect (Core)/Network/IPacketHandler.cs +++ b/Framework/Intersect.Framework.Core/Network/AbstractPacketHandler.cs @@ -1,15 +1,4 @@ -namespace Intersect.Network; - -public interface IPacketHandler -{ - bool Handle(IPacketSender packetSender, IPacket packet); -} - -public interface IPacketHandler : IPacketHandler where TPacket : class, IPacket -{ - - bool Handle(IPacketSender packetSender, TPacket packet); -} +namespace Intersect.Network; public abstract class AbstractPacketHandler : IPacketHandler where TPacket : class, IPacket { @@ -19,4 +8,4 @@ public virtual bool Handle(IPacketSender packetSender, IPacket packet) { return packet is TPacket typedPacket && Handle(packetSender, typedPacket); } -} +} \ No newline at end of file diff --git a/Intersect (Core)/Network/Ceras.cs b/Framework/Intersect.Framework.Core/Network/Ceras.cs similarity index 59% rename from Intersect (Core)/Network/Ceras.cs rename to Framework/Intersect.Framework.Core/Network/Ceras.cs index ef5fbfef57..643e44b254 100644 --- a/Intersect (Core)/Network/Ceras.cs +++ b/Framework/Intersect.Framework.Core/Network/Ceras.cs @@ -5,20 +5,6 @@ namespace Intersect.Network; - -public sealed partial class CerasDefaultBufferPool : ICerasBufferPool -{ - public byte[] RentBuffer(int minimumSize) - { - return System.Buffers.ArrayPool.Shared.Rent(minimumSize); - } - - public void Return(byte[] buffer) - { - System.Buffers.ArrayPool.Shared.Return(buffer, false); - } -} - public partial class Ceras { private static readonly string[] BuiltInPacketNamespaces = new[] @@ -111,13 +97,13 @@ public object Deserialize(byte[] data) } catch (Exception exception) { - Log.Error(exception); + LegacyLogging.Logger?.Error(exception); return null; } } - public T Deserialize(byte[] data) + public T? Deserialize(byte[] data) { try { @@ -128,9 +114,9 @@ public T Deserialize(byte[] data) } catch (Exception exception) { - Log.Error(exception); + LegacyLogging.Logger?.Error(exception); - return default(T); + return default; } } @@ -144,73 +130,9 @@ public object Decompress(byte[] data) return Deserialize(LZ4Pickler.Unpickle(data)); } - public T Decompress(byte[] data) + public T? Decompress(byte[] data) { return Deserialize(LZ4Pickler.Unpickle(data)); } -} - -public partial class LegacyCeras : Ceras -{ - /// - /// Creates a Ceras instance with legacy config (no version tolerance) in order for the server to use for database upgrades to the new serialized formats. - /// - public LegacyCeras() - { - mSerializerConfig = CreateLegacyConfig(); - mSerializer = new CerasSerializer(mSerializerConfig); - } - - /// - /// Creates a Ceras instant wtih legacy config (no version tolerance) in order for the server to use for database upgrades to new serialized formats. - /// The dictionary parameters allow us to override what classes Ceras initializes by mapping old types to new ones. - /// - public LegacyCeras(Dictionary nameTypeMap) - { - mSerializerConfig = CreateLegacyConfig(); - - var typeBinder = new CerasTypeBinder(nameTypeMap); - mSerializerConfig.Advanced.TypeBinder = typeBinder; - - mSerializer = new CerasSerializer(mSerializerConfig); - } - - private SerializerConfig CreateLegacyConfig() - { - var config = new SerializerConfig - { - PreserveReferences = false - }; - - config.Advanced.SealTypesWhenUsingKnownTypes = false; - config.VersionTolerance.Mode = VersionToleranceMode.Disabled; - - return config; - } -} - -partial class CerasTypeBinder : ITypeBinder -{ - Dictionary _nameToType = new Dictionary(); - - public CerasTypeBinder(Dictionary nameTypeMap) - { - _nameToType = nameTypeMap; - } - - public string GetBaseName(Type type) - { - return _nameToType.Keys.FirstOrDefault(k => _nameToType[k] == type); - } - - public Type GetTypeFromBase(string baseTypeName) - { - return _nameToType[baseTypeName]; - } - - public Type GetTypeFromBaseAndArguments(string baseTypeName, params Type[] genericTypeArguments) - { - throw new NotSupportedException("this binder is only for debugging"); - } -} +} \ No newline at end of file diff --git a/Framework/Intersect.Framework.Core/Network/CerasTypeBinder.cs b/Framework/Intersect.Framework.Core/Network/CerasTypeBinder.cs new file mode 100644 index 0000000000..9d55c8d78f --- /dev/null +++ b/Framework/Intersect.Framework.Core/Network/CerasTypeBinder.cs @@ -0,0 +1,28 @@ +using Ceras; + +namespace Intersect.Network; + +partial class CerasTypeBinder : ITypeBinder +{ + Dictionary _nameToType = new Dictionary(); + + public CerasTypeBinder(Dictionary nameTypeMap) + { + _nameToType = nameTypeMap; + } + + public string GetBaseName(Type type) + { + return _nameToType.Keys.FirstOrDefault(k => _nameToType[k] == type); + } + + public Type GetTypeFromBase(string baseTypeName) + { + return _nameToType[baseTypeName]; + } + + public Type GetTypeFromBaseAndArguments(string baseTypeName, params Type[] genericTypeArguments) + { + throw new NotSupportedException("this binder is only for debugging"); + } +} \ No newline at end of file diff --git a/Intersect (Core)/Network/ConnectionStatistics.cs b/Framework/Intersect.Framework.Core/Network/ConnectionStatistics.cs similarity index 100% rename from Intersect (Core)/Network/ConnectionStatistics.cs rename to Framework/Intersect.Framework.Core/Network/ConnectionStatistics.cs diff --git a/Framework/Intersect.Framework.Core/Network/Delegates.cs b/Framework/Intersect.Framework.Core/Network/Delegates.cs new file mode 100644 index 0000000000..ab225fd943 --- /dev/null +++ b/Framework/Intersect.Framework.Core/Network/Delegates.cs @@ -0,0 +1,3 @@ +namespace Intersect.Network; + +public delegate bool HandlePacket(IConnection connection, IPacket packet); \ No newline at end of file diff --git a/Intersect (Core)/Network/Events/ConnectionEventArgs.cs b/Framework/Intersect.Framework.Core/Network/Events/ConnectionEventArgs.cs similarity index 100% rename from Intersect (Core)/Network/Events/ConnectionEventArgs.cs rename to Framework/Intersect.Framework.Core/Network/Events/ConnectionEventArgs.cs diff --git a/Intersect (Core)/Network/GenericPacketTypeArgumentsAttribute.cs b/Framework/Intersect.Framework.Core/Network/GenericPacketTypeArgumentsAttribute.cs similarity index 100% rename from Intersect (Core)/Network/GenericPacketTypeArgumentsAttribute.cs rename to Framework/Intersect.Framework.Core/Network/GenericPacketTypeArgumentsAttribute.cs diff --git a/Intersect (Core)/Network/HandleConnectionEvent.cs b/Framework/Intersect.Framework.Core/Network/HandleConnectionEvent.cs similarity index 100% rename from Intersect (Core)/Network/HandleConnectionEvent.cs rename to Framework/Intersect.Framework.Core/Network/HandleConnectionEvent.cs diff --git a/Intersect (Core)/Network/HandleConnectionRequest.cs b/Framework/Intersect.Framework.Core/Network/HandleConnectionRequest.cs similarity index 100% rename from Intersect (Core)/Network/HandleConnectionRequest.cs rename to Framework/Intersect.Framework.Core/Network/HandleConnectionRequest.cs diff --git a/Framework/Intersect.Framework.Core/Network/HandlePacket.cs b/Framework/Intersect.Framework.Core/Network/HandlePacket.cs new file mode 100644 index 0000000000..69fed34790 --- /dev/null +++ b/Framework/Intersect.Framework.Core/Network/HandlePacket.cs @@ -0,0 +1,4 @@ +namespace Intersect.Network; + +public delegate bool HandlePacket(TPacketSender packetSender, TPacket packet) + where TPacketSender : IPacketSender where TPacket : IPacket; \ No newline at end of file diff --git a/Intersect (Core)/Network/HandlePacketAvailable.cs b/Framework/Intersect.Framework.Core/Network/HandlePacketAvailable.cs similarity index 100% rename from Intersect (Core)/Network/HandlePacketAvailable.cs rename to Framework/Intersect.Framework.Core/Network/HandlePacketAvailable.cs diff --git a/Framework/Intersect.Framework.Core/Network/HandlePacketGeneric.cs b/Framework/Intersect.Framework.Core/Network/HandlePacketGeneric.cs new file mode 100644 index 0000000000..83a2ebb01d --- /dev/null +++ b/Framework/Intersect.Framework.Core/Network/HandlePacketGeneric.cs @@ -0,0 +1,3 @@ +namespace Intersect.Network; + +public delegate bool HandlePacketGeneric(IPacketSender packetSender, IPacket packet); \ No newline at end of file diff --git a/Framework/Intersect.Framework.Core/Network/HandlePacketVoid.cs b/Framework/Intersect.Framework.Core/Network/HandlePacketVoid.cs new file mode 100644 index 0000000000..0a90d82205 --- /dev/null +++ b/Framework/Intersect.Framework.Core/Network/HandlePacketVoid.cs @@ -0,0 +1,4 @@ +namespace Intersect.Network; + +public delegate void HandlePacketVoid(TPacketSender packetSender, TPacket packet) + where TPacketSender : IPacketSender where TPacket : IPacket; \ No newline at end of file diff --git a/Intersect (Core)/Network/HandleUnconnectedMessage.cs b/Framework/Intersect.Framework.Core/Network/HandleUnconnectedMessage.cs similarity index 100% rename from Intersect (Core)/Network/HandleUnconnectedMessage.cs rename to Framework/Intersect.Framework.Core/Network/HandleUnconnectedMessage.cs diff --git a/Intersect (Core)/Network/IConnection.cs b/Framework/Intersect.Framework.Core/Network/IConnection.cs similarity index 100% rename from Intersect (Core)/Network/IConnection.cs rename to Framework/Intersect.Framework.Core/Network/IConnection.cs diff --git a/Intersect (Core)/Network/INetwork.cs b/Framework/Intersect.Framework.Core/Network/INetwork.cs similarity index 100% rename from Intersect (Core)/Network/INetwork.cs rename to Framework/Intersect.Framework.Core/Network/INetwork.cs diff --git a/Intersect (Core)/Network/INetworkLayerInterface.cs b/Framework/Intersect.Framework.Core/Network/INetworkLayerInterface.cs similarity index 100% rename from Intersect (Core)/Network/INetworkLayerInterface.cs rename to Framework/Intersect.Framework.Core/Network/INetworkLayerInterface.cs diff --git a/Intersect (Core)/Network/IPacket.cs b/Framework/Intersect.Framework.Core/Network/IPacket.cs similarity index 100% rename from Intersect (Core)/Network/IPacket.cs rename to Framework/Intersect.Framework.Core/Network/IPacket.cs diff --git a/Framework/Intersect.Framework.Core/Network/IPacketHandler.cs b/Framework/Intersect.Framework.Core/Network/IPacketHandler.cs new file mode 100644 index 0000000000..aeb1b5a2cb --- /dev/null +++ b/Framework/Intersect.Framework.Core/Network/IPacketHandler.cs @@ -0,0 +1,12 @@ +namespace Intersect.Network; + +public interface IPacketHandler +{ + bool Handle(IPacketSender packetSender, IPacket packet); +} + +public interface IPacketHandler : IPacketHandler where TPacket : class, IPacket +{ + + bool Handle(IPacketSender packetSender, TPacket packet); +} \ No newline at end of file diff --git a/Intersect (Core)/Network/IPacketSender.cs b/Framework/Intersect.Framework.Core/Network/IPacketSender.cs similarity index 100% rename from Intersect (Core)/Network/IPacketSender.cs rename to Framework/Intersect.Framework.Core/Network/IPacketSender.cs diff --git a/Intersect (Core)/Network/IntersectPacket.cs b/Framework/Intersect.Framework.Core/Network/IntersectPacket.cs similarity index 97% rename from Intersect (Core)/Network/IntersectPacket.cs rename to Framework/Intersect.Framework.Core/Network/IntersectPacket.cs index 9f358f3476..2fa0300d98 100644 --- a/Intersect (Core)/Network/IntersectPacket.cs +++ b/Framework/Intersect.Framework.Core/Network/IntersectPacket.cs @@ -1,8 +1,8 @@ using Intersect.Collections; +using Intersect.Framework.Reflection; #if DIAGNOSTIC using Intersect.Logging; #endif -using Intersect.Reflection; using MessagePack; namespace Intersect.Network; diff --git a/Framework/Intersect.Framework.Core/Network/LegacyCeras.cs b/Framework/Intersect.Framework.Core/Network/LegacyCeras.cs new file mode 100644 index 0000000000..f490b6c5f7 --- /dev/null +++ b/Framework/Intersect.Framework.Core/Network/LegacyCeras.cs @@ -0,0 +1,42 @@ +using Ceras; + +namespace Intersect.Network; + +public partial class LegacyCeras : Ceras +{ + /// + /// Creates a Ceras instance with legacy config (no version tolerance) in order for the server to use for database upgrades to the new serialized formats. + /// + public LegacyCeras() + { + mSerializerConfig = CreateLegacyConfig(); + mSerializer = new CerasSerializer(mSerializerConfig); + } + + /// + /// Creates a Ceras instant wtih legacy config (no version tolerance) in order for the server to use for database upgrades to new serialized formats. + /// The dictionary parameters allow us to override what classes Ceras initializes by mapping old types to new ones. + /// + public LegacyCeras(Dictionary nameTypeMap) + { + mSerializerConfig = CreateLegacyConfig(); + + var typeBinder = new CerasTypeBinder(nameTypeMap); + mSerializerConfig.Advanced.TypeBinder = typeBinder; + + mSerializer = new CerasSerializer(mSerializerConfig); + } + + private SerializerConfig CreateLegacyConfig() + { + var config = new SerializerConfig + { + PreserveReferences = false + }; + + config.Advanced.SealTypesWhenUsingKnownTypes = false; + config.VersionTolerance.Mode = VersionToleranceMode.Disabled; + + return config; + } +} \ No newline at end of file diff --git a/Intersect (Core)/Network/MessagePacker.cs b/Framework/Intersect.Framework.Core/Network/MessagePacker.cs similarity index 93% rename from Intersect (Core)/Network/MessagePacker.cs rename to Framework/Intersect.Framework.Core/Network/MessagePacker.cs index 5efcfb3132..e3c72cbdc2 100644 --- a/Intersect (Core)/Network/MessagePacker.cs +++ b/Framework/Intersect.Framework.Core/Network/MessagePacker.cs @@ -40,12 +40,12 @@ public byte[] Serialize(IntersectPacket packet) catch (Exception exception) { #if DIAGNOSTIC - Log.Debug($"Invalid packet: {Convert.ToHexString(data)}"); + Logger?.Debug($"Invalid packet: {Convert.ToHexString(data)}"); #endif if (!silent) { - Log.Error(exception); + LegacyLogging.Logger?.Error(exception); } return null; diff --git a/Intersect (Core)/Network/NetworkConfiguration.cs b/Framework/Intersect.Framework.Core/Network/NetworkConfiguration.cs similarity index 100% rename from Intersect (Core)/Network/NetworkConfiguration.cs rename to Framework/Intersect.Framework.Core/Network/NetworkConfiguration.cs diff --git a/Intersect (Core)/Network/NetworkStatus.cs b/Framework/Intersect.Framework.Core/Network/NetworkStatus.cs similarity index 100% rename from Intersect (Core)/Network/NetworkStatus.cs rename to Framework/Intersect.Framework.Core/Network/NetworkStatus.cs diff --git a/Intersect (Core)/Network/PacketHandlerAttribute.cs b/Framework/Intersect.Framework.Core/Network/PacketHandlerAttribute.cs similarity index 99% rename from Intersect (Core)/Network/PacketHandlerAttribute.cs rename to Framework/Intersect.Framework.Core/Network/PacketHandlerAttribute.cs index 114f0179c0..8f29a3a289 100644 --- a/Intersect (Core)/Network/PacketHandlerAttribute.cs +++ b/Framework/Intersect.Framework.Core/Network/PacketHandlerAttribute.cs @@ -1,5 +1,5 @@ using System.Reflection; -using Intersect.Reflection; +using Intersect.Framework.Reflection; namespace Intersect.Network; diff --git a/Intersect (Core)/Network/PacketHandlerRegistry.DisposableHandler.cs b/Framework/Intersect.Framework.Core/Network/PacketHandlerRegistry.DisposableHandler.cs similarity index 100% rename from Intersect (Core)/Network/PacketHandlerRegistry.DisposableHandler.cs rename to Framework/Intersect.Framework.Core/Network/PacketHandlerRegistry.DisposableHandler.cs diff --git a/Intersect (Core)/Network/PacketHandlerRegistry.cs b/Framework/Intersect.Framework.Core/Network/PacketHandlerRegistry.cs similarity index 99% rename from Intersect (Core)/Network/PacketHandlerRegistry.cs rename to Framework/Intersect.Framework.Core/Network/PacketHandlerRegistry.cs index f6a6bdf67e..3f5a0e403a 100644 --- a/Intersect (Core)/Network/PacketHandlerRegistry.cs +++ b/Framework/Intersect.Framework.Core/Network/PacketHandlerRegistry.cs @@ -1,7 +1,7 @@ using Intersect.Collections; using Intersect.Logging; -using Intersect.Reflection; using System.Reflection; +using Intersect.Framework.Reflection; namespace Intersect.Network; @@ -27,9 +27,9 @@ public partial class PacketHandlerRegistry : IDisposable protected PacketTypeRegistry PacketTypeRegistry { get; } - protected Logger Logger { get; } + protected ILogger Logger { get; } - public PacketHandlerRegistry(PacketTypeRegistry packetTypeRegistry, Logger logger) + public PacketHandlerRegistry(PacketTypeRegistry packetTypeRegistry, ILogger logger) { PacketTypeRegistry = packetTypeRegistry ?? throw new ArgumentNullException(nameof(packetTypeRegistry)); Logger = logger ?? throw new ArgumentNullException(nameof(logger)); ; @@ -442,7 +442,7 @@ public bool TryRegisterAvailableTypeHandlers(Assembly assembly, bool requireAttr /// /// Discovers all methods in a given assembly that are valid packet handlers, by default requiring a . - /// + /// /// Note: Changing to is very computationally expensive. /// /// the to scan @@ -465,7 +465,7 @@ public static IEnumerable DiscoverMethods(Assembly assembly, bool re /// /// Discovers all methods in a given type that are valid packet handlers, by default requiring a . - /// + /// /// Note: Changing to is very computationally expensive. /// /// the to scan diff --git a/Intersect (Core)/Network/PacketTypeRegistry.cs b/Framework/Intersect.Framework.Core/Network/PacketTypeRegistry.cs similarity index 94% rename from Intersect (Core)/Network/PacketTypeRegistry.cs rename to Framework/Intersect.Framework.Core/Network/PacketTypeRegistry.cs index 61b5b73d2c..ce190793d6 100644 --- a/Intersect (Core)/Network/PacketTypeRegistry.cs +++ b/Framework/Intersect.Framework.Core/Network/PacketTypeRegistry.cs @@ -6,9 +6,9 @@ namespace Intersect.Network; public sealed partial class PacketTypeRegistry { - private static readonly Assembly BuiltInAssembly = typeof(PacketTypeRegistry).Assembly; + private Assembly _builtinAssembly; - private Logger Logger { get; } + private ILogger Logger { get; } private List BuiltInTypesInternal { get; } @@ -18,9 +18,10 @@ public sealed partial class PacketTypeRegistry public IReadOnlyList Types { get; } - public PacketTypeRegistry(Logger logger) + public PacketTypeRegistry(ILogger logger, Assembly builtinAssembly) { Logger = logger ?? throw new ArgumentNullException(nameof(logger)); + _builtinAssembly = builtinAssembly; BuiltInTypesInternal = new List(); BuiltInTypes = BuiltInTypesInternal.WrapReadOnly(); @@ -34,7 +35,7 @@ public bool IsRegistered(Type type) => public bool TryRegisterBuiltIn() { - var types = BuiltInAssembly.GetExportedTypes(); + var types = _builtinAssembly.GetExportedTypes(); var packetTypes = types.Where(type => type.GetInterfaces().Any(interfaceType => interfaceType == typeof(IPacket))); var definedPacketTypes = packetTypes .Where(type => !type.IsInterface && !type.IsValueType && !type.IsAbstract) diff --git a/Framework/Intersect.Framework.Core/Network/ShouldProcessPacket.cs b/Framework/Intersect.Framework.Core/Network/ShouldProcessPacket.cs new file mode 100644 index 0000000000..82cd689090 --- /dev/null +++ b/Framework/Intersect.Framework.Core/Network/ShouldProcessPacket.cs @@ -0,0 +1,3 @@ +namespace Intersect.Network; + +public delegate bool ShouldProcessPacket(IConnection connection, long pSize); \ No newline at end of file diff --git a/Intersect (Core)/Network/TransmissionMode.cs b/Framework/Intersect.Framework.Core/Network/TransmissionMode.cs similarity index 100% rename from Intersect (Core)/Network/TransmissionMode.cs rename to Framework/Intersect.Framework.Core/Network/TransmissionMode.cs diff --git a/Intersect (Core)/Network/UnconnectedMessageSender.cs b/Framework/Intersect.Framework.Core/Network/UnconnectedMessageSender.cs similarity index 100% rename from Intersect (Core)/Network/UnconnectedMessageSender.cs rename to Framework/Intersect.Framework.Core/Network/UnconnectedMessageSender.cs diff --git a/Framework/Intersect.Framework.Core/Network/UnconnectedPacket.cs b/Framework/Intersect.Framework.Core/Network/UnconnectedPacket.cs new file mode 100644 index 0000000000..86e1439a46 --- /dev/null +++ b/Framework/Intersect.Framework.Core/Network/UnconnectedPacket.cs @@ -0,0 +1,9 @@ +using MessagePack; + +namespace Intersect.Network; + +[MessagePackObject] +public abstract class UnconnectedPacket : IntersectPacket +{ + [Key(0)] public Guid MessageId { get; private set; } = Guid.NewGuid(); +} \ No newline at end of file diff --git a/Intersect (Core)/Network/UnconnectedPacket.cs b/Framework/Intersect.Framework.Core/Network/UnconnectedRequestPacket.cs similarity index 54% rename from Intersect (Core)/Network/UnconnectedPacket.cs rename to Framework/Intersect.Framework.Core/Network/UnconnectedRequestPacket.cs index d5851c1212..3f9a5c4082 100644 --- a/Intersect (Core)/Network/UnconnectedPacket.cs +++ b/Framework/Intersect.Framework.Core/Network/UnconnectedRequestPacket.cs @@ -2,12 +2,6 @@ namespace Intersect.Network; -[MessagePackObject] -public abstract class UnconnectedPacket : IntersectPacket -{ - [Key(0)] public Guid MessageId { get; private set; } = Guid.NewGuid(); -} - [MessagePackObject] public abstract class UnconnectedRequestPacket : UnconnectedPacket { @@ -19,10 +13,4 @@ protected UnconnectedRequestPacket(byte[] responseKey) } [Key(1)] public byte[] ResponseKey { get; set; } = Array.Empty(); -} - -[MessagePackObject] -public abstract class UnconnectedResponsePacket : UnconnectedPacket -{ - [IgnoreMember] public byte[] ResponseKey { get; set; } } \ No newline at end of file diff --git a/Framework/Intersect.Framework.Core/Network/UnconnectedResponsePacket.cs b/Framework/Intersect.Framework.Core/Network/UnconnectedResponsePacket.cs new file mode 100644 index 0000000000..e688136c14 --- /dev/null +++ b/Framework/Intersect.Framework.Core/Network/UnconnectedResponsePacket.cs @@ -0,0 +1,9 @@ +using MessagePack; + +namespace Intersect.Network; + +[MessagePackObject] +public abstract class UnconnectedResponsePacket : UnconnectedPacket +{ + [IgnoreMember] public byte[] ResponseKey { get; set; } +} \ No newline at end of file diff --git a/Framework/Intersect.Framework.Core/Plugins/IPlugin.cs b/Framework/Intersect.Framework.Core/Plugins/IPlugin.cs new file mode 100644 index 0000000000..30a97260d8 --- /dev/null +++ b/Framework/Intersect.Framework.Core/Plugins/IPlugin.cs @@ -0,0 +1,30 @@ +using Intersect.Plugins.Interfaces; + +namespace Intersect.Plugins; + +public interface IPlugin +{ + /// + /// The that describes this . + /// + IManifestHelper Manifest { get; } + + /// + /// The for this . + /// + ILoggingHelper Logging { get; } + + /// + /// The for this . + /// + PluginConfiguration Configuration { get; } + + /// + bool IsEnabled { get; internal set; } + + /// + string Key { get; } + + /// + int GetHashCode(); +} \ No newline at end of file diff --git a/Intersect (Core)/Plugins/IPluginBaseContext.cs b/Framework/Intersect.Framework.Core/Plugins/IPluginBaseContext.cs similarity index 100% rename from Intersect (Core)/Plugins/IPluginBaseContext.cs rename to Framework/Intersect.Framework.Core/Plugins/IPluginBaseContext.cs diff --git a/Intersect (Core)/Plugins/IPluginBootstrapContext.cs b/Framework/Intersect.Framework.Core/Plugins/IPluginBootstrapContext.cs similarity index 100% rename from Intersect (Core)/Plugins/IPluginBootstrapContext.cs rename to Framework/Intersect.Framework.Core/Plugins/IPluginBootstrapContext.cs diff --git a/Intersect (Core)/Plugins/IPluginContext.cs b/Framework/Intersect.Framework.Core/Plugins/IPluginContext.cs similarity index 100% rename from Intersect (Core)/Plugins/IPluginContext.cs rename to Framework/Intersect.Framework.Core/Plugins/IPluginContext.cs diff --git a/Intersect (Core)/Plugins/IPluginContext`1.cs b/Framework/Intersect.Framework.Core/Plugins/IPluginContext`1.cs similarity index 100% rename from Intersect (Core)/Plugins/IPluginContext`1.cs rename to Framework/Intersect.Framework.Core/Plugins/IPluginContext`1.cs diff --git a/Intersect (Core)/Plugins/IPluginContext`2.cs b/Framework/Intersect.Framework.Core/Plugins/IPluginContext`2.cs similarity index 100% rename from Intersect (Core)/Plugins/IPluginContext`2.cs rename to Framework/Intersect.Framework.Core/Plugins/IPluginContext`2.cs diff --git a/Intersect (Core)/Plugins/IPluginEntry.cs b/Framework/Intersect.Framework.Core/Plugins/IPluginEntry.cs similarity index 76% rename from Intersect (Core)/Plugins/IPluginEntry.cs rename to Framework/Intersect.Framework.Core/Plugins/IPluginEntry.cs index b7d7dd4174..36b4a55375 100644 --- a/Intersect (Core)/Plugins/IPluginEntry.cs +++ b/Framework/Intersect.Framework.Core/Plugins/IPluginEntry.cs @@ -1,7 +1,4 @@ - -using Microsoft; - -namespace Intersect.Plugins; +namespace Intersect.Plugins; /// /// Defines the API that plugin entry points must implement @@ -14,17 +11,17 @@ public interface IPluginEntry : IDisposable /// Invoked during application bootstrapping before startup. /// /// the current plugin context - void OnBootstrap([ValidatedNotNull] IPluginBootstrapContext context); + void OnBootstrap(IPluginBootstrapContext context); /// /// Invoked during application startup after basic initialization. /// /// the current plugin context - void OnStart([ValidatedNotNull] IPluginContext context); + void OnStart(IPluginContext context); /// /// Invoked during application shutdown. /// /// the current plugin context - void OnStop([ValidatedNotNull] IPluginContext context); + void OnStop(IPluginContext context); } diff --git a/Intersect (Core)/Plugins/IPluginEntry`1.cs b/Framework/Intersect.Framework.Core/Plugins/IPluginEntry`1.cs similarity index 83% rename from Intersect (Core)/Plugins/IPluginEntry`1.cs rename to Framework/Intersect.Framework.Core/Plugins/IPluginEntry`1.cs index 1d1c2cf219..248a2d0494 100644 --- a/Intersect (Core)/Plugins/IPluginEntry`1.cs +++ b/Framework/Intersect.Framework.Core/Plugins/IPluginEntry`1.cs @@ -1,7 +1,4 @@ - -using Microsoft; - -namespace Intersect.Plugins; +namespace Intersect.Plugins; /// /// Defines the API that plugin entry points must implement @@ -17,11 +14,11 @@ public interface IPluginEntry : IPluginEntry /// Invoked during application startup after basic initialization. /// /// the current specialized plugin context - void OnStart([ValidatedNotNull] TPluginContext context); + void OnStart(TPluginContext context); /// /// Invoked during application shutdown. /// /// the current specialized plugin context - void OnStop([ValidatedNotNull] TPluginContext context); + void OnStop(TPluginContext context); } diff --git a/Intersect (Core)/Plugins/IPluginService.cs b/Framework/Intersect.Framework.Core/Plugins/IPluginService.cs similarity index 96% rename from Intersect (Core)/Plugins/IPluginService.cs rename to Framework/Intersect.Framework.Core/Plugins/IPluginService.cs index 8e6339d449..6e2faff477 100644 --- a/Intersect (Core)/Plugins/IPluginService.cs +++ b/Framework/Intersect.Framework.Core/Plugins/IPluginService.cs @@ -12,7 +12,7 @@ public interface IPluginService : IApplicationService /// /// the /// - Plugin this[string pluginKey] { get; } + IPlugin this[string pluginKey] { get; } /// /// The directories to look for plugins in. diff --git a/Framework/Intersect.Framework.Core/Plugins/Interfaces/CreateLoggerOptions.cs b/Framework/Intersect.Framework.Core/Plugins/Interfaces/CreateLoggerOptions.cs new file mode 100644 index 0000000000..599bffada8 --- /dev/null +++ b/Framework/Intersect.Framework.Core/Plugins/Interfaces/CreateLoggerOptions.cs @@ -0,0 +1,30 @@ +using Intersect.Logging; +using Intersect.Logging.Formatting; + +namespace Intersect.Plugins.Interfaces; + +/// +/// Configuration options for creating s. +/// +public partial struct CreateLoggerOptions +{ + /// + /// The minimum for console output, set to to disable. + /// + public LogLevel Console { get; set; } + + /// + /// The minimum for file output, set to to disable. + /// + public LogLevel File { get; set; } + + /// + /// The custom formatters to use for output from the created . + /// + public IReadOnlyList Formatters { get; set; } + + /// + /// The name of the created . + /// + public string Name { get; set; } +} \ No newline at end of file diff --git a/Intersect (Core)/Plugins/Interfaces/ICommandLineHelper.cs b/Framework/Intersect.Framework.Core/Plugins/Interfaces/ICommandLineHelper.cs similarity index 100% rename from Intersect (Core)/Plugins/Interfaces/ICommandLineHelper.cs rename to Framework/Intersect.Framework.Core/Plugins/Interfaces/ICommandLineHelper.cs diff --git a/Intersect (Core)/Plugins/Interfaces/IEmbeddedResourceHelper.cs b/Framework/Intersect.Framework.Core/Plugins/Interfaces/IEmbeddedResourceHelper.cs similarity index 100% rename from Intersect (Core)/Plugins/Interfaces/IEmbeddedResourceHelper.cs rename to Framework/Intersect.Framework.Core/Plugins/Interfaces/IEmbeddedResourceHelper.cs diff --git a/Intersect (Core)/Plugins/Interfaces/ILifecycleHelper.cs b/Framework/Intersect.Framework.Core/Plugins/Interfaces/ILifecycleHelper.cs similarity index 100% rename from Intersect (Core)/Plugins/Interfaces/ILifecycleHelper.cs rename to Framework/Intersect.Framework.Core/Plugins/Interfaces/ILifecycleHelper.cs diff --git a/Framework/Intersect.Framework.Core/Plugins/Interfaces/ILoggingHelper.cs b/Framework/Intersect.Framework.Core/Plugins/Interfaces/ILoggingHelper.cs new file mode 100644 index 0000000000..06b05f1e42 --- /dev/null +++ b/Framework/Intersect.Framework.Core/Plugins/Interfaces/ILoggingHelper.cs @@ -0,0 +1,26 @@ +using Intersect.Logging; + +namespace Intersect.Plugins.Interfaces; + +/// +/// Defines the API for accessing the logging system. +/// +public interface ILoggingHelper +{ + /// + /// The instance for the entire application. + /// + ILogger Application { get; } + + /// + /// The instance for the active plugin. + /// + ILogger Plugin { get; } + + /// + /// Creates specialized s for the active plugin. + /// + /// options to configure the + /// a specialized instance + ILogger CreateLogger(CreateLoggerOptions createLoggerOptions); +} \ No newline at end of file diff --git a/Intersect (Core)/Plugins/Interfaces/IManifestHelper.cs b/Framework/Intersect.Framework.Core/Plugins/Interfaces/IManifestHelper.cs similarity index 100% rename from Intersect (Core)/Plugins/Interfaces/IManifestHelper.cs rename to Framework/Intersect.Framework.Core/Plugins/Interfaces/IManifestHelper.cs diff --git a/Intersect (Core)/Plugins/Interfaces/IPacketHelper.cs b/Framework/Intersect.Framework.Core/Plugins/Interfaces/IPacketHelper.cs similarity index 100% rename from Intersect (Core)/Plugins/Interfaces/IPacketHelper.cs rename to Framework/Intersect.Framework.Core/Plugins/Interfaces/IPacketHelper.cs diff --git a/Intersect (Core)/Plugins/Manifests/JsonManifest.cs b/Framework/Intersect.Framework.Core/Plugins/Manifests/JsonManifest.cs similarity index 100% rename from Intersect (Core)/Plugins/Manifests/JsonManifest.cs rename to Framework/Intersect.Framework.Core/Plugins/Manifests/JsonManifest.cs diff --git a/Intersect (Core)/Plugins/Manifests/Types/Author.cs b/Framework/Intersect.Framework.Core/Plugins/Manifests/Types/Author.cs similarity index 93% rename from Intersect (Core)/Plugins/Manifests/Types/Author.cs rename to Framework/Intersect.Framework.Core/Plugins/Manifests/Types/Author.cs index 163547f78d..9574be6777 100644 --- a/Intersect (Core)/Plugins/Manifests/Types/Author.cs +++ b/Framework/Intersect.Framework.Core/Plugins/Manifests/Types/Author.cs @@ -1,6 +1,4 @@ -using Intersect.Utilities; - -using Newtonsoft.Json; +using Newtonsoft.Json; using System.Diagnostics.CodeAnalysis; using System.Text.RegularExpressions; @@ -78,7 +76,7 @@ public Author(string authorString) Email = email.Value; Homepage = homepage.Value; - mHashCode = ValueUtils.ComputeHashCode(Name, Email, Homepage); + mHashCode = HashCode.Combine(Name, Email, Homepage); } /// @@ -88,13 +86,13 @@ public Author(string authorString) /// the email address of the /// the homepage of the [JsonConstructor] - public Author(string name, string email, string homepage = null) + public Author(string name, string email, string? homepage = default) { Name = name; Email = email; Homepage = homepage ?? string.Empty; - mHashCode = ValueUtils.ComputeHashCode(Name, Email, Homepage); + mHashCode = HashCode.Combine(Name, Email, Homepage); } #endregion Constructors @@ -122,16 +120,16 @@ obj is Author other : throw new NotSupportedException("Comparison only supported with Author."); /// - public int CompareTo(Author other) => ValueUtils.Compare(Parts, other.Parts); + public int CompareTo(Author other) => HashCode.Combine(Parts, other.Parts); /// - public override bool Equals(object obj) => obj is Author author && Equals(author); + public override bool Equals(object? obj) => obj is Author author && Equals(author); /// public bool Equals(Author other) => this == other; /// - public bool Equals(string other) => this == other; + public bool Equals(string? other) => other is not null && other == this; /// public override int GetHashCode() => mHashCode; diff --git a/Intersect (Core)/Plugins/Manifests/Types/Authors.cs b/Framework/Intersect.Framework.Core/Plugins/Manifests/Types/Authors.cs similarity index 98% rename from Intersect (Core)/Plugins/Manifests/Types/Authors.cs rename to Framework/Intersect.Framework.Core/Plugins/Manifests/Types/Authors.cs index 308a7a154f..f03e403f3e 100644 --- a/Intersect (Core)/Plugins/Manifests/Types/Authors.cs +++ b/Framework/Intersect.Framework.Core/Plugins/Manifests/Types/Authors.cs @@ -1,7 +1,5 @@ using System.Collections; -using Intersect.Utilities; - using Newtonsoft.Json; namespace Intersect.Plugins.Manifests.Types; @@ -59,7 +57,14 @@ public Authors(params Author[] authors) : this(authors as IEnumerable) { public Authors(IEnumerable authors) { mAuthors = authors.ToArray(); - mHashCode = ValueUtils.ComputeHashCode(mAuthors); + + HashCode hashCode = new(); + foreach (var author in mAuthors) + { + hashCode.Add(author); + } + + mHashCode = hashCode.ToHashCode(); } #endregion Constructors diff --git a/Intersect (Core)/Network/PackedIntersectPacket.cs b/Framework/Intersect.Framework.Core/Plugins/PackedIntersectPacket.cs similarity index 100% rename from Intersect (Core)/Network/PackedIntersectPacket.cs rename to Framework/Intersect.Framework.Core/Plugins/PackedIntersectPacket.cs diff --git a/Intersect (Core)/Plugins/PluginConfiguration.cs b/Framework/Intersect.Framework.Core/Plugins/PluginConfiguration.cs similarity index 100% rename from Intersect (Core)/Plugins/PluginConfiguration.cs rename to Framework/Intersect.Framework.Core/Plugins/PluginConfiguration.cs diff --git a/Intersect (Core)/Plugins/PluginEntry.cs b/Framework/Intersect.Framework.Core/Plugins/PluginEntry.cs similarity index 100% rename from Intersect (Core)/Plugins/PluginEntry.cs rename to Framework/Intersect.Framework.Core/Plugins/PluginEntry.cs diff --git a/Intersect (Core)/Plugins/PluginEntry`1.cs b/Framework/Intersect.Framework.Core/Plugins/PluginEntry`1.cs similarity index 100% rename from Intersect (Core)/Plugins/PluginEntry`1.cs rename to Framework/Intersect.Framework.Core/Plugins/PluginEntry`1.cs diff --git a/Intersect (Core)/Plugins/Plugin.PluginReference.cs b/Framework/Intersect.Framework.Core/Plugins/PluginReference.cs similarity index 100% rename from Intersect (Core)/Plugins/Plugin.PluginReference.cs rename to Framework/Intersect.Framework.Core/Plugins/PluginReference.cs diff --git a/Intersect (Core)/Point.cs b/Framework/Intersect.Framework.Core/Point.cs similarity index 100% rename from Intersect (Core)/Point.cs rename to Framework/Intersect.Framework.Core/Point.cs diff --git a/Framework/Intersect.Framework.Core/Properties/AssemblyAttributes.cs b/Framework/Intersect.Framework.Core/Properties/AssemblyAttributes.cs new file mode 100644 index 0000000000..43297eb458 --- /dev/null +++ b/Framework/Intersect.Framework.Core/Properties/AssemblyAttributes.cs @@ -0,0 +1,2 @@ +[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("Intersect.Framework.Core.Tests")] +[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("Intersect Core")] diff --git a/Intersect (Core)/Utilities/ReflectionUtils.cs b/Framework/Intersect.Framework.Core/Reflection/ReflectionUtils.cs similarity index 90% rename from Intersect (Core)/Utilities/ReflectionUtils.cs rename to Framework/Intersect.Framework.Core/Reflection/ReflectionUtils.cs index 83beae6e07..00adefdfcd 100644 --- a/Intersect (Core)/Utilities/ReflectionUtils.cs +++ b/Framework/Intersect.Framework.Core/Reflection/ReflectionUtils.cs @@ -9,7 +9,6 @@ namespace Intersect.Utilities; public static partial class ReflectionUtils { - public static string StringifyParameter(ParameterInfo parameter) { return parameter == null @@ -35,13 +34,8 @@ public static string StringifyConstructor(ConstructorInfo constructor) return builder.ToString(); } - public static string StringifyConstructors(Type type) + public static string StringifyConstructors(this Type type) { - if (type == null) - { - return ""; - } - var constructors = type.GetConstructors(); var builder = new StringBuilder(); foreach (var constructor in constructors) @@ -115,7 +109,7 @@ public static bool ExtractCompressedResource(string resourceName, Stream destina using (var resourceStream = new DeflateStream(compressedResourceStream, CompressionMode.Decompress)) { - StreamUtils.Pipe(resourceStream, destinationStream); + resourceStream.Pipe(destinationStream); } } @@ -123,8 +117,7 @@ public static bool ExtractCompressedResource(string resourceName, Stream destina } catch (Exception exception) { - Log.Error(exception); - Log.Error($"resourceName: '{resourceName}'"); + LegacyLogging.Logger?.Error(exception, $"resourceName: '{resourceName}'"); return false; } @@ -146,14 +139,13 @@ public static bool ExtractResource(string resourceName, Stream destinationStream { var executingAssembly = assembly ?? Assembly.GetEntryAssembly(); using var resourceStream = executingAssembly?.GetManifestResourceStream(resourceName); - StreamUtils.Pipe(resourceStream, destinationStream); + StreamExtensions.Pipe(resourceStream, destinationStream); return true; } catch (Exception exception) { - Log.Error(exception); - Log.Error($"resourceName: '{resourceName}'"); + LegacyLogging.Logger?.Error(exception, $"resourceName: '{resourceName}'"); return false; } diff --git a/Framework/Intersect.Framework.Core/Serialization/IntersectTypeSerializationBinder.cs b/Framework/Intersect.Framework.Core/Serialization/IntersectTypeSerializationBinder.cs new file mode 100644 index 0000000000..643970ce98 --- /dev/null +++ b/Framework/Intersect.Framework.Core/Serialization/IntersectTypeSerializationBinder.cs @@ -0,0 +1,22 @@ +using System.Diagnostics.CodeAnalysis; +using Newtonsoft.Json.Serialization; + +namespace Intersect.Framework.Core.Serialization; + +public sealed class IntersectTypeSerializationBinder : ISerializationBinder +{ + private readonly DefaultSerializationBinder _defaultSerializationBinder = new(); + + public Type BindToType(string assemblyName, string typeName) + { + return assemblyName.StartsWith("Intersect") + ? Type.GetType(typeName) + : _defaultSerializationBinder.BindToType(assemblyName, typeName); + } + + public void BindToName( + Type serializedType, + [UnscopedRef] out string assemblyName, + [UnscopedRef] out string typeName + ) => _defaultSerializationBinder.BindToName(serializedType, out assemblyName, out typeName); +} \ No newline at end of file diff --git a/Intersect (Core)/Extensions/StringExtensions.cs b/Framework/Intersect.Framework.Core/StringExtensions.cs similarity index 100% rename from Intersect (Core)/Extensions/StringExtensions.cs rename to Framework/Intersect.Framework.Core/StringExtensions.cs diff --git a/Framework/Intersect.Framework.Core/Threading/ILockingActionQueue.cs b/Framework/Intersect.Framework.Core/Threading/ILockingActionQueue.cs new file mode 100644 index 0000000000..a3c0ad67d8 --- /dev/null +++ b/Framework/Intersect.Framework.Core/Threading/ILockingActionQueue.cs @@ -0,0 +1,6 @@ +namespace Intersect.Threading; + +public interface ILockingActionQueue +{ + Action? NextAction { get; set; } +} \ No newline at end of file diff --git a/Framework/Intersect.Framework/Reflection/ObjectExtensions.cs b/Framework/Intersect.Framework/Reflection/ObjectExtensions.cs index c7c7852ce7..909c2d78c0 100644 --- a/Framework/Intersect.Framework/Reflection/ObjectExtensions.cs +++ b/Framework/Intersect.Framework/Reflection/ObjectExtensions.cs @@ -6,4 +6,11 @@ public static class ObjectExtensions { [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string GetQualifiedTypeName(this object @object) => @object.GetType().GetQualifiedName(); + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static string GetFullishName(this object @object) + { + var type = @object.GetType(); + return type.FullName ?? type.Name; + } } \ No newline at end of file diff --git a/Framework/Intersect.Framework/Reflection/TypeExtensions.cs b/Framework/Intersect.Framework/Reflection/TypeExtensions.cs index 6f45b1f37b..3c07e949b4 100755 --- a/Framework/Intersect.Framework/Reflection/TypeExtensions.cs +++ b/Framework/Intersect.Framework/Reflection/TypeExtensions.cs @@ -131,6 +131,8 @@ public static bool Extends(this Type childType, Type baseType) public static bool ExtendedBy(this Type type) => typeof(TChildType).Extends(type); + public static bool ExtendedBy(this Type type, Type? childType) => childType?.Extends(type) ?? false; + public static Type? FindConcreteType( this Type abstractType, Func predicate, diff --git a/Intersect (Core)/Compression/AssetPacker.cs b/Intersect (Core)/Compression/AssetPacker.cs index 44be5e93b9..eb54842828 100644 --- a/Intersect (Core)/Compression/AssetPacker.cs +++ b/Intersect (Core)/Compression/AssetPacker.cs @@ -5,246 +5,274 @@ namespace Intersect.Compression; /// /// Allows for packaging up assets and extracting them from packaged files. /// -public sealed partial class AssetPacker : IDisposable - { - - /// - /// The location given at the creation of this object defining where we can find our asset packs. - /// - public string PackageLocation { get => packageLocation; } - - /// - /// A list of all packages currently being cached. - /// - public List CachedPackages { get => packageCache.Keys.ToList(); } - - /// - /// A list of all files contained within the asset packs. - /// - public List FileList { get => fileIndex.Select(i => i.FileName).ToList(); } - - // The index used to retrieve data from our cached packages. - private List fileIndex; - - // The location used to load asset packages from. - private string packageLocation; - - // Our package cache as well as the timer used to keep track of what to cache. - private Dictionary packageCache = new Dictionary(); - - // Our timer defining how long to keep items cached in memory. - private long cacheTimeOutTimer = 2 * TimeSpan.TicksPerMinute; - - /// - /// Create a new instance of - /// - /// The index file to load assets from. - /// The location to load asset packages from. - public AssetPacker(string indexFile, string packLocation) - { - fileIndex = JsonConvert.DeserializeObject>(GzipCompression.ReadDecompressedString(indexFile)); - packageLocation = packLocation; - - // Load all pack names from this asset file so we can start keeping track of our caches. - foreach (var pack in fileIndex.Select(i => i.PackName).Distinct().ToArray()) - { - packageCache.Add(pack, new PackageCacheEntry()); - } - } - - /// - /// Retrieve an asset from the asset packages. - /// - /// The asset to retrieve. - /// Returns a containing the requested file. - public MemoryStream GetAsset(string fileName) - { - // Find out where to locate our data. - var asset = findAsset(fileName); - - // Is this file included in our packages? - if (asset == null) - { - return null; - } - - // Set our access timer. - packageCache[asset.PackName].LastAccessTime = DateTime.Now.Ticks; - - // Do we already have this data package cached? - if (packageCache[asset.PackName].StreamCache == null) - { - using (var stream = GzipCompression.CreateDecompressedFileStream(Path.Combine(packageLocation, asset.PackName))) - { - packageCache[asset.PackName].StreamCache = new MemoryStream(); - stream.CopyTo(packageCache[asset.PackName].StreamCache); - } - } - - // Create our buffer. - var bytes = new byte[asset.FileEndByte - asset.FileStartByte]; - - // Search for the file in our cached package. - packageCache[asset.PackName].StreamCache.Seek(asset.FileStartByte, SeekOrigin.Begin); - packageCache[asset.PackName].StreamCache.Read(bytes, 0, bytes.Length); - - // Create a new memorystream and write our data to it, then return it. - var output = new MemoryStream(); - output.Write(bytes, 0, bytes.Length); - output.Position = 0; - return output; - } - - /// - /// Checks whether or not an asset is contained within the loaded index file. This check is case insensitive! - /// - /// The file to look for. - /// Returns whether or not the file was found in the loaded Asset Packs. - public bool Contains(string fileName) => findAsset(fileName) != default; - - /// - /// Updates our cache timers and disposes of items no longer within the caching time limit. - /// - public void UpdateCache() - { - // Cycle through all our packages and check if they've been accessed within our timeout timer. If not, dispose of them. - foreach (var pack in packageCache) - { - if (pack.Value.StreamCache != null && (DateTime.Now.Ticks - pack.Value.LastAccessTime) > cacheTimeOutTimer) - { - pack.Value.StreamCache.Dispose(); - pack.Value.StreamCache = default; - } - } - } - - /// - /// Find the location of an item in our asset packs. - /// - /// The asset file to locate. - /// Returns a containing relevant information regarding the asset's location in our asset packages. - private PackageIndexEntry findAsset(string fileName) - { - return fileIndex.Where(d => d.FileName.Equals(fileName, StringComparison.OrdinalIgnoreCase)).SingleOrDefault(); - } - - #region IDisposable Implementation - /// - /// Disposes of all cached data in the cache. - /// - public void Dispose() - { - foreach (var pack in packageCache) - { - if (pack.Value.StreamCache != null) - { - pack.Value.StreamCache.Dispose(); - pack.Value.StreamCache = null; - } - } - } - #endregion - - #region Static Methods - /// - /// Packages up assets according to our settings. - /// - /// The directory to search for assets to package up in. - /// The filter to use when searching for assets to pack up. - /// The directory to place output assets packs and index files. - /// The filename for the index file. - /// The file prefix for each asset pack. - /// The file extension for each asset pack. - /// The maximum size in Megabytes of combined files to pack up in each asset pack. - public static void PackageAssets(string inputDir, string inputFilter, string outputDir, string indexName, string packPrefix, string packExt, int batchSize) - { - // We can't do less than one MB at a time. - if (batchSize < 1) - { - batchSize = 1; - } - - // Convert to Bytes. - batchSize = (batchSize * 1024) * 1024; - - // Get our asset file layout so we can just loop through this to create our packs. - var packs = GeneratePackLayout(inputDir, inputFilter, packPrefix, packExt, batchSize); - - var index = new List(); - foreach (var pack in packs) - { - using (var stream = GzipCompression.CreateCompressedFileStream(Path.Combine(outputDir, pack.Key))) - { - int streamOffset = 0; - foreach (var item in pack.Value) - { - using (var file = File.OpenRead(item.FullPath)) - { - file.CopyTo(stream); - index.Add(new PackageIndexEntry() { FileName = Path.GetFileName(item.Name), PackName = pack.Key, FileStartByte = streamOffset, FileEndByte = streamOffset + (int)file.Length }); - streamOffset += (int)file.Length; - } - } - } - } - - GzipCompression.WriteCompressedString(Path.Combine(outputDir, indexName), JsonConvert.SerializeObject(index)); - } - - private static Dictionary> GeneratePackLayout(string inputDir, string inputFilter, string packPrefix, string packExt, long batchSize) +public sealed partial class AssetPacker : IAssetPacker +{ + /// + /// The location given at the creation of this object defining where we can find our asset packs. + /// + public string PackageLocation { get => packageLocation; } + + /// + /// A list of all packages currently being cached. + /// + public List CachedPackages { get => packageCache.Keys.ToList(); } + + /// + /// A list of all files contained within the asset packs. + /// + public List FileList { get => fileIndex.Select(i => i.FileName).ToList(); } + + // The index used to retrieve data from our cached packages. + private List fileIndex; + + // The location used to load asset packages from. + private string packageLocation; + + // Our package cache as well as the timer used to keep track of what to cache. + private Dictionary packageCache = new Dictionary(); + + // Our timer defining how long to keep items cached in memory. + private long cacheTimeOutTimer = 2 * TimeSpan.TicksPerMinute; + + /// + /// Create a new instance of + /// + /// The index file to load assets from. + /// The location to load asset packages from. + public AssetPacker(string indexFile, string packLocation) { - var cache = new Dictionary>(); - var currentPack = 0; - long currentSize = 0; + fileIndex = JsonConvert.DeserializeObject>( + GzipCompression.ReadDecompressedString(indexFile) + ); + packageLocation = packLocation; - foreach (var file in new DirectoryInfo(inputDir).GetFiles(inputFilter).OrderByDescending(f => f.Length)) + // Load all pack names from this asset file so we can start keeping track of our caches. + foreach (var pack in fileIndex.Select(i => i.PackName).Distinct().ToArray()) { - // Does this file make us go over our determined batch size, but is it not our first file? - if (currentSize + file.Length > batchSize && currentSize != 0) + packageCache.Add(pack, new PackageCacheEntry()); + } + } + + /// + /// Retrieve an asset from the asset packages. + /// + /// The asset to retrieve. + /// Returns a containing the requested file. + public MemoryStream GetAsset(string fileName) + { + // Find out where to locate our data. + var asset = findAsset(fileName); + + // Is this file included in our packages? + if (asset == null) + { + return null; + } + + // Set our access timer. + packageCache[asset.PackName].LastAccessTime = DateTime.Now.Ticks; + + // Do we already have this data package cached? + if (packageCache[asset.PackName].StreamCache == null) + { + using (var stream = + GzipCompression.CreateDecompressedFileStream(Path.Combine(packageLocation, asset.PackName))) + { + packageCache[asset.PackName].StreamCache = new MemoryStream(); + stream.CopyTo(packageCache[asset.PackName].StreamCache); + } + } + + // Create our buffer. + var bytes = new byte[asset.FileEndByte - asset.FileStartByte]; + + // Search for the file in our cached package. + packageCache[asset.PackName].StreamCache.Seek(asset.FileStartByte, SeekOrigin.Begin); + packageCache[asset.PackName].StreamCache.Read(bytes, 0, bytes.Length); + + // Create a new memorystream and write our data to it, then return it. + var output = new MemoryStream(); + output.Write(bytes, 0, bytes.Length); + output.Position = 0; + return output; + } + + /// + /// Checks whether or not an asset is contained within the loaded index file. This check is case insensitive! + /// + /// The file to look for. + /// Returns whether or not the file was found in the loaded Asset Packs. + public bool Contains(string fileName) => findAsset(fileName) != default; + + /// + /// Updates our cache timers and disposes of items no longer within the caching time limit. + /// + public void UpdateCache() + { + // Cycle through all our packages and check if they've been accessed within our timeout timer. If not, dispose of them. + foreach (var pack in packageCache) + { + if (pack.Value.StreamCache != null && (DateTime.Now.Ticks - pack.Value.LastAccessTime) > cacheTimeOutTimer) + { + pack.Value.StreamCache.Dispose(); + pack.Value.StreamCache = default; + } + } + } + + /// + /// Find the location of an item in our asset packs. + /// + /// The asset file to locate. + /// Returns a containing relevant information regarding the asset's location in our asset packages. + private PackageIndexEntry findAsset(string fileName) + { + return fileIndex.Where(d => d.FileName.Equals(fileName, StringComparison.OrdinalIgnoreCase)).SingleOrDefault(); + } + + #region IDisposable Implementation + + /// + /// Disposes of all cached data in the cache. + /// + public void Dispose() + { + foreach (var pack in packageCache) + { + if (pack.Value.StreamCache != null) + { + pack.Value.StreamCache.Dispose(); + pack.Value.StreamCache = null; + } + } + } + + #endregion + + #region Static Methods + + /// + /// Packages up assets according to our settings. + /// + /// The directory to search for assets to package up in. + /// The filter to use when searching for assets to pack up. + /// The directory to place output assets packs and index files. + /// The filename for the index file. + /// The file prefix for each asset pack. + /// The file extension for each asset pack. + /// The maximum size in Megabytes of combined files to pack up in each asset pack. + public static void PackageAssets(string inputDir, string inputFilter, string outputDir, string indexName, + string packPrefix, string packExt, int batchSize) + { + // We can't do less than one MB at a time. + if (batchSize < 1) + { + batchSize = 1; + } + + // Convert to Bytes. + batchSize = (batchSize * 1024) * 1024; + + // Get our asset file layout so we can just loop through this to create our packs. + var packs = GeneratePackLayout( + inputDir, + inputFilter, + packPrefix, + packExt, + batchSize + ); + + var index = new List(); + foreach (var pack in packs) + { + using (var stream = GzipCompression.CreateCompressedFileStream(Path.Combine(outputDir, pack.Key))) + { + int streamOffset = 0; + foreach (var item in pack.Value) + { + using (var file = File.OpenRead(item.FullPath)) + { + file.CopyTo(stream); + index.Add( + new PackageIndexEntry() + { + FileName = Path.GetFileName(item.Name), + PackName = pack.Key, + FileStartByte = streamOffset, + FileEndByte = streamOffset + (int)file.Length + } + ); + streamOffset += (int)file.Length; + } + } + } + } + + GzipCompression.WriteCompressedString(Path.Combine(outputDir, indexName), JsonConvert.SerializeObject(index)); + } + + private static Dictionary> GeneratePackLayout(string inputDir, string inputFilter, + string packPrefix, string packExt, long batchSize) + { + var cache = new Dictionary>(); + var currentPack = 0; + long currentSize = 0; + + foreach (var file in new DirectoryInfo(inputDir).GetFiles(inputFilter).OrderByDescending(f => f.Length)) + { + // Does this file make us go over our determined batch size, but is it not our first file? + if (currentSize + file.Length > batchSize && currentSize != 0) { - // It's going over and is NOT our first file! Uh-Oh! Move on to the next pack! - currentSize = 0; - currentPack++; + // It's going over and is NOT our first file! Uh-Oh! Move on to the next pack! + currentSize = 0; + currentPack++; } - // Get our pack name for simplicity. - var packname = $"{packPrefix}{currentPack}{packExt}"; + // Get our pack name for simplicity. + var packname = $"{packPrefix}{currentPack}{packExt}"; - // Check if we already have this pack name in our cache, if not add it! - if (!cache.ContainsKey(packname)) + // Check if we already have this pack name in our cache, if not add it! + if (!cache.ContainsKey(packname)) { - cache.Add(packname, new List()); + cache.Add(packname, new List()); } - // Add the file to our cache here. - cache[packname].Add(new PackFileEntry() { Name = file.Name, FullPath = file.FullName }); - currentSize += file.Length; + // Add the file to our cache here. + cache[packname].Add( + new PackFileEntry() + { + Name = file.Name, FullPath = file.FullName + } + ); + currentSize += file.Length; } - return cache; + return cache; + } + + #endregion + + #region Internal classes + + private partial class PackageCacheEntry + { + public long LastAccessTime { get; set; } + public MemoryStream StreamCache { get; set; } + } + + private partial class PackageIndexEntry + { + public string FileName { get; set; } + public string PackName { get; set; } + public int FileStartByte { get; set; } + public int FileEndByte { get; set; } } - #endregion - - #region Internal classes - private partial class PackageCacheEntry - { - public long LastAccessTime { get; set; } - public MemoryStream StreamCache { get; set; } - } - - private partial class PackageIndexEntry - { - public string FileName { get; set; } - public string PackName { get; set; } - public int FileStartByte { get; set; } - public int FileEndByte { get; set; } - } - - private partial class PackFileEntry - { - public string Name { get; set; } - public string FullPath { get; set; } - } - #endregion - - } + + private partial class PackFileEntry + { + public string Name { get; set; } + public string FullPath { get; set; } + } + + #endregion +} \ No newline at end of file diff --git a/Intersect (Core)/Core/ApplicationContext`2.cs b/Intersect (Core)/Core/ApplicationContext`2.cs index 1ab7121c63..eca27b18ee 100644 --- a/Intersect (Core)/Core/ApplicationContext`2.cs +++ b/Intersect (Core)/Core/ApplicationContext`2.cs @@ -58,7 +58,7 @@ protected ApplicationContext(TStartupOptions startupOptions, Logger logger, IPac public TStartupOptions StartupOptions { get; } /// - public Logger Logger { get; } + public ILogger Logger { get; } /// public IPacketHelper PacketHelper { get; } @@ -143,6 +143,7 @@ protected virtual IEnumerable GetAssemblies() var assemblies = new List { typeof(IApplicationContext).Assembly, + typeof(SharedConstants).Assembly, typeof(TContext).Assembly, }; @@ -277,7 +278,7 @@ protected virtual void PostStartup() } /// - public LockingActionQueue StartWithActionQueue() + public ILockingActionQueue StartWithActionQueue() { Start(false); diff --git a/Intersect (Core)/Core/ExperimentalFeatures/CommonExperiments.Core.cs b/Intersect (Core)/Core/ExperimentalFeatures/CommonExperiments.Core.cs index dde530bc74..8fb5d8ab85 100644 --- a/Intersect (Core)/Core/ExperimentalFeatures/CommonExperiments.Core.cs +++ b/Intersect (Core)/Core/ExperimentalFeatures/CommonExperiments.Core.cs @@ -2,6 +2,7 @@ using System.Text; using Intersect.Extensions; +using Intersect.Framework.Core.Serialization; using Intersect.Logging; using Intersect.Utilities; @@ -219,7 +220,8 @@ protected virtual bool Load() Converters = new List { new ExperimentalFlagConverter() - } + }, + SerializationBinder = new IntersectTypeSerializationBinder(), } ); diff --git a/Intersect (Core)/Extensions/VariableModExtensions.cs b/Intersect (Core)/Extensions/VariableModExtensions.cs index df8eb31408..1503ef57e4 100644 --- a/Intersect (Core)/Extensions/VariableModExtensions.cs +++ b/Intersect (Core)/Extensions/VariableModExtensions.cs @@ -5,7 +5,7 @@ namespace Intersect.Extensions; public static class VariableModExtensions { - public static VariableType GetRelatedVariableType(this VariableMod value) + public static VariableType GetRelatedVariableType(this VariableModType value) { if (!Enum.IsDefined(value)) { @@ -18,7 +18,7 @@ public static VariableType GetRelatedVariableType(this VariableMod value) throw new ArgumentOutOfRangeException(nameof(value), value, "Missing enum name"); } - FieldInfo fieldInfo = typeof(VariableMod).GetField(name); + FieldInfo fieldInfo = typeof(VariableModType).GetField(name); if (fieldInfo == null) { throw new MissingFieldException($"Reflection failed for VariableType enum, value was {value}", nameof(value)); diff --git a/Intersect (Core)/Intersect.Core.csproj b/Intersect (Core)/Intersect.Core.csproj index 61dfc62cb8..43ce3bf743 100644 --- a/Intersect (Core)/Intersect.Core.csproj +++ b/Intersect (Core)/Intersect.Core.csproj @@ -68,15 +68,8 @@ - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - @@ -92,9 +85,7 @@ - - @@ -106,9 +97,6 @@ - - - @@ -132,7 +120,7 @@ - + \ No newline at end of file diff --git a/Intersect (Core)/Logging/Log.cs b/Intersect (Core)/Logging/Log.cs index 9ca99c51da..e712d3da48 100644 --- a/Intersect (Core)/Logging/Log.cs +++ b/Intersect (Core)/Logging/Log.cs @@ -1,9 +1,13 @@ using System.Collections.Immutable; using System.Diagnostics; using System.Runtime.CompilerServices; - +using Intersect.Collections; +using Intersect.Configuration; using Intersect.Logging.Formatting; using Intersect.Logging.Output; +using Intersect.Network; +using Intersect.Server.Utilities; +using Intersect.Utilities; namespace Intersect.Logging; @@ -48,6 +52,8 @@ static Log() Outputs = outputs, } ); + + LegacyLogging.Logger = Default; } public static Logger Pretty { get; internal set; } diff --git a/Intersect (Core)/Network/AsymmetricEncryptedPacket.cs b/Intersect (Core)/Network/AsymmetricEncryptedPacket.cs index 302be40799..6f8cc6c108 100644 --- a/Intersect (Core)/Network/AsymmetricEncryptedPacket.cs +++ b/Intersect (Core)/Network/AsymmetricEncryptedPacket.cs @@ -1,5 +1,6 @@ using System.Diagnostics.CodeAnalysis; using System.Security.Cryptography; +using Intersect.Framework.Reflection; using Intersect.Logging; using Intersect.Reflection; using MessagePack; diff --git a/Intersect (Core)/Network/CerasDefaultBufferPool.cs b/Intersect (Core)/Network/CerasDefaultBufferPool.cs new file mode 100644 index 0000000000..c1431ecaaa --- /dev/null +++ b/Intersect (Core)/Network/CerasDefaultBufferPool.cs @@ -0,0 +1,16 @@ +using Ceras; + +namespace Intersect.Network; + +public sealed partial class CerasDefaultBufferPool : ICerasBufferPool +{ + public byte[] RentBuffer(int minimumSize) + { + return System.Buffers.ArrayPool.Shared.Rent(minimumSize); + } + + public void Return(byte[] buffer) + { + System.Buffers.ArrayPool.Shared.Return(buffer, false); + } +} \ No newline at end of file diff --git a/Intersect (Core)/Network/Delegates.cs b/Intersect (Core)/Network/Delegates.cs deleted file mode 100644 index 6ddeb86fb8..0000000000 --- a/Intersect (Core)/Network/Delegates.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace Intersect.Network; - -public delegate bool HandlePacket(TPacketSender packetSender, TPacket packet) - where TPacketSender : IPacketSender where TPacket : IPacket; - -public delegate void HandlePacketVoid(TPacketSender packetSender, TPacket packet) - where TPacketSender : IPacketSender where TPacket : IPacket; - -public delegate bool HandlePacketGeneric(IPacketSender packetSender, IPacket packet); - -public delegate bool HandlePacket(IConnection connection, IPacket packet); - -public delegate bool ShouldProcessPacket(IConnection connection, long pSize); diff --git a/Intersect (Core)/Plugins/Helpers/CommandLineHelper.cs b/Intersect (Core)/Plugins/Helpers/CommandLineHelper.cs index eb6065a274..8ed8a34fb2 100644 --- a/Intersect (Core)/Plugins/Helpers/CommandLineHelper.cs +++ b/Intersect (Core)/Plugins/Helpers/CommandLineHelper.cs @@ -12,7 +12,7 @@ internal sealed partial class CommandLineHelper : PluginHelper, ICommandLineHelp private readonly string[] mArgs; - internal CommandLineHelper(Logger logger, string[] args, Parser parser) : base( + internal CommandLineHelper(ILogger logger, string[] args, Parser parser) : base( logger ) { diff --git a/Intersect (Core)/Plugins/Helpers/LoggingHelper.cs b/Intersect (Core)/Plugins/Helpers/LoggingHelper.cs index 4447a00256..31c87bcf9d 100644 --- a/Intersect (Core)/Plugins/Helpers/LoggingHelper.cs +++ b/Intersect (Core)/Plugins/Helpers/LoggingHelper.cs @@ -48,11 +48,11 @@ private static Logger CreateLogger(IManifestHelper manifest, CreateLoggerOptions private readonly IManifestHelper mManifest; /// - public Logger Application { get; } + public ILogger Application { get; } - public Logger Plugin { get; } + public ILogger Plugin { get; } - internal LoggingHelper(Logger applicationLogger, IManifestHelper manifest) + internal LoggingHelper(ILogger applicationLogger, IManifestHelper manifest) { mManifest = manifest; @@ -67,6 +67,6 @@ internal LoggingHelper(Logger applicationLogger, IManifestHelper manifest) } /// - public Logger CreateLogger(CreateLoggerOptions createLoggerOptions) => + public ILogger CreateLogger(CreateLoggerOptions createLoggerOptions) => CreateLogger(mManifest, createLoggerOptions); } diff --git a/Intersect (Core)/Plugins/Interfaces/ILoggingHelper.cs b/Intersect (Core)/Plugins/Interfaces/ILoggingHelper.cs deleted file mode 100644 index 093c77ad67..0000000000 --- a/Intersect (Core)/Plugins/Interfaces/ILoggingHelper.cs +++ /dev/null @@ -1,53 +0,0 @@ -using Intersect.Logging; -using Intersect.Logging.Formatting; - -namespace Intersect.Plugins.Interfaces; - -/// -/// Defines the API for accessing the logging system. -/// -public interface ILoggingHelper -{ - /// - /// The instance for the entire application. - /// - Logger Application { get; } - - /// - /// The instance for the active plugin. - /// - Logger Plugin { get; } - - /// - /// Creates specialized s for the active plugin. - /// - /// options to configure the - /// a specialized instance - Logger CreateLogger(CreateLoggerOptions createLoggerOptions); -} - -/// -/// Configuration options for creating s. -/// -public partial struct CreateLoggerOptions -{ - /// - /// The minimum for console output, set to to disable. - /// - public LogLevel Console { get; set; } - - /// - /// The minimum for file output, set to to disable. - /// - public LogLevel File { get; set; } - - /// - /// The custom formatters to use for output from the created . - /// - public IReadOnlyList Formatters { get; set; } - - /// - /// The name of the created . - /// - public string Name { get; set; } -} diff --git a/Intersect (Core)/Plugins/Loaders/PluginLoader.Configuration.cs b/Intersect (Core)/Plugins/Loaders/PluginLoader.Configuration.cs index cda1cf67ba..4d8b29e50e 100644 --- a/Intersect (Core)/Plugins/Loaders/PluginLoader.Configuration.cs +++ b/Intersect (Core)/Plugins/Loaders/PluginLoader.Configuration.cs @@ -3,6 +3,7 @@ using Newtonsoft.Json; using System.Diagnostics.CodeAnalysis; using System.Text; +using Intersect.Framework.Core.Serialization; namespace Intersect.Plugins.Loaders; @@ -57,7 +58,8 @@ Plugin plugin serializedOldConfiguration, plugin.Reference.ConfigurationType, new JsonSerializerSettings { - DefaultValueHandling = DefaultValueHandling.Include + DefaultValueHandling = DefaultValueHandling.Include, + SerializationBinder = new IntersectTypeSerializationBinder(), } ) as PluginConfiguration ?? configuration; diff --git a/Intersect (Core)/Plugins/Plugin.cs b/Intersect (Core)/Plugins/Plugin.cs index df76b0c90d..caa312f2d4 100644 --- a/Intersect (Core)/Plugins/Plugin.cs +++ b/Intersect (Core)/Plugins/Plugin.cs @@ -7,7 +7,7 @@ namespace Intersect.Plugins; /// /// Representation of a loaded plugin descriptor. /// -public sealed partial class Plugin +public sealed partial class Plugin : IPlugin { /// /// Create a instance for the given context, manifest and reference. @@ -56,10 +56,17 @@ PluginReference reference internal PluginReference Reference { get; } /// - public bool IsEnabled + internal bool IsEnabled { get => Configuration.IsEnabled; - internal set => Configuration.IsEnabled = value; + set => Configuration.IsEnabled = value; + } + + /// + bool IPlugin.IsEnabled + { + get => IsEnabled; + set => IsEnabled = value; } /// diff --git a/Intersect (Core)/Plugins/PluginHelper.cs b/Intersect (Core)/Plugins/PluginHelper.cs index 888edd3e5d..5199a4be4f 100644 --- a/Intersect (Core)/Plugins/PluginHelper.cs +++ b/Intersect (Core)/Plugins/PluginHelper.cs @@ -10,13 +10,13 @@ public abstract partial class PluginHelper /// /// The for this helper to use. /// - protected Logger Logger { get; } + protected ILogger Logger { get; } /// /// Initializes this . /// /// The for this helper to use. - protected PluginHelper(Logger logger) + protected PluginHelper(ILogger logger) { Logger = logger; } diff --git a/Intersect (Core)/Plugins/PluginService.cs b/Intersect (Core)/Plugins/PluginService.cs index e6eaae139c..4158fc2666 100644 --- a/Intersect (Core)/Plugins/PluginService.cs +++ b/Intersect (Core)/Plugins/PluginService.cs @@ -110,8 +110,7 @@ protected override void TaskStop(IApplicationContext applicationContext) } /// - public Plugin this[string pluginKey] => - Plugins.TryGetValue(pluginKey, out var plugin) ? plugin : null; + public IPlugin this[string pluginKey] => Plugins.GetValueOrDefault(pluginKey); /// public List PluginDirectories { get; } diff --git a/Intersect (Core)/Reflection/ObjectExtensions.cs b/Intersect (Core)/Reflection/ObjectExtensions.cs deleted file mode 100644 index ac02b2ef77..0000000000 --- a/Intersect (Core)/Reflection/ObjectExtensions.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace Intersect.Reflection; - -public static partial class ObjectExtensions -{ - public static string GetFullishName(this object @object) - { - var type = @object.GetType(); - return type.FullName ?? type.Name; - } -} \ No newline at end of file diff --git a/Intersect (Core)/Threading/LockingActionQueue.cs b/Intersect (Core)/Threading/LockingActionQueue.cs index 5edb101ebd..cfebd282cc 100644 --- a/Intersect (Core)/Threading/LockingActionQueue.cs +++ b/Intersect (Core)/Threading/LockingActionQueue.cs @@ -1,7 +1,7 @@ namespace Intersect.Threading; -public partial class LockingActionQueue +public partial class LockingActionQueue : ILockingActionQueue { private readonly object mLockObject; @@ -17,7 +17,7 @@ public LockingActionQueue(object lockObjectObject) mLockObject = lockObjectObject; } - public Action NextAction + public Action? NextAction { get { diff --git a/Intersect (Core)/Updater/Updater.cs b/Intersect (Core)/Updater/Updater.cs index 44b447122a..fa1e71092e 100644 --- a/Intersect (Core)/Updater/Updater.cs +++ b/Intersect (Core)/Updater/Updater.cs @@ -5,6 +5,7 @@ using System.Text; using Intersect.Configuration; +using Intersect.Framework.Core.Serialization; using Intersect.Logging; using Newtonsoft.Json; @@ -143,7 +144,7 @@ private async void RunUpdates() } } - //Copy Over + //Copy Over mCurrentVersion = new Update(); foreach (var file in mUpdate.Files) { @@ -277,8 +278,13 @@ private async void RunUpdates() File.WriteAllText( mCurrentVersionPath, JsonConvert.SerializeObject( - mCurrentVersion.Filter(IsClient), Formatting.Indented, - new JsonSerializerSettings { DefaultValueHandling = DefaultValueHandling.Ignore } + mCurrentVersion.Filter(IsClient), + Formatting.Indented, + new JsonSerializerSettings + { + DefaultValueHandling = DefaultValueHandling.Ignore, + SerializationBinder = new IntersectTypeSerializationBinder(), + } ) ); diff --git a/Intersect (Core)/Utilities/VariableModUtils.cs b/Intersect (Core)/Utilities/VariableModUtils.cs index 0729ddb474..3b0574654c 100644 --- a/Intersect (Core)/Utilities/VariableModUtils.cs +++ b/Intersect (Core)/Utilities/VariableModUtils.cs @@ -5,60 +5,60 @@ namespace Intersect.Utilities; public static class VariableModUtils { - public static readonly ImmutableArray SetMods = ImmutableArray.Create(new VariableMod[] { - VariableMod.Set, - VariableMod.DupPlayerVar, - VariableMod.DupGlobalVar, - VariableMod.DupGuildVar, - VariableMod.DuplicateUserVariable, + public static readonly ImmutableArray SetMods = ImmutableArray.Create(new VariableModType[] { + VariableModType.Set, + VariableModType.DupPlayerVar, + VariableModType.DupGlobalVar, + VariableModType.DupGuildVar, + VariableModType.DuplicateUserVariable, }); - public static readonly ImmutableArray AddMods = ImmutableArray.Create(new VariableMod[] { - VariableMod.Add, - VariableMod.AddPlayerVar, - VariableMod.AddGlobalVar, - VariableMod.AddGuildVar, - VariableMod.AddUserVariable, + public static readonly ImmutableArray AddMods = ImmutableArray.Create(new VariableModType[] { + VariableModType.Add, + VariableModType.AddPlayerVar, + VariableModType.AddGlobalVar, + VariableModType.AddGuildVar, + VariableModType.AddUserVariable, }); - public static readonly ImmutableArray SubMods = ImmutableArray.Create(new VariableMod[] { - VariableMod.Subtract, - VariableMod.SubtractPlayerVar, - VariableMod.SubtractGlobalVar, - VariableMod.SubtractGuildVar, - VariableMod.SubtractUserVariable, + public static readonly ImmutableArray SubMods = ImmutableArray.Create(new VariableModType[] { + VariableModType.Subtract, + VariableModType.SubtractPlayerVar, + VariableModType.SubtractGlobalVar, + VariableModType.SubtractGuildVar, + VariableModType.SubtractUserVariable, }); - public static readonly ImmutableArray MultMods = ImmutableArray.Create(new VariableMod[] { - VariableMod.Multiply, - VariableMod.MultiplyPlayerVar, - VariableMod.MultiplyGlobalVar, - VariableMod.MultiplyGuildVar, - VariableMod.MultiplyUserVariable, + public static readonly ImmutableArray MultMods = ImmutableArray.Create(new VariableModType[] { + VariableModType.Multiply, + VariableModType.MultiplyPlayerVar, + VariableModType.MultiplyGlobalVar, + VariableModType.MultiplyGuildVar, + VariableModType.MultiplyUserVariable, }); - public static readonly ImmutableArray DivideMods = ImmutableArray.Create(new VariableMod[] { - VariableMod.Divide, - VariableMod.DividePlayerVar, - VariableMod.DivideGlobalVar, - VariableMod.DivideGuildVar, - VariableMod.DivideUserVariable, + public static readonly ImmutableArray DivideMods = ImmutableArray.Create(new VariableModType[] { + VariableModType.Divide, + VariableModType.DividePlayerVar, + VariableModType.DivideGlobalVar, + VariableModType.DivideGuildVar, + VariableModType.DivideUserVariable, }); - public static readonly ImmutableArray LShiftMods = ImmutableArray.Create(new VariableMod[] { - VariableMod.LeftShift, - VariableMod.LeftShiftPlayerVar, - VariableMod.LeftShiftGlobalVar, - VariableMod.LeftShiftGuildVar, - VariableMod.LeftShiftUserVariable, + public static readonly ImmutableArray LShiftMods = ImmutableArray.Create(new VariableModType[] { + VariableModType.LeftShift, + VariableModType.LeftShiftPlayerVar, + VariableModType.LeftShiftGlobalVar, + VariableModType.LeftShiftGuildVar, + VariableModType.LeftShiftUserVariable, }); - public static readonly ImmutableArray RShiftMods = ImmutableArray.Create(new VariableMod[] { - VariableMod.RightShift, - VariableMod.RightShiftPlayerVar, - VariableMod.RightShiftGlobalVar, - VariableMod.RightShiftGuildVar, - VariableMod.RightShiftUserVariable, + public static readonly ImmutableArray RShiftMods = ImmutableArray.Create(new VariableModType[] { + VariableModType.RightShift, + VariableModType.RightShiftPlayerVar, + VariableModType.RightShiftGlobalVar, + VariableModType.RightShiftGuildVar, + VariableModType.RightShiftUserVariable, }); } diff --git a/Intersect.Client.Core/Core/Bootstrapper.cs b/Intersect.Client.Core/Core/Bootstrapper.cs index 2dc5cbc0a1..9facb1d71e 100644 --- a/Intersect.Client.Core/Core/Bootstrapper.cs +++ b/Intersect.Client.Core/Core/Bootstrapper.cs @@ -32,7 +32,7 @@ public static void Start(params string[] args) ); var logger = Log.Default; - var packetTypeRegistry = new PacketTypeRegistry(logger); + var packetTypeRegistry = new PacketTypeRegistry(logger, typeof(SharedConstants).Assembly); if (!packetTypeRegistry.TryRegisterBuiltIn()) { logger.Error("Failed to register built-in packets."); diff --git a/Intersect.Client.Core/Entities/Entity.cs b/Intersect.Client.Core/Entities/Entity.cs index fbfa444fd8..75788bdb9d 100644 --- a/Intersect.Client.Core/Entities/Entity.cs +++ b/Intersect.Client.Core/Entities/Entity.cs @@ -17,7 +17,6 @@ using Intersect.Logging; using Intersect.Network.Packets.Server; using Intersect.Utilities; -using MapAttribute = Intersect.Enums.MapAttribute; namespace Intersect.Client.Entities; @@ -2385,18 +2384,18 @@ public int IsTileBlocked( { if (gameMap.Attributes[tmpX, tmpY] != null) { - if (gameMap.Attributes[tmpX, tmpY].Type == MapAttribute.Blocked || (gameMap.Attributes[tmpX, tmpY].Type == MapAttribute.Animation && ((MapAnimationAttribute)gameMap.Attributes[tmpX, tmpY]).IsBlock)) + if (gameMap.Attributes[tmpX, tmpY].Type == MapAttributeType.Blocked || (gameMap.Attributes[tmpX, tmpY].Type == MapAttributeType.Animation && ((MapAnimationAttribute)gameMap.Attributes[tmpX, tmpY]).IsBlock)) { return -2; } - else if (gameMap.Attributes[tmpX, tmpY].Type == MapAttribute.ZDimension) + else if (gameMap.Attributes[tmpX, tmpY].Type == MapAttributeType.ZDimension) { if (((MapZDimensionAttribute)gameMap.Attributes[tmpX, tmpY]).BlockedLevel - 1 == z) { return -3; } } - else if (gameMap.Attributes[tmpX, tmpY].Type == MapAttribute.NpcAvoid) + else if (gameMap.Attributes[tmpX, tmpY].Type == MapAttributeType.NpcAvoid) { if (!ignoreNpcAvoids) { diff --git a/Intersect.Client.Core/Entities/Player.cs b/Intersect.Client.Core/Entities/Player.cs index 653955e0fc..04d7cff10c 100644 --- a/Intersect.Client.Core/Entities/Player.cs +++ b/Intersect.Client.Core/Entities/Player.cs @@ -22,7 +22,6 @@ using Intersect.Logging; using Intersect.Network.Packets.Server; using Intersect.Utilities; -using MapAttribute = Intersect.Enums.MapAttribute; namespace Intersect.Client.Entities; @@ -1324,7 +1323,7 @@ private void TryToChangeDimension() { if (Maps.MapInstance.Get(MapId) != null && Maps.MapInstance.Get(MapId).Attributes[X, Y] != null) { - if (Maps.MapInstance.Get(MapId).Attributes[X, Y].Type == MapAttribute.ZDimension) + if (Maps.MapInstance.Get(MapId).Attributes[X, Y].Type == MapAttributeType.ZDimension) { if (((MapZDimensionAttribute)Maps.MapInstance.Get(MapId).Attributes[X, Y]).GatewayTo > 0) { diff --git a/Intersect.Client.Core/Entities/Projectiles/Projectile.cs b/Intersect.Client.Core/Entities/Projectiles/Projectile.cs index aad3f8cd71..c844d18c43 100644 --- a/Intersect.Client.Core/Entities/Projectiles/Projectile.cs +++ b/Intersect.Client.Core/Entities/Projectiles/Projectile.cs @@ -5,7 +5,6 @@ using Intersect.GameObjects.Maps; using Intersect.Network.Packets.Server; using Intersect.Utilities; -using MapAttribute = Intersect.Enums.MapAttribute; namespace Intersect.Client.Entities.Projectiles; @@ -566,7 +565,7 @@ public void CheckForCollision() { var attribute = spawnMap.Attributes[projectileSpawn.X, projectileSpawn.Y]; - if (attribute != null && attribute.Type == MapAttribute.ZDimension) + if (attribute != null && attribute.Type == MapAttributeType.ZDimension) { var zDimensionAttribute = (MapZDimensionAttribute)attribute; diff --git a/Intersect.Client.Core/Maps/MapInstance.cs b/Intersect.Client.Core/Maps/MapInstance.cs index fcf471a6ab..e1a1a262ec 100644 --- a/Intersect.Client.Core/Maps/MapInstance.cs +++ b/Intersect.Client.Core/Maps/MapInstance.cs @@ -15,6 +15,7 @@ using Intersect.Client.Localization; using Intersect.Compression; using Intersect.Enums; +using Intersect.Framework.Core.Serialization; using Intersect.GameObjects; using Intersect.GameObjects.Maps; using Intersect.Logging; @@ -22,7 +23,6 @@ using Intersect.Utilities; using Newtonsoft.Json; -using MapAttribute = Intersect.Enums.MapAttribute; namespace Intersect.Client.Maps; @@ -167,7 +167,13 @@ public void Load(string json) { LocalEntitiesToDispose.AddRange(LocalEntities.Keys.ToArray()); JsonConvert.PopulateObject( - json, this, new JsonSerializerSettings { ObjectCreationHandling = ObjectCreationHandling.Replace } + json, + this, + new JsonSerializerSettings + { + SerializationBinder = new IntersectTypeSerializationBinder(), + ObjectCreationHandling = ObjectCreationHandling.Replace, + } ); IsLoaded = true; @@ -602,7 +608,7 @@ private void UpdateMapAttributes() switch (mapAttribute.Type) { - case MapAttribute.Animation: + case MapAttributeType.Animation: { var anim = AnimationBase.Get(((MapAnimationAttribute)mapAttribute).AnimationId); if (anim == null) @@ -624,7 +630,7 @@ private void UpdateMapAttributes() mAttributeAnimInstances[mapAttribute].Update(); break; } - case MapAttribute.Critter: + case MapAttributeType.Critter: { var critterAttribute = ((MapCritterAttribute)mapAttribute); var sprite = critterAttribute.Sprite; @@ -675,7 +681,7 @@ public void CreateMapSounds() for (var y = 0; y < _height; ++y) { var attribute = Attributes?[x, y]; - if (attribute?.Type != MapAttribute.Sound) + if (attribute?.Type != MapAttributeType.Sound) { continue; } diff --git a/Intersect.Client.Core/MonoGame/File Management/MonoContentManager.cs b/Intersect.Client.Core/MonoGame/File Management/MonoContentManager.cs index 207108777d..bd150fb75c 100644 --- a/Intersect.Client.Core/MonoGame/File Management/MonoContentManager.cs +++ b/Intersect.Client.Core/MonoGame/File Management/MonoContentManager.cs @@ -16,7 +16,7 @@ namespace Intersect.Client.MonoGame.File_Management; public partial class MonoContentManager : GameContentManager { - public MonoContentManager() + public MonoContentManager(ILogger logger) : base(logger) { var rootPath = Path.GetFullPath(ClientConfiguration.ResourcesDirectory); diff --git a/Intersect.Client.Core/MonoGame/IntersectGame.cs b/Intersect.Client.Core/MonoGame/IntersectGame.cs index 01dc6d6d2d..ffbc5282c9 100644 --- a/Intersect.Client.Core/MonoGame/IntersectGame.cs +++ b/Intersect.Client.Core/MonoGame/IntersectGame.cs @@ -99,8 +99,8 @@ private IntersectGame(IClientContext context, Action postStartupAction) Content.RootDirectory = ""; IsMouseVisible = true; - Globals.ContentManager = new MonoContentManager(); - Globals.Database = new JsonDatabase(); + Globals.ContentManager = new MonoContentManager(Log.Default); + Globals.Database = new JsonDatabase(Log.Default); // Load configuration. Globals.Database.LoadPreferences(); diff --git a/Intersect.Client.Core/Networking/PacketHandler.cs b/Intersect.Client.Core/Networking/PacketHandler.cs index efb5c61e3f..180d2779f1 100644 --- a/Intersect.Client.Core/Networking/PacketHandler.cs +++ b/Intersect.Client.Core/Networking/PacketHandler.cs @@ -23,7 +23,6 @@ using Intersect.Utilities; using Intersect.Framework; using Intersect.Models; -using MapAttribute = Intersect.Enums.MapAttribute; using Intersect.Client.Interface.Shared; using Intersect.Network.Packets.Client; @@ -40,7 +39,7 @@ private sealed partial class VirtualPacketSender : IPacketSender public VirtualPacketSender(IApplicationContext applicationContext) => ApplicationContext = applicationContext ?? throw new ArgumentNullException(nameof(applicationContext)); - + #region Implementation of IPacketSender /// @@ -64,7 +63,7 @@ public bool Send(IPacket packet) public IClientContext Context { get; } - public Logger Logger => Context.Logger; + public ILogger Logger => Context.Logger; public PacketHandlerRegistry Registry { get; } @@ -253,7 +252,7 @@ private void HandleMap(IPacketSender packetSender, MapPacket packet, bool skipSa } MapInstance.UpdateMapRequestTime(packet.MapId); - + if (MapInstance.TryGet(mapId, out var mapInstance)) { if (packet.Revision == mapInstance.Revision) @@ -567,7 +566,7 @@ public void HandlePacket(IPacketSender packetSender, Intersect.Network.Packets.S //AnnouncementPacket public void HandlePacket(IPacketSender packetSender, AnnouncementPacket packet) { - Interface.Interface.GameUi.AnnouncementWindow.ShowAnnouncement(packet.Message, packet.Duration); + Interface.Interface.GameUi.AnnouncementWindow.ShowAnnouncement(packet.Message, packet.Duration); } //ActionMsgPackets @@ -754,7 +753,7 @@ public void HandlePacket(IPacketSender packetSender, EntityMovePacket packet) // Set the Z-Dimension if the player has moved up or down a dimension. if (entityMap.Attributes[en.X, en.Y] != null && - entityMap.Attributes[en.X, en.Y].Type == MapAttribute.ZDimension) + entityMap.Attributes[en.X, en.Y].Type == MapAttributeType.ZDimension) { if (((MapZDimensionAttribute) entityMap.Attributes[en.X, en.Y]).GatewayTo > 0) { @@ -1109,7 +1108,7 @@ public void HandlePacket(IPacketSender packetSender, EntityDiePacket packet) var id = packet.Id; var type = packet.Type; var mapId = packet.MapId; - + Entity en = null; if (type < EntityType.Event) { @@ -1117,7 +1116,7 @@ public void HandlePacket(IPacketSender packetSender, EntityDiePacket packet) { return; } - + en = Globals.Entities[id]; } else @@ -1215,7 +1214,7 @@ public void HandlePacket(IPacketSender packetSender, MapItemsPacket packet) foreach(var item in packet.Items) { var mapItem = new MapItemInstance(item.TileIndex,item.Id, item.ItemId, item.BagId, item.Quantity, item.Properties); - + if (!map.MapItems.ContainsKey(mapItem.TileIndex)) { map.MapItems.Add(mapItem.TileIndex, new List()); @@ -1270,7 +1269,7 @@ public void HandlePacket(IPacketSender packetSender, MapItemUpdatePacket packet) { // Reverse the array again to match server, add item.. then reverse again to get the right render order. map.MapItems[packet.TileIndex].Add(mapItem); - } + } } } @@ -2121,7 +2120,7 @@ public void HandlePacket(IPacketSender packetSender, PasswordResetResultPacket p public void HandlePacket(IPacketSender packetSender, TargetOverridePacket packet) { if (Globals.Entities.ContainsKey(packet.TargetId)) - { + { Globals.Me.TryTarget(Globals.Entities[packet.TargetId], true); } } diff --git a/Intersect (Core)/Enums/TypewriterBehavior.cs b/Intersect.Client.Framework/Configuration/Features/Typewriter/TypewriterBehavior.cs similarity index 100% rename from Intersect (Core)/Enums/TypewriterBehavior.cs rename to Intersect.Client.Framework/Configuration/Features/Typewriter/TypewriterBehavior.cs diff --git a/Intersect.Client.Framework/Database/JsonDatabase.cs b/Intersect.Client.Framework/Database/JsonDatabase.cs index 891b117792..54ea5ce3ce 100644 --- a/Intersect.Client.Framework/Database/JsonDatabase.cs +++ b/Intersect.Client.Framework/Database/JsonDatabase.cs @@ -10,11 +10,13 @@ namespace Intersect.Client.Framework.Database; public class JsonDatabase : GameDatabase { private readonly string _instancePath; + private readonly ILogger _logger; private JObject? _instance; - public JsonDatabase() + public JsonDatabase(ILogger logger) { _instancePath = GetInstancePath(ClientConfiguration.Instance); + _logger = logger; _ = TryOpenOrCreate(_instancePath, out _instance); } @@ -24,7 +26,7 @@ private static string GetInstancePath(ClientConfiguration instance) Assembly.GetEntryAssembly().GetName().Name, $"{instance.Host}.{instance.Port}.json"); } - private static bool TryOpenOrCreate(string instancePath, [NotNullWhen(true)] out JObject? instance) + private bool TryOpenOrCreate(string instancePath, [NotNullWhen(true)] out JObject? instance) { try { @@ -50,13 +52,13 @@ private static bool TryOpenOrCreate(string instancePath, [NotNullWhen(true)] out } catch (Exception exception) { - Log.Error(exception, $"Failed to open or create part or all of the path: {instancePath}"); + _logger.Error(exception, $"Failed to open or create part or all of the path: {instancePath}"); instance = default; return false; } } - private static bool TryWrite(string instancePath, JObject instance) + private bool TryWrite(string instancePath, JObject instance) { try { @@ -83,7 +85,7 @@ private static bool TryWrite(string instancePath, JObject instance) } catch (Exception exception) { - Log.Error(exception, + _logger.Error(exception, $"Failed to open or create part or all of the path, or failed while writing to: {instancePath}"); instance = default; return false; @@ -126,7 +128,7 @@ public override string LoadPreference(string key) return token.Value(); } - Log.Warn($"Found invalid type {token.Type} stored in {key} instead of {JTokenType.String}."); + _logger.Warn($"Found invalid type {token.Type} stored in {key} instead of {JTokenType.String}."); return string.Empty; } diff --git a/Intersect.Client.Framework/File Management/GameContentManager.cs b/Intersect.Client.Framework/File Management/GameContentManager.cs index e786d41692..6172690dfc 100644 --- a/Intersect.Client.Framework/File Management/GameContentManager.cs +++ b/Intersect.Client.Framework/File Management/GameContentManager.cs @@ -13,8 +13,7 @@ namespace Intersect.Client.Framework.File_Management; public abstract partial class GameContentManager : IContentManager { - - + public ILogger Logger { get; } public enum UI { @@ -68,19 +67,20 @@ public enum UI /// /// Contains all indexed files and their caches from sound pack files. /// - public AssetPacker SoundPacks { get; set; } + public IAssetPacker SoundPacks { get; set; } /// /// Contains all indexed files and their caches from music pack files. /// - public AssetPacker MusicPacks { get; set; } + public IAssetPacker MusicPacks { get; set; } public bool TilesetsLoaded = false; public ContentWatcher ContentWatcher { get; protected set; } - protected GameContentManager() + protected GameContentManager(ILogger logger) { + Logger = logger; Current = this; } @@ -472,7 +472,7 @@ public virtual void SaveUIJson(UI stage, string name, string json, string resolu } catch (Exception exception) { - Log.Debug(exception); + Logger.Debug(exception); } }); return; @@ -489,7 +489,7 @@ public virtual void SaveUIJson(UI stage, string name, string json, string resolu } catch (Exception exception) { - Log.Debug(exception); + Logger.Debug(exception); } }); } diff --git a/Intersect.Client.Framework/Graphics/GameTexture.cs b/Intersect.Client.Framework/Graphics/GameTexture.cs index 956559a183..b8fa887db7 100644 --- a/Intersect.Client.Framework/Graphics/GameTexture.cs +++ b/Intersect.Client.Framework/Graphics/GameTexture.cs @@ -1,6 +1,7 @@ using System.Diagnostics; using System.Runtime.CompilerServices; using Intersect.Client.Framework.Content; +using Intersect.Client.Framework.File_Management; using Intersect.Client.Framework.GenericClasses; using Intersect.Logging; @@ -82,7 +83,7 @@ public GameTexturePackFrame? TexturePackFrame break; default: - Log.Error(new ArgumentOutOfRangeException(nameof(boundsComparison), boundsComparison.ToString())); + GameContentManager.Current?.Logger.Error(new ArgumentOutOfRangeException(nameof(boundsComparison), boundsComparison.ToString())); break; } diff --git a/Intersect.Client.Framework/Gwen/Control/Base.cs b/Intersect.Client.Framework/Gwen/Control/Base.cs index c5330d2caa..c0ae337889 100644 --- a/Intersect.Client.Framework/Gwen/Control/Base.cs +++ b/Intersect.Client.Framework/Gwen/Control/Base.cs @@ -12,7 +12,7 @@ using Newtonsoft.Json.Linq; using Intersect.Logging; using Intersect.Client.Framework.Gwen.Renderer; -using Intersect.Reflection; +using Intersect.Framework.Reflection; namespace Intersect.Client.Framework.Gwen.Control; @@ -888,13 +888,13 @@ public void LoadJsonUi(GameContentManager.UI stage, string? resolution, bool sav { if (string.IsNullOrWhiteSpace(Name)) { - Log.Warn($"Attempted to load layout for nameless {GetType().FullName}"); + GameContentManager.Current?.Logger.Warn($"Attempted to load layout for nameless {GetType().FullName}"); return; } if (string.IsNullOrWhiteSpace(resolution) || string.IsNullOrEmpty(resolution)) { - Log.Warn($"Attempted to load layout for {Name} with no resolution"); + GameContentManager.Current?.Logger.Warn($"Attempted to load layout for {Name} with no resolution"); return; } diff --git a/Intersect.Client.Framework/Gwen/Control/TextBox.cs b/Intersect.Client.Framework/Gwen/Control/TextBox.cs index 232d8a62ae..a22f5d3105 100644 --- a/Intersect.Client.Framework/Gwen/Control/TextBox.cs +++ b/Intersect.Client.Framework/Gwen/Control/TextBox.cs @@ -614,7 +614,7 @@ public virtual void ReplaceText(int startPos, int length, string? replacement, b } catch (Exception exception) { - Log.Warn(exception); + LegacyLogging.Logger?.Warn(exception); } } diff --git a/Intersect.Client.Framework/Gwen/Renderer/IntersectRenderer.cs b/Intersect.Client.Framework/Gwen/Renderer/IntersectRenderer.cs index b85ff06df8..42df0f01b2 100644 --- a/Intersect.Client.Framework/Gwen/Renderer/IntersectRenderer.cs +++ b/Intersect.Client.Framework/Gwen/Renderer/IntersectRenderer.cs @@ -1,3 +1,4 @@ +using Intersect.Client.Framework.File_Management; using Intersect.Client.Framework.GenericClasses; using Intersect.Client.Framework.Graphics; using Intersect.Configuration; @@ -340,7 +341,7 @@ public void SetupCacheTexture(Control.Base control) if (!m_RT.ContainsKey(control)) { var keys = m_RT.Keys.Select(key => key.CanonicalName); - Log.Error($"{control.CanonicalName} not found in the list of render targets: {string.Join(", ", keys)}"); + GameContentManager.Current?.Logger.Error($"{control.CanonicalName} not found in the list of render targets: {string.Join(", ", keys)}"); } mRenderTarget = m_RT[control]; // make cache current RT mRenderTarget.Begin(); @@ -358,7 +359,7 @@ public void FinishCacheTexture(Control.Base control) } /// - /// Called when gwen wants to draw the cached version of the control. + /// Called when gwen wants to draw the cached version of the control. /// /// Control to be rendered. public void DrawCachedControlTexture(Control.Base control) @@ -376,7 +377,7 @@ public void DrawCachedControlTexture(Control.Base control) } /// - /// Called to actually create a cached texture. + /// Called to actually create a cached texture. /// /// Control to be rendered. public void CreateControlCacheTexture(Control.Base control) diff --git a/Intersect.Client.Framework/Intersect.Client.Framework.csproj b/Intersect.Client.Framework/Intersect.Client.Framework.csproj index bb98011a3a..3c128122c8 100644 --- a/Intersect.Client.Framework/Intersect.Client.Framework.csproj +++ b/Intersect.Client.Framework/Intersect.Client.Framework.csproj @@ -20,7 +20,7 @@ - + \ No newline at end of file diff --git a/Intersect.Client.Framework/Maps/IMapInstance.cs b/Intersect.Client.Framework/Maps/IMapInstance.cs index 09b9ea14fe..fac59388b2 100644 --- a/Intersect.Client.Framework/Maps/IMapInstance.cs +++ b/Intersect.Client.Framework/Maps/IMapInstance.cs @@ -26,8 +26,7 @@ public interface IMapInstance int GridY { get; set; } bool IsLoaded { get; } - void AddEvent(Guid evtId, EventEntityPacket packet); - void AddTileAnimation(Guid animId, int tileX, int tileY, Direction dir = Direction.None, IEntity owner = null); + void AddTileAnimation(Guid animId, int tileX, int tileY, Direction dir = Direction.None, IEntity? owner = null); void CompareEffects(IMapInstance oldMap); bool InView(); void Load(string json); diff --git a/Intersect.Editor/Core/Graphics.cs b/Intersect.Editor/Core/Graphics.cs index bb708a9c71..c56c57c45f 100644 --- a/Intersect.Editor/Core/Graphics.cs +++ b/Intersect.Editor/Core/Graphics.cs @@ -14,7 +14,6 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using MapAttribute = Intersect.Enums.MapAttribute; namespace Intersect.Editor.Core; @@ -916,7 +915,7 @@ private static void DrawSelectionRect() for (var y = 0; y < Options.MapHeight; y++) { var attr = tmpMap.Attributes[x, y]; - if ((attr?.Type ?? MapAttribute.Walkable) == MapAttribute.Walkable) + if ((attr?.Type ?? MapAttributeType.Walkable) == MapAttributeType.Walkable) { continue; } @@ -1374,7 +1373,7 @@ bool alternate continue; } - if (tmpMap.Attributes[x, y].Type == MapAttribute.Resource && !upper && !alternate) + if (tmpMap.Attributes[x, y].Type == MapAttributeType.Resource && !upper && !alternate) { var resource = ResourceBase.Get(((MapResourceAttribute) tmpMap.Attributes[x, y]).ResourceId); if (resource == null) @@ -1443,7 +1442,7 @@ bool alternate DrawTexture(res, xpos, ypos, 0, 0, res.Width, res.Height, renderTarget); } } - else if (tmpMap.Attributes[x, y].Type == MapAttribute.Animation) + else if (tmpMap.Attributes[x, y].Type == MapAttributeType.Animation) { var animation = AnimationBase.Get(((MapAnimationAttribute) tmpMap.Attributes[x, y]).AnimationId); diff --git a/Intersect.Editor/Forms/DockingElements/frmMapEditor.cs b/Intersect.Editor/Forms/DockingElements/frmMapEditor.cs index 3167ef9cb9..89981fcdff 100644 --- a/Intersect.Editor/Forms/DockingElements/frmMapEditor.cs +++ b/Intersect.Editor/Forms/DockingElements/frmMapEditor.cs @@ -16,7 +16,6 @@ using Intersect.Logging; using Microsoft.Xna.Framework.Graphics; using WeifenLuo.WinFormsUI.Docking; -using MapAttribute = Intersect.Enums.MapAttribute; using Timer = System.Windows.Forms.Timer; namespace Intersect.Editor.Forms.DockingElements; @@ -1703,9 +1702,9 @@ public void SmartEraseLayer(int x, int y) } } - private void SmartEraseAttribute(int x, int y, MapAttribute attribute) + private void SmartEraseAttribute(int x, int y, MapAttributeType attribute) { - var a = MapAttribute.Walkable; + var a = MapAttributeType.Walkable; if (x < 0 || x >= Options.MapWidth || y < 0 || y >= Options.MapHeight) { @@ -1730,7 +1729,7 @@ private void SmartEraseAttribute(int x, int y, MapAttribute attribute) public void SmartEraseAttributes(int x, int y) { - var attribute = MapAttribute.Walkable; + var attribute = MapAttributeType.Walkable; if (Globals.CurrentMap.Attributes[x, y] != null) { diff --git a/Intersect.Editor/Forms/DockingElements/frmMapLayers.cs b/Intersect.Editor/Forms/DockingElements/frmMapLayers.cs index 1c60158407..efe4c49002 100644 --- a/Intersect.Editor/Forms/DockingElements/frmMapLayers.cs +++ b/Intersect.Editor/Forms/DockingElements/frmMapLayers.cs @@ -14,7 +14,6 @@ using WeifenLuo.WinFormsUI.Docking; using Graphics = System.Drawing.Graphics; -using MapAttribute = Intersect.Enums.MapAttribute; namespace Intersect.Editor.Forms.DockingElements; @@ -576,112 +575,112 @@ public int GetAttributeFromEditor() { if (rbBlocked.Checked == true) { - return (int) MapAttribute.Blocked; + return (int) MapAttributeType.Blocked; } else if (rbItem.Checked == true) { - return (int) MapAttribute.Item; + return (int) MapAttributeType.Item; } else if (rbZDimension.Checked == true) { - return (int) MapAttribute.ZDimension; + return (int) MapAttributeType.ZDimension; } else if (rbNPCAvoid.Checked == true) { - return (int) MapAttribute.NpcAvoid; + return (int) MapAttributeType.NpcAvoid; } else if (rbWarp.Checked == true) { - return (int) MapAttribute.Warp; + return (int) MapAttributeType.Warp; } else if (rbSound.Checked == true) { - return (int) MapAttribute.Sound; + return (int) MapAttributeType.Sound; } else if (rbResource.Checked == true) { - return (int) MapAttribute.Resource; + return (int) MapAttributeType.Resource; } else if (rbAnimation.Checked == true) { - return (int) MapAttribute.Animation; + return (int) MapAttributeType.Animation; } else if (rbGrappleStone.Checked == true) { - return (int) MapAttribute.GrappleStone; + return (int) MapAttributeType.GrappleStone; } else if (rbSlide.Checked == true) { - return (int) MapAttribute.Slide; + return (int) MapAttributeType.Slide; } else if (rbCritter.Checked == true) { - return (int) MapAttribute.Critter; + return (int) MapAttributeType.Critter; } - return (int) MapAttribute.Walkable; + return (int) MapAttributeType.Walkable; } - private MapAttribute SelectedMapAttributeType + private MapAttributeType SelectedMapAttributeType { get { if (rbBlocked.Checked) { - return MapAttribute.Blocked; + return MapAttributeType.Blocked; } if (rbItem.Checked) { - return MapAttribute.Item; + return MapAttributeType.Item; } if (rbZDimension.Checked) { - return MapAttribute.ZDimension; + return MapAttributeType.ZDimension; } if (rbNPCAvoid.Checked) { - return MapAttribute.NpcAvoid; + return MapAttributeType.NpcAvoid; } if (rbWarp.Checked) { - return MapAttribute.Warp; + return MapAttributeType.Warp; } if (rbSound.Checked) { - return MapAttribute.Sound; + return MapAttributeType.Sound; } if (rbResource.Checked) { - return MapAttribute.Resource; + return MapAttributeType.Resource; } if (rbAnimation.Checked) { - return MapAttribute.Animation; + return MapAttributeType.Animation; } if (rbGrappleStone.Checked) { - return MapAttribute.GrappleStone; + return MapAttributeType.GrappleStone; } if (rbSlide.Checked) { - return MapAttribute.Slide; + return MapAttributeType.Slide; } if (rbCritter.Checked) { - return MapAttribute.Critter; + return MapAttributeType.Critter; } - return (MapAttribute) byte.MaxValue; + return (MapAttributeType) byte.MaxValue; } } @@ -692,26 +691,26 @@ public GameObjects.Maps.MapAttribute CreateAttribute() var attribute = GameObjects.Maps.MapAttribute.CreateAttribute(attributeType); switch (SelectedMapAttributeType) { - case MapAttribute.Walkable: - case MapAttribute.Blocked: - case MapAttribute.GrappleStone: - case MapAttribute.NpcAvoid: + case MapAttributeType.Walkable: + case MapAttributeType.Blocked: + case MapAttributeType.GrappleStone: + case MapAttributeType.NpcAvoid: break; - case MapAttribute.Item: + case MapAttributeType.Item: var itemAttribute = attribute as MapItemAttribute; itemAttribute.ItemId = ItemBase.IdFromList(cmbItemAttribute.SelectedIndex); itemAttribute.Quantity = (int)nudItemQuantity.Value; itemAttribute.RespawnTime = (long)nudItemRespawnTime.Value; break; - case MapAttribute.ZDimension: + case MapAttributeType.ZDimension: var zDimensionAttribute = attribute as MapZDimensionAttribute; zDimensionAttribute.GatewayTo = GetEditorDimensionGateway(); zDimensionAttribute.BlockedLevel = GetEditorDimensionBlock(); break; - case MapAttribute.Warp: + case MapAttributeType.Warp: var warpAttribute = attribute as MapWarpAttribute; warpAttribute.MapId = MapList.OrderedMaps[cmbWarpMap.SelectedIndex].MapId; warpAttribute.X = (byte)nudWarpX.Value; @@ -722,31 +721,31 @@ public GameObjects.Maps.MapAttribute CreateAttribute() warpAttribute.WarpSound = TextUtils.SanitizeNone(cmbWarpSound.Text); break; - case MapAttribute.Sound: + case MapAttributeType.Sound: var soundAttribute = attribute as MapSoundAttribute; soundAttribute.Distance = (byte)nudSoundDistance.Value; soundAttribute.File = TextUtils.SanitizeNone(cmbMapAttributeSound.Text); soundAttribute.LoopInterval = (int)nudSoundLoopInterval.Value; break; - case MapAttribute.Resource: + case MapAttributeType.Resource: var resourceAttribute = attribute as MapResourceAttribute; resourceAttribute.ResourceId = ResourceBase.IdFromList(cmbResourceAttribute.SelectedIndex); resourceAttribute.SpawnLevel = (byte)(rbLevel1.Checked ? 0 : 1); break; - case MapAttribute.Animation: + case MapAttributeType.Animation: var animationAttribute = attribute as MapAnimationAttribute; animationAttribute.AnimationId = AnimationBase.IdFromList(cmbAnimationAttribute.SelectedIndex); animationAttribute.IsBlock = chkAnimationBlock.Checked; break; - case MapAttribute.Slide: + case MapAttributeType.Slide: var slideAttribute = attribute as MapSlideAttribute; slideAttribute.Direction = (Direction)cmbSlideDir.SelectedIndex; break; - case MapAttribute.Critter: + case MapAttributeType.Critter: var critterAttribute = attribute as MapCritterAttribute; critterAttribute.Sprite = cmbCritterSprite.Text; critterAttribute.AnimationId = AnimationBase.IdFromList(cmbCritterAnimation.SelectedIndex - 1); @@ -780,7 +779,7 @@ public GameObjects.Maps.MapAttribute PlaceAttribute(MapBase mapDescriptor, int x public bool RemoveAttribute(MapBase tmpMap, int x, int y) { - if (tmpMap.Attributes[x, y] != null && tmpMap.Attributes[x, y].Type != MapAttribute.Walkable) + if (tmpMap.Attributes[x, y] != null && tmpMap.Attributes[x, y].Type != MapAttributeType.Walkable) { tmpMap.Attributes[x, y] = null; diff --git a/Intersect.Editor/Forms/Editors/Events/CommandPrinter.cs b/Intersect.Editor/Forms/Editors/Events/CommandPrinter.cs index bff30bf143..7cbd7133cf 100644 --- a/Intersect.Editor/Forms/Editors/Events/CommandPrinter.cs +++ b/Intersect.Editor/Forms/Editors/Events/CommandPrinter.cs @@ -1414,82 +1414,82 @@ private static string GetVariableModText(SetVariableCommand command, IntegerVari var varvalue = ""; switch (mod.ModType) { - case Enums.VariableMod.Set: + case VariableModType.Set: varvalue = Strings.EventCommandList.setvariable.ToString(mod.Value); break; - case Enums.VariableMod.Add: + case VariableModType.Add: varvalue = Strings.EventCommandList.addvariable.ToString(mod.Value); break; - case Enums.VariableMod.Subtract: + case VariableModType.Subtract: varvalue = Strings.EventCommandList.subtractvariable.ToString(mod.Value); break; - case Enums.VariableMod.Multiply: + case VariableModType.Multiply: varvalue = Strings.EventCommandList.multiplyvariable.ToString(mod.Value); break; - case Enums.VariableMod.Divide: + case VariableModType.Divide: varvalue = Strings.EventCommandList.dividevariable.ToString(mod.Value); break; - case Enums.VariableMod.LeftShift: + case VariableModType.LeftShift: varvalue = Strings.EventCommandList.leftshiftvariable.ToString(mod.Value); break; - case Enums.VariableMod.RightShift: + case VariableModType.RightShift: varvalue = Strings.EventCommandList.rightshiftvariable.ToString(mod.Value); break; - case Enums.VariableMod.Random: + case VariableModType.Random: varvalue = Strings.EventCommandList.randvariable.ToString(mod.Value, mod.HighValue); break; - case Enums.VariableMod.SystemTime: + case VariableModType.SystemTime: varvalue = Strings.EventCommandList.systemtimevariable; break; //Player Variable - case Enums.VariableMod.DupPlayerVar: + case VariableModType.DupPlayerVar: varvalue = Strings.EventCommandList.dupplayervariable.ToString( PlayerVariableBase.GetName(mod.DuplicateVariableId) ); break; - case Enums.VariableMod.AddPlayerVar: + case VariableModType.AddPlayerVar: varvalue = Strings.EventCommandList.addplayervariable.ToString( PlayerVariableBase.GetName(mod.DuplicateVariableId) ); break; - case Enums.VariableMod.SubtractPlayerVar: + case VariableModType.SubtractPlayerVar: varvalue = Strings.EventCommandList.subtractplayervariable.ToString( PlayerVariableBase.GetName(mod.DuplicateVariableId) ); break; - case Enums.VariableMod.MultiplyPlayerVar: + case VariableModType.MultiplyPlayerVar: varvalue = Strings.EventCommandList.multiplyplayervariable.ToString( PlayerVariableBase.GetName(mod.DuplicateVariableId) ); break; - case Enums.VariableMod.DividePlayerVar: + case VariableModType.DividePlayerVar: varvalue = Strings.EventCommandList.divideplayervariable.ToString( PlayerVariableBase.GetName(mod.DuplicateVariableId) ); break; - case Enums.VariableMod.LeftShiftPlayerVar: + case VariableModType.LeftShiftPlayerVar: varvalue = Strings.EventCommandList.leftshiftplayervariable.ToString( PlayerVariableBase.GetName(mod.DuplicateVariableId) ); break; - case Enums.VariableMod.RightShiftPlayerVar: + case VariableModType.RightShiftPlayerVar: varvalue = Strings.EventCommandList.rightshiftplayervariable.ToString( PlayerVariableBase.GetName(mod.DuplicateVariableId) ); @@ -1498,43 +1498,43 @@ private static string GetVariableModText(SetVariableCommand command, IntegerVari //Global Variable - case Enums.VariableMod.DupGlobalVar: + case VariableModType.DupGlobalVar: varvalue = Strings.EventCommandList.dupglobalvariable.ToString( ServerVariableBase.GetName(mod.DuplicateVariableId) ); break; - case Enums.VariableMod.AddGlobalVar: + case VariableModType.AddGlobalVar: varvalue = Strings.EventCommandList.addglobalvariable.ToString( ServerVariableBase.GetName(mod.DuplicateVariableId) ); break; - case Enums.VariableMod.SubtractGlobalVar: + case VariableModType.SubtractGlobalVar: varvalue = Strings.EventCommandList.subtractglobalvariable.ToString( ServerVariableBase.GetName(mod.DuplicateVariableId) ); break; - case Enums.VariableMod.MultiplyGlobalVar: + case VariableModType.MultiplyGlobalVar: varvalue = Strings.EventCommandList.multiplyglobalvariable.ToString( ServerVariableBase.GetName(mod.DuplicateVariableId) ); break; - case Enums.VariableMod.DivideGlobalVar: + case VariableModType.DivideGlobalVar: varvalue = Strings.EventCommandList.divideglobalvariable.ToString( ServerVariableBase.GetName(mod.DuplicateVariableId) ); break; - case Enums.VariableMod.LeftShiftGlobalVar: + case VariableModType.LeftShiftGlobalVar: varvalue = Strings.EventCommandList.leftshiftglobalvariable.ToString( ServerVariableBase.GetName(mod.DuplicateVariableId) ); break; - case Enums.VariableMod.RightShiftGlobalVar: + case VariableModType.RightShiftGlobalVar: varvalue = Strings.EventCommandList.rightshiftglobalvariable.ToString( ServerVariableBase.GetName(mod.DuplicateVariableId) ); @@ -1543,43 +1543,43 @@ private static string GetVariableModText(SetVariableCommand command, IntegerVari //Guilds Variable - case Enums.VariableMod.DupGuildVar: + case VariableModType.DupGuildVar: varvalue = Strings.EventCommandList.dupguildvariable.ToString( GuildVariableBase.GetName(mod.DuplicateVariableId) ); break; - case Enums.VariableMod.AddGuildVar: + case VariableModType.AddGuildVar: varvalue = Strings.EventCommandList.addguildvariable.ToString( GuildVariableBase.GetName(mod.DuplicateVariableId) ); break; - case Enums.VariableMod.SubtractGuildVar: + case VariableModType.SubtractGuildVar: varvalue = Strings.EventCommandList.subtractguildvariable.ToString( GuildVariableBase.GetName(mod.DuplicateVariableId) ); break; - case Enums.VariableMod.MultiplyGuildVar: + case VariableModType.MultiplyGuildVar: varvalue = Strings.EventCommandList.multiplyguildvariable.ToString( GuildVariableBase.GetName(mod.DuplicateVariableId) ); break; - case Enums.VariableMod.DivideGuildVar: + case VariableModType.DivideGuildVar: varvalue = Strings.EventCommandList.divideguildvariable.ToString( GuildVariableBase.GetName(mod.DuplicateVariableId) ); break; - case Enums.VariableMod.LeftShiftGuildVar: + case VariableModType.LeftShiftGuildVar: varvalue = Strings.EventCommandList.leftshiftguildvariable.ToString( GuildVariableBase.GetName(mod.DuplicateVariableId) ); break; - case Enums.VariableMod.RightShiftGuildVar: + case VariableModType.RightShiftGuildVar: varvalue = Strings.EventCommandList.rightshiftguildvariable.ToString( GuildVariableBase.GetName(mod.DuplicateVariableId) ); @@ -1588,49 +1588,49 @@ private static string GetVariableModText(SetVariableCommand command, IntegerVari //User Variable - case Enums.VariableMod.DuplicateUserVariable: + case VariableModType.DuplicateUserVariable: varvalue = Strings.EventCommandList.DupUserVariable.ToString( Strings.GameObjectStrings.UserVariable, UserVariableBase.GetName(mod.DuplicateVariableId) ); break; - case Enums.VariableMod.AddUserVariable: + case VariableModType.AddUserVariable: varvalue = Strings.EventCommandList.AddUserVariable.ToString( Strings.GameObjectStrings.UserVariable, UserVariableBase.GetName(mod.DuplicateVariableId) ); break; - case Enums.VariableMod.SubtractUserVariable: + case VariableModType.SubtractUserVariable: varvalue = Strings.EventCommandList.SubtractUserVariable.ToString( Strings.GameObjectStrings.UserVariable, UserVariableBase.GetName(mod.DuplicateVariableId) ); break; - case Enums.VariableMod.MultiplyUserVariable: + case VariableModType.MultiplyUserVariable: varvalue = Strings.EventCommandList.MultiplyUserVariable.ToString( Strings.GameObjectStrings.UserVariable, UserVariableBase.GetName(mod.DuplicateVariableId) ); break; - case Enums.VariableMod.DivideUserVariable: + case VariableModType.DivideUserVariable: varvalue = Strings.EventCommandList.DivideUserVariable.ToString( Strings.GameObjectStrings.UserVariable, UserVariableBase.GetName(mod.DuplicateVariableId) ); break; - case Enums.VariableMod.LeftShiftUserVariable: + case VariableModType.LeftShiftUserVariable: varvalue = Strings.EventCommandList.LeftShiftUserVariable.ToString( Strings.GameObjectStrings.UserVariable, UserVariableBase.GetName(mod.DuplicateVariableId) ); break; - case Enums.VariableMod.RightShiftUserVariable: + case VariableModType.RightShiftUserVariable: varvalue = Strings.EventCommandList.RightShiftUserVariable.ToString( Strings.GameObjectStrings.UserVariable, UserVariableBase.GetName(mod.DuplicateVariableId) @@ -1677,11 +1677,11 @@ private static string GetVariableModText(SetVariableCommand command, StringVaria var varvalue = ""; switch (mod.ModType) { - case Enums.VariableMod.Set: + case VariableModType.Set: varvalue = Strings.EventCommandList.setvariable.ToString(mod.Value); break; - case Enums.VariableMod.Replace: + case VariableModType.Replace: varvalue = Strings.EventCommandList.replace.ToString(mod.Value, mod.Replace); break; diff --git a/Intersect.Editor/Forms/Editors/Events/Event Commands/EventCommand_Variable.cs b/Intersect.Editor/Forms/Editors/Events/Event Commands/EventCommand_Variable.cs index 10e6419bbd..2972c2cee9 100644 --- a/Intersect.Editor/Forms/Editors/Events/Event Commands/EventCommand_Variable.cs +++ b/Intersect.Editor/Forms/Editors/Events/Event Commands/EventCommand_Variable.cs @@ -5,7 +5,6 @@ using Intersect.GameObjects.Events; using Intersect.GameObjects.Events.Commands; using Intersect.Utilities; -using VariableMod = Intersect.Enums.VariableMod; namespace Intersect.Editor.Forms.Editors.Events.Event_Commands; @@ -263,15 +262,15 @@ private void TryLoadNumericMod(GameObjects.Events.VariableMod variableMod) switch (integerMod.ModType) { - case VariableMod.Set: - case VariableMod.Add: - case VariableMod.Subtract: - case VariableMod.Multiply: - case VariableMod.Divide: - case VariableMod.LeftShift: - case VariableMod.RightShift: - case VariableMod.Random: - case VariableMod.SystemTime: + case VariableModType.Set: + case VariableModType.Add: + case VariableModType.Subtract: + case VariableModType.Multiply: + case VariableModType.Divide: + case VariableModType.LeftShift: + case VariableModType.RightShift: + case VariableModType.Random: + case VariableModType.SystemTime: nudNumericValue.Value = integerMod.Value; ResetSettingVariableSelection(); break; @@ -291,9 +290,9 @@ private void TryLoadNumericMod(GameObjects.Events.VariableMod variableMod) optNumericLeftShift.Checked = VariableModUtils.LShiftMods.Contains(integerMod.ModType); optNumericRightShift.Checked = VariableModUtils.RShiftMods.Contains(integerMod.ModType); - optNumericSystemTime.Checked = integerMod.ModType == VariableMod.SystemTime; + optNumericSystemTime.Checked = integerMod.ModType == VariableModType.SystemTime; - if (integerMod.ModType == VariableMod.Random) + if (integerMod.ModType == VariableModType.Random) { optNumericRandom.Checked = true; nudLow.Value = integerMod.Value; @@ -366,35 +365,35 @@ private IntegerVariableMod GetNumericVariableMod() if (optNumericSet.Checked && optNumericStaticVal.Checked) { - mod.ModType = VariableMod.Set; + mod.ModType = VariableModType.Set; } else if (optNumericAdd.Checked && optNumericStaticVal.Checked) { - mod.ModType = VariableMod.Add; + mod.ModType = VariableModType.Add; } else if (optNumericSubtract.Checked && optNumericStaticVal.Checked) { - mod.ModType = VariableMod.Subtract; + mod.ModType = VariableModType.Subtract; } else if (optNumericMultiply.Checked && optNumericStaticVal.Checked) { - mod.ModType = VariableMod.Multiply; + mod.ModType = VariableModType.Multiply; } else if (optNumericDivide.Checked && optNumericStaticVal.Checked) { - mod.ModType = VariableMod.Divide; + mod.ModType = VariableModType.Divide; } else if (optNumericLeftShift.Checked && optNumericStaticVal.Checked) { - mod.ModType = VariableMod.LeftShift; + mod.ModType = VariableModType.LeftShift; } else if (optNumericRightShift.Checked && optNumericStaticVal.Checked) { - mod.ModType = VariableMod.RightShift; + mod.ModType = VariableModType.RightShift; } else if (optNumericRandom.Checked) { - mod.ModType = VariableMod.Random; + mod.ModType = VariableModType.Random; mod.HighValue = (int)nudHigh.Value; if (mod.HighValue < mod.Value) { @@ -405,130 +404,130 @@ private IntegerVariableMod GetNumericVariableMod() } else if (optNumericSystemTime.Checked) { - mod.ModType = VariableMod.SystemTime; + mod.ModType = VariableModType.SystemTime; } else if (mSettingVariableType == VariableType.PlayerVariable) { if (optNumericSet.Checked) { - mod.ModType = VariableMod.DupPlayerVar; + mod.ModType = VariableModType.DupPlayerVar; } else if (optNumericAdd.Checked) { - mod.ModType = VariableMod.AddPlayerVar; + mod.ModType = VariableModType.AddPlayerVar; } else if (optNumericSubtract.Checked) { - mod.ModType = VariableMod.SubtractPlayerVar; + mod.ModType = VariableModType.SubtractPlayerVar; } else if (optNumericMultiply.Checked) { - mod.ModType = VariableMod.MultiplyPlayerVar; + mod.ModType = VariableModType.MultiplyPlayerVar; } else if (optNumericDivide.Checked) { - mod.ModType = VariableMod.DividePlayerVar; + mod.ModType = VariableModType.DividePlayerVar; } else if (optNumericLeftShift.Checked) { - mod.ModType = VariableMod.LeftShiftPlayerVar; + mod.ModType = VariableModType.LeftShiftPlayerVar; } else { - mod.ModType = VariableMod.RightShiftPlayerVar; + mod.ModType = VariableModType.RightShiftPlayerVar; } } else if (mSettingVariableType == VariableType.ServerVariable) { if (optNumericSet.Checked) { - mod.ModType = VariableMod.DupGlobalVar; + mod.ModType = VariableModType.DupGlobalVar; } else if (optNumericAdd.Checked) { - mod.ModType = VariableMod.AddGlobalVar; + mod.ModType = VariableModType.AddGlobalVar; } else if (optNumericSubtract.Checked) { - mod.ModType = VariableMod.SubtractGlobalVar; + mod.ModType = VariableModType.SubtractGlobalVar; } else if (optNumericMultiply.Checked) { - mod.ModType = VariableMod.MultiplyGlobalVar; + mod.ModType = VariableModType.MultiplyGlobalVar; } else if (optNumericDivide.Checked) { - mod.ModType = VariableMod.DivideGlobalVar; + mod.ModType = VariableModType.DivideGlobalVar; } else if (optNumericLeftShift.Checked) { - mod.ModType = VariableMod.LeftShiftGlobalVar; + mod.ModType = VariableModType.LeftShiftGlobalVar; } else { - mod.ModType = VariableMod.RightShiftGlobalVar; + mod.ModType = VariableModType.RightShiftGlobalVar; } } else if (mSettingVariableType == VariableType.GuildVariable) { if (optNumericSet.Checked) { - mod.ModType = VariableMod.DupGuildVar; + mod.ModType = VariableModType.DupGuildVar; } else if (optNumericAdd.Checked) { - mod.ModType = VariableMod.AddGuildVar; + mod.ModType = VariableModType.AddGuildVar; } else if (optNumericSubtract.Checked) { - mod.ModType = VariableMod.SubtractGuildVar; + mod.ModType = VariableModType.SubtractGuildVar; } else if (optNumericMultiply.Checked) { - mod.ModType = VariableMod.MultiplyGuildVar; + mod.ModType = VariableModType.MultiplyGuildVar; } else if (optNumericDivide.Checked) { - mod.ModType = VariableMod.DivideGuildVar; + mod.ModType = VariableModType.DivideGuildVar; } else if (optNumericLeftShift.Checked) { - mod.ModType = VariableMod.LeftShiftGuildVar; + mod.ModType = VariableModType.LeftShiftGuildVar; } else { - mod.ModType = VariableMod.RightShiftGuildVar; + mod.ModType = VariableModType.RightShiftGuildVar; } } else if (mSettingVariableType == VariableType.UserVariable) { if (optNumericSet.Checked) { - mod.ModType = VariableMod.DuplicateUserVariable; + mod.ModType = VariableModType.DuplicateUserVariable; } else if (optNumericAdd.Checked) { - mod.ModType = VariableMod.AddUserVariable; + mod.ModType = VariableModType.AddUserVariable; } else if (optNumericSubtract.Checked) { - mod.ModType = VariableMod.SubtractUserVariable; + mod.ModType = VariableModType.SubtractUserVariable; } else if (optNumericMultiply.Checked) { - mod.ModType = VariableMod.MultiplyUserVariable; + mod.ModType = VariableModType.MultiplyUserVariable; } else if (optNumericDivide.Checked) { - mod.ModType = VariableMod.DivideUserVariable; + mod.ModType = VariableModType.DivideUserVariable; } else if (optNumericLeftShift.Checked) { - mod.ModType = VariableMod.LeftShiftUserVariable; + mod.ModType = VariableModType.LeftShiftUserVariable; } else { - mod.ModType = VariableMod.RightShiftUserVariable; + mod.ModType = VariableModType.RightShiftUserVariable; } } @@ -550,12 +549,12 @@ private void TryLoadStringMod(GameObjects.Events.VariableMod variableMod) { switch (stringMod.ModType) { - case VariableMod.Set: + case VariableModType.Set: optStaticString.Checked = true; txtStringValue.Text = stringMod.Value; break; - case VariableMod.Replace: + case VariableModType.Replace: optReplaceString.Checked = true; txtStringFind.Text = stringMod.Value; txtStringReplace.Text = stringMod.Replace; @@ -572,12 +571,12 @@ private StringVariableMod GetStringVariableMod() var mod = new StringVariableMod(); if (optStaticString.Checked) { - mod.ModType = VariableMod.Set; + mod.ModType = VariableModType.Set; mod.Value = txtStringValue.Text; } else if (optReplaceString.Checked) { - mod.ModType = VariableMod.Replace; + mod.ModType = VariableModType.Replace; mod.Value = txtStringFind.Text; mod.Replace = txtStringReplace.Text; } diff --git a/Intersect.Editor/Localization/Strings.cs b/Intersect.Editor/Localization/Strings.cs index 7d47bc0f2a..af2765dcc5 100644 --- a/Intersect.Editor/Localization/Strings.cs +++ b/Intersect.Editor/Localization/Strings.cs @@ -848,18 +848,18 @@ public partial struct Attributes { public static Dictionary AttributeTypes = new Dictionary { - {(int) MapAttribute.Animation, @"Map Animation" }, - {(int) MapAttribute.Blocked, @"Blocked" }, - {(int) MapAttribute.Critter, @"Critter" }, - {(int) MapAttribute.GrappleStone, @"Grapple Stone" }, - {(int) MapAttribute.Item, @"Item Spawn" }, - {(int) MapAttribute.NpcAvoid, @"Npc Avoid" }, - {(int) MapAttribute.Resource, @"Resource Spawn" }, - {(int) MapAttribute.Slide, @"Slide" }, - {(int) MapAttribute.Sound, @"Map Sound" }, - {(int) MapAttribute.Walkable, @"Walkable" }, - {(int) MapAttribute.Warp, @"Warp" }, - {(int) MapAttribute.ZDimension, @"Z-Dimension" }, + {(int) MapAttributeType.Animation, @"Map Animation" }, + {(int) MapAttributeType.Blocked, @"Blocked" }, + {(int) MapAttributeType.Critter, @"Critter" }, + {(int) MapAttributeType.GrappleStone, @"Grapple Stone" }, + {(int) MapAttributeType.Item, @"Item Spawn" }, + {(int) MapAttributeType.NpcAvoid, @"Npc Avoid" }, + {(int) MapAttributeType.Resource, @"Resource Spawn" }, + {(int) MapAttributeType.Slide, @"Slide" }, + {(int) MapAttributeType.Sound, @"Map Sound" }, + {(int) MapAttributeType.Walkable, @"Walkable" }, + {(int) MapAttributeType.Warp, @"Warp" }, + {(int) MapAttributeType.ZDimension, @"Z-Dimension" }, }; public static string FormatSpawnLevel(int level) diff --git a/Intersect.Editor/Networking/Network.cs b/Intersect.Editor/Networking/Network.cs index 29adab00a5..c81416d3d0 100644 --- a/Intersect.Editor/Networking/Network.cs +++ b/Intersect.Editor/Networking/Network.cs @@ -36,7 +36,7 @@ public VirtualApplicationContext(IPacketHelper packetHelper) public ICommandLineOptions StartupOptions => throw new NotImplementedException(); - public Logger Logger => throw new NotImplementedException(); + public ILogger Logger => throw new NotImplementedException(); public IPacketHelper PacketHelper { get; } @@ -57,7 +57,7 @@ public void Start(bool lockUntilShutdown = true) throw new NotImplementedException(); } - public LockingActionQueue StartWithActionQueue() + public ILockingActionQueue StartWithActionQueue() { throw new NotImplementedException(); } @@ -91,7 +91,7 @@ public static void InitNetwork() if (EditorLidgrenNetwork == null) { var logger = Log.Default; - var packetTypeRegistry = new PacketTypeRegistry(logger); + var packetTypeRegistry = new PacketTypeRegistry(logger, typeof(SharedConstants).Assembly); if (!packetTypeRegistry.TryRegisterBuiltIn()) { throw new Exception("Failed to register built-in packets."); @@ -294,7 +294,7 @@ internal VirtualEditorContext(PacketHelper packetHelper, Logger logger) public ICommandLineOptions StartupOptions => default; - public Logger Logger { get; } + public ILogger Logger { get; } public List Services { get; } = new List(); @@ -306,5 +306,5 @@ internal VirtualEditorContext(PacketHelper packetHelper, Logger logger) public void Start(bool lockUntilShutdown = true) { } - public LockingActionQueue StartWithActionQueue() => default; + public ILockingActionQueue StartWithActionQueue() => default; } diff --git a/Intersect.Network/LiteNetLib/LiteNetLibConnection.cs b/Intersect.Network/LiteNetLib/LiteNetLibConnection.cs index bb97aba2c8..78c77c8655 100644 --- a/Intersect.Network/LiteNetLib/LiteNetLibConnection.cs +++ b/Intersect.Network/LiteNetLib/LiteNetLibConnection.cs @@ -1,6 +1,7 @@ using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Security.Cryptography; +using Intersect.Framework.Reflection; using Intersect.Logging; using Intersect.Memory; using Intersect.Network.Packets; diff --git a/Intersect.Network/LiteNetLib/LiteNetLibInterface.cs b/Intersect.Network/LiteNetLib/LiteNetLibInterface.cs index 6b2ae294fe..ca9698d9df 100644 --- a/Intersect.Network/LiteNetLib/LiteNetLibInterface.cs +++ b/Intersect.Network/LiteNetLib/LiteNetLibInterface.cs @@ -4,6 +4,7 @@ using System.Net.Sockets; using System.Security.Cryptography; using System.Text; +using Intersect.Framework.Reflection; using Intersect.Logging; using Intersect.Memory; using Intersect.Network.Events; diff --git a/Intersect.Server.Core/Core/Bootstrapper.cs b/Intersect.Server.Core/Core/Bootstrapper.cs index 721c62415c..b5694d63af 100644 --- a/Intersect.Server.Core/Core/Bootstrapper.cs +++ b/Intersect.Server.Core/Core/Bootstrapper.cs @@ -35,7 +35,7 @@ static Bootstrapper() public static IServerContext Context { get; private set; } - public static LockingActionQueue MainThread { get; private set; } + public static ILockingActionQueue MainThread { get; private set; } public static void Start(params string[] args) { @@ -59,7 +59,7 @@ public static void Start(params string[] args) Console.WriteLine("Pre-context setup finished."); var logger = Log.Default; - var packetTypeRegistry = new PacketTypeRegistry(logger); + var packetTypeRegistry = new PacketTypeRegistry(logger, typeof(SharedConstants).Assembly); if (!packetTypeRegistry.TryRegisterBuiltIn()) { logger.Error("[FATAL] Failed to load built-in packet types."); @@ -73,7 +73,7 @@ public static void Start(params string[] args) FactoryRegistry.RegisterFactory( PluginBootstrapContext.CreateFactory( - parsedArguments.Args ?? Array.Empty(), + parsedArguments.Args ?? [], parsedArguments.Parser, packetHelper ) @@ -81,11 +81,14 @@ public static void Start(params string[] args) Console.WriteLine("Creating server context..."); - Context = ServerContext.ServerContextFactory.Invoke( + var context = ServerContext.ServerContextFactory.Invoke( parsedArguments.CommandLineOptions, logger, packetHelper ); + + Context = context; + var noHaltOnError = Context?.StartupOptions.DoNotHaltOnError ?? false; if (!PostContextSetup()) @@ -99,9 +102,8 @@ public static void Start(params string[] args) Console.WriteLine("Finished post-context setup."); Console.WriteLine("Starting main thread..."); - MainThread = Context.StartWithActionQueue(); - Action action; - while (null != (action = MainThread.NextAction)) + MainThread = context.StartWithActionQueue(); + while (MainThread.NextAction is { } action) { action.Invoke(); } @@ -110,7 +112,8 @@ public static void Start(params string[] args) // At this point dbs should be saved and all threads should be killed. Give a message saying that the server has shutdown and to press any key to exit. // Having the message and the console.readline() allows the server to exit properly if the console has crashed, and it allows us to know that the server context has shutdown. - if (Context.HasErrors) + // ReSharper disable once InvertIf + if (context.HasErrors) { if (noHaltOnError) { @@ -187,6 +190,8 @@ private static bool PreContextSetup(params string[] args) return false; } + Log.Default.Configuration.LogLevel = Options.Instance.Logging.Level; + if (ServerContext.IsDefaultResourceDirectory) { if (!Directory.Exists(Path.Combine(ServerContext.ResourceDirectory, "notifications"))) diff --git a/Intersect.Server.Core/Database/GameData/Migrations/Beta6Migration.cs b/Intersect.Server.Core/Database/GameData/Migrations/Beta6Migration.cs index 0564464de0..538f1ad257 100644 --- a/Intersect.Server.Core/Database/GameData/Migrations/Beta6Migration.cs +++ b/Intersect.Server.Core/Database/GameData/Migrations/Beta6Migration.cs @@ -1,6 +1,7 @@ using System.IO.Compression; using Intersect.Enums; +using Intersect.Framework.Core.Serialization; using Intersect.GameObjects.Events; using Intersect.GameObjects.Events.Commands; using Microsoft.Data.Sqlite; @@ -11,7 +12,6 @@ using Newtonsoft.Json; using Newtonsoft.Json.Linq; using MapAttribute = Intersect.GameObjects.Maps.MapAttribute; -using VariableMod = Intersect.Enums.VariableMod; namespace Intersect.Server.Database.GameData.Migrations; @@ -21,6 +21,14 @@ public static partial class Beta6Migration private static Intersect.Network.Ceras mCeras; + private static readonly JsonSerializerSettings JsonSerializerSettings = new() + { + Formatting = Formatting.None, TypeNameHandling = TypeNameHandling.Auto, + DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate, + ObjectCreationHandling = ObjectCreationHandling.Replace, + SerializationBinder = new IntersectTypeSerializationBinder(), + }; + public static void Run(GameContext context) { var nameTypeDict = new Dictionary(); @@ -269,12 +277,7 @@ private static JObject ConvertSetSwitchCommand(JObject obj) var newJson = JsonConvert.SerializeObject( cmd, typeof(EventCommand), - new JsonSerializerSettings() - { - Formatting = Formatting.None, TypeNameHandling = TypeNameHandling.Auto, - DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate, - ObjectCreationHandling = ObjectCreationHandling.Replace - } + JsonSerializerSettings ); return JObject.Parse(newJson); @@ -336,17 +339,12 @@ private static JObject ConvertSetVariableCommand(JObject obj) if (obj.ContainsKey("ModType")) { - mod.ModType = (VariableMod) int.Parse(obj["ModType"].ToString()); + mod.ModType = (VariableModType) int.Parse(obj["ModType"].ToString()); } var newJson = JsonConvert.SerializeObject( cmd, typeof(EventCommand), - new JsonSerializerSettings() - { - Formatting = Formatting.None, TypeNameHandling = TypeNameHandling.Auto, - DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate, - ObjectCreationHandling = ObjectCreationHandling.Replace - } + JsonSerializerSettings ); return JObject.Parse(newJson); @@ -383,12 +381,7 @@ private static JObject ConvertPlayerSwitchCondition(JObject obj) var newJson = JsonConvert.SerializeObject( cmd, typeof(Condition), - new JsonSerializerSettings() - { - Formatting = Formatting.None, TypeNameHandling = TypeNameHandling.Auto, - DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate, - ObjectCreationHandling = ObjectCreationHandling.Replace - } + JsonSerializerSettings ); return JObject.Parse(newJson); @@ -425,12 +418,7 @@ private static JObject ConvertGlobalSwitchCondition(JObject obj) var newJson = JsonConvert.SerializeObject( cmd, typeof(Condition), - new JsonSerializerSettings() - { - Formatting = Formatting.None, TypeNameHandling = TypeNameHandling.Auto, - DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate, - ObjectCreationHandling = ObjectCreationHandling.Replace - } + JsonSerializerSettings ); return JObject.Parse(newJson); @@ -494,12 +482,7 @@ private static JObject ConvertPlayerVariableCondition(JObject obj) var newJson = JsonConvert.SerializeObject( cmd, typeof(Condition), - new JsonSerializerSettings() - { - Formatting = Formatting.None, TypeNameHandling = TypeNameHandling.Auto, - DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate, - ObjectCreationHandling = ObjectCreationHandling.Replace - } + JsonSerializerSettings ); return JObject.Parse(newJson); @@ -563,12 +546,7 @@ private static JObject ConvertGlobalVariableCondition(JObject obj) var newJson = JsonConvert.SerializeObject( cmd, typeof(Condition), - new JsonSerializerSettings() - { - Formatting = Formatting.None, TypeNameHandling = TypeNameHandling.Auto, - DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate, - ObjectCreationHandling = ObjectCreationHandling.Replace - } + JsonSerializerSettings ); return JObject.Parse(newJson); diff --git a/Intersect.Server.Core/Database/GameData/Migrations/CerasVersionToleranceMigration.cs b/Intersect.Server.Core/Database/GameData/Migrations/CerasVersionToleranceMigration.cs index 9a8525283e..c9c1831b1f 100644 --- a/Intersect.Server.Core/Database/GameData/Migrations/CerasVersionToleranceMigration.cs +++ b/Intersect.Server.Core/Database/GameData/Migrations/CerasVersionToleranceMigration.cs @@ -1,12 +1,12 @@ using Intersect.Compression; using Intersect.Enums; +using Intersect.Framework.Core.Serialization; using Intersect.GameObjects.Maps; using Intersect.Network; using Microsoft.Data.Sqlite; using Microsoft.EntityFrameworkCore; using MySqlConnector; using Newtonsoft.Json; -using MapAttribute = Intersect.Enums.MapAttribute; namespace Intersect.Server.Database.GameData.Migrations; @@ -14,6 +14,7 @@ public partial class CerasVersionToleranceMigration { private static JsonSerializerSettings mJsonSerializerSettings = new JsonSerializerSettings() { + SerializationBinder = new IntersectTypeSerializationBinder(), TypeNameHandling = TypeNameHandling.Auto, DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate, ObjectCreationHandling = ObjectCreationHandling.Replace @@ -192,33 +193,33 @@ private partial struct LegacyTile private abstract partial class LegacyMapAttribute { - public abstract MapAttribute Type { get; } + public abstract MapAttributeType Type { get; } - public static LegacyMapAttribute CreateAttribute(MapAttribute type) + public static LegacyMapAttribute CreateAttribute(MapAttributeType type) { switch (type) { - case MapAttribute.Walkable: + case MapAttributeType.Walkable: return null; - case MapAttribute.Blocked: + case MapAttributeType.Blocked: return new LegacyMapBlockedAttribute(); - case MapAttribute.Item: + case MapAttributeType.Item: return new LegacyMapItemAttribute(); - case MapAttribute.ZDimension: + case MapAttributeType.ZDimension: return new LegacyMapZDimensionAttribute(); - case MapAttribute.NpcAvoid: + case MapAttributeType.NpcAvoid: return new LegacyMapNpcAvoidAttribute(); - case MapAttribute.Warp: + case MapAttributeType.Warp: return new LegacyMapWarpAttribute(); - case MapAttribute.Sound: + case MapAttributeType.Sound: return new LegacyMapSoundAttribute(); - case MapAttribute.Resource: + case MapAttributeType.Resource: return new LegacyMapResourceAttribute(); - case MapAttribute.Animation: + case MapAttributeType.Animation: return new LegacyMapAnimationAttribute(); - case MapAttribute.GrappleStone: + case MapAttributeType.GrappleStone: return new LegacyMapGrappleStoneAttribute(); - case MapAttribute.Slide: + case MapAttributeType.Slide: return new LegacyMapSlideAttribute(); } @@ -229,14 +230,14 @@ public static LegacyMapAttribute CreateAttribute(MapAttribute type) private partial class LegacyMapBlockedAttribute : LegacyMapAttribute { - public override MapAttribute Type { get; } = MapAttribute.Blocked; + public override MapAttributeType Type { get; } = MapAttributeType.Blocked; } private partial class LegacyMapItemAttribute : LegacyMapAttribute { - public override MapAttribute Type { get; } = MapAttribute.Item; + public override MapAttributeType Type { get; } = MapAttributeType.Item; public Guid ItemId { get; set; } @@ -247,7 +248,7 @@ private partial class LegacyMapItemAttribute : LegacyMapAttribute private partial class LegacyMapZDimensionAttribute : LegacyMapAttribute { - public override MapAttribute Type { get; } = MapAttribute.ZDimension; + public override MapAttributeType Type { get; } = MapAttributeType.ZDimension; public byte GatewayTo { get; set; } @@ -258,14 +259,14 @@ private partial class LegacyMapZDimensionAttribute : LegacyMapAttribute private partial class LegacyMapNpcAvoidAttribute : LegacyMapAttribute { - public override MapAttribute Type { get; } = MapAttribute.NpcAvoid; + public override MapAttributeType Type { get; } = MapAttributeType.NpcAvoid; } private partial class LegacyMapWarpAttribute : LegacyMapAttribute { - public override MapAttribute Type { get; } = MapAttribute.Warp; + public override MapAttributeType Type { get; } = MapAttributeType.Warp; public Guid MapId { get; set; } @@ -280,7 +281,7 @@ private partial class LegacyMapWarpAttribute : LegacyMapAttribute private partial class LegacyMapSoundAttribute : LegacyMapAttribute { - public override MapAttribute Type { get; } = MapAttribute.Sound; + public override MapAttributeType Type { get; } = MapAttributeType.Sound; public string File { get; set; } @@ -291,7 +292,7 @@ private partial class LegacyMapSoundAttribute : LegacyMapAttribute private partial class LegacyMapResourceAttribute : LegacyMapAttribute { - public override MapAttribute Type { get; } = MapAttribute.Resource; + public override MapAttributeType Type { get; } = MapAttributeType.Resource; public Guid ResourceId { get; set; } @@ -302,7 +303,7 @@ private partial class LegacyMapResourceAttribute : LegacyMapAttribute private partial class LegacyMapAnimationAttribute : LegacyMapAttribute { - public override MapAttribute Type { get; } = MapAttribute.Animation; + public override MapAttributeType Type { get; } = MapAttributeType.Animation; public Guid AnimationId { get; set; } @@ -311,14 +312,14 @@ private partial class LegacyMapAnimationAttribute : LegacyMapAttribute private partial class LegacyMapGrappleStoneAttribute : LegacyMapAttribute { - public override MapAttribute Type { get; } = MapAttribute.GrappleStone; + public override MapAttributeType Type { get; } = MapAttributeType.GrappleStone; } private partial class LegacyMapSlideAttribute : LegacyMapAttribute { - public override MapAttribute Type { get; } = MapAttribute.Slide; + public override MapAttributeType Type { get; } = MapAttributeType.Slide; public byte Direction { get; set; } diff --git a/Intersect.Server.Core/Database/IntersectDbContext.cs b/Intersect.Server.Core/Database/IntersectDbContext.cs index 8155220ce2..ef173c897d 100644 --- a/Intersect.Server.Core/Database/IntersectDbContext.cs +++ b/Intersect.Server.Core/Database/IntersectDbContext.cs @@ -3,6 +3,7 @@ using System.Diagnostics; using System.Text; using Intersect.Config; +using Intersect.Framework.Reflection; using Intersect.Logging; using Intersect.Reflection; using Intersect.Server.Core; diff --git a/Intersect.Server.Core/Database/IntersectLoggerFactory.cs b/Intersect.Server.Core/Database/IntersectLoggerFactory.cs index 8cdd98bebf..55586c85b9 100644 --- a/Intersect.Server.Core/Database/IntersectLoggerFactory.cs +++ b/Intersect.Server.Core/Database/IntersectLoggerFactory.cs @@ -1,5 +1,6 @@ using System.Collections.Immutable; using System.Diagnostics; +using Intersect.Framework.Reflection; using Intersect.Logging; using Intersect.Logging.Formatting; using Intersect.Logging.Output; diff --git a/Intersect.Server.Core/Database/PlayerData/User.cs b/Intersect.Server.Core/Database/PlayerData/User.cs index 28c8664c56..98a0605254 100644 --- a/Intersect.Server.Core/Database/PlayerData/User.cs +++ b/Intersect.Server.Core/Database/PlayerData/User.cs @@ -5,6 +5,7 @@ using System.Security.Cryptography; using System.Text; using Intersect.Enums; +using Intersect.Framework.Reflection; using Intersect.GameObjects; using Intersect.Logging; using Intersect.Reflection; diff --git a/Intersect.Server.Core/Database/SqliteNetCoreGuidPatch.cs b/Intersect.Server.Core/Database/SqliteNetCoreGuidPatch.cs index 244b6b4d87..cf0f2d1c1f 100644 --- a/Intersect.Server.Core/Database/SqliteNetCoreGuidPatch.cs +++ b/Intersect.Server.Core/Database/SqliteNetCoreGuidPatch.cs @@ -1,5 +1,6 @@ using Dapper; using Intersect.Config; +using Intersect.Framework.Reflection; using Intersect.Logging; using Intersect.Reflection; using Microsoft.Data.Sqlite; diff --git a/Intersect.Server.Core/Entities/Entity.cs b/Intersect.Server.Core/Entities/Entity.cs index 440c92076b..51b1a948a5 100644 --- a/Intersect.Server.Core/Entities/Entity.cs +++ b/Intersect.Server.Core/Entities/Entity.cs @@ -20,7 +20,6 @@ using Intersect.Server.Networking; using Intersect.Utilities; using Newtonsoft.Json; -using MapAttribute = Intersect.Enums.MapAttribute; using Stat = Intersect.Enums.Stat; namespace Intersect.Server.Entities; @@ -1229,13 +1228,13 @@ public virtual void Move(Direction moveDir, Player forPlayer, bool doNotUpdate = // ReSharper disable once InvertIf //Check for slide tiles - if (attribute?.Type == MapAttribute.Slide) + if (attribute?.Type == MapAttributeType.Slide) { // If sets direction, set it. if (((MapSlideAttribute)attribute).Direction > 0) { //Check for slide tiles - if (attribute != null && attribute.Type == MapAttribute.Slide) + if (attribute != null && attribute.Type == MapAttributeType.Slide) { if (((MapSlideAttribute)attribute).Direction > 0) { @@ -1291,7 +1290,7 @@ public bool TryToChangeDimension() if (Y < Options.MapHeight && Y >= 0) { var attribute = MapController.Get(MapId).Attributes[X, Y]; - if (attribute != null && attribute.Type == MapAttribute.ZDimension) + if (attribute != null && attribute.Type == MapAttributeType.ZDimension) { if (((MapZDimensionAttribute)attribute).GatewayTo > 0) { diff --git a/Intersect.Server.Core/Entities/Events/CommandProcessing.cs b/Intersect.Server.Core/Entities/Events/CommandProcessing.cs index e6c6aebf89..fb94b4d4b6 100644 --- a/Intersect.Server.Core/Entities/Events/CommandProcessing.cs +++ b/Intersect.Server.Core/Entities/Events/CommandProcessing.cs @@ -13,7 +13,6 @@ using Intersect.Server.Maps; using Intersect.Server.Networking; using Intersect.Utilities; -using VariableMod = Intersect.Enums.VariableMod; namespace Intersect.Server.Entities.Events; @@ -1994,51 +1993,51 @@ Event instance switch (mod.ModType) { - case VariableMod.Set: + case VariableModType.Set: value.Integer = mod.Value; break; - case VariableMod.Add: + case VariableModType.Add: value.Integer += mod.Value; break; - case VariableMod.Subtract: + case VariableModType.Subtract: value.Integer -= mod.Value; break; - case VariableMod.Multiply: + case VariableModType.Multiply: value.Integer *= mod.Value; break; - case VariableMod.Divide: + case VariableModType.Divide: if (mod.Value != 0) //Idiot proofing divide by 0 LOL { value.Integer /= mod.Value; } break; - case VariableMod.LeftShift: - value.Integer = value.Integer << (int)mod.Value; + case VariableModType.LeftShift: + value.Integer <<= (int)mod.Value; break; - case VariableMod.RightShift: - value.Integer = value.Integer >> (int)mod.Value; + case VariableModType.RightShift: + value.Integer >>= (int)mod.Value; break; - case VariableMod.Random: + case VariableModType.Random: //TODO: Fix - Random doesnt work with longs lolz value.Integer = Randomization.Next((int)mod.Value, (int)mod.HighValue + 1); break; - case VariableMod.SystemTime: + case VariableModType.SystemTime: value.Integer = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(); break; - case VariableMod.DupPlayerVar: + case VariableModType.DupPlayerVar: value.Integer = player.GetVariableValue(mod.DuplicateVariableId).Integer; break; - case VariableMod.DupGlobalVar: + case VariableModType.DupGlobalVar: var dupServerVariable = ServerVariableBase.Get(mod.DuplicateVariableId); if (dupServerVariable != null) { @@ -2046,11 +2045,11 @@ Event instance } break; - case VariableMod.AddPlayerVar: + case VariableModType.AddPlayerVar: value.Integer += player.GetVariableValue(mod.DuplicateVariableId).Integer; break; - case VariableMod.AddGlobalVar: + case VariableModType.AddGlobalVar: var asv = ServerVariableBase.Get(mod.DuplicateVariableId); if (asv != null) { @@ -2058,11 +2057,11 @@ Event instance } break; - case VariableMod.SubtractPlayerVar: + case VariableModType.SubtractPlayerVar: value.Integer -= player.GetVariableValue(mod.DuplicateVariableId).Integer; break; - case VariableMod.SubtractGlobalVar: + case VariableModType.SubtractGlobalVar: var ssv = ServerVariableBase.Get(mod.DuplicateVariableId); if (ssv != null) { @@ -2070,11 +2069,11 @@ Event instance } break; - case VariableMod.MultiplyPlayerVar: + case VariableModType.MultiplyPlayerVar: value.Integer *= player.GetVariableValue(mod.DuplicateVariableId).Integer; break; - case VariableMod.MultiplyGlobalVar: + case VariableModType.MultiplyGlobalVar: var msv = ServerVariableBase.Get(mod.DuplicateVariableId); if (msv != null) { @@ -2082,14 +2081,14 @@ Event instance } break; - case VariableMod.DividePlayerVar: + case VariableModType.DividePlayerVar: if (player.GetVariableValue(mod.DuplicateVariableId).Integer != 0) //Idiot proofing divide by 0 LOL { value.Integer /= player.GetVariableValue(mod.DuplicateVariableId).Integer; } break; - case VariableMod.DivideGlobalVar: + case VariableModType.DivideGlobalVar: var dsv = ServerVariableBase.Get(mod.DuplicateVariableId); if (dsv != null) { @@ -2100,11 +2099,11 @@ Event instance } break; - case VariableMod.LeftShiftPlayerVar: + case VariableModType.LeftShiftPlayerVar: value.Integer = value.Integer << (int)player.GetVariableValue(mod.DuplicateVariableId).Integer; break; - case VariableMod.LeftShiftGlobalVar: + case VariableModType.LeftShiftGlobalVar: var lhsv = ServerVariableBase.Get(mod.DuplicateVariableId); if (lhsv != null) { @@ -2112,11 +2111,11 @@ Event instance } break; - case VariableMod.RightShiftPlayerVar: + case VariableModType.RightShiftPlayerVar: value.Integer = value.Integer >> (int)player.GetVariableValue(mod.DuplicateVariableId).Integer; break; - case VariableMod.RightShiftGlobalVar: + case VariableModType.RightShiftGlobalVar: var rhsv = ServerVariableBase.Get(mod.DuplicateVariableId); if (rhsv != null) { @@ -2215,11 +2214,11 @@ Event instance switch (mod.ModType) { - case VariableMod.Set: + case VariableModType.Set: value.String = ParseEventText(mod.Value, player, instance); break; - case VariableMod.Replace: + case VariableModType.Replace: var find = ParseEventText(mod.Value, player, instance); var replace = ParseEventText(mod.Replace, player, instance); value.String = value.String.Replace(find, replace); diff --git a/Intersect.Server.Core/Entities/Player.cs b/Intersect.Server.Core/Entities/Player.cs index 1f8c0a71a9..bb80d5e6d0 100644 --- a/Intersect.Server.Core/Entities/Player.cs +++ b/Intersect.Server.Core/Entities/Player.cs @@ -29,7 +29,6 @@ using Intersect.Utilities; using Newtonsoft.Json; -using MapAttribute = Intersect.Enums.MapAttribute; using Stat = Intersect.Enums.Stat; namespace Intersect.Server.Entities; @@ -7128,7 +7127,7 @@ public override void Move(Direction moveDir, Player forPlayer, bool dontUpdate = // Check for a warp, if so warp the player. var attribute = MapController.Get(MapId).Attributes[X, Y]; - if (attribute != null && attribute.Type == MapAttribute.Warp) + if (attribute != null && attribute.Type == MapAttributeType.Warp) { var warpAtt = (MapWarpAttribute)attribute; var dir = Dir; diff --git a/Intersect.Server.Core/Entities/Projectile.cs b/Intersect.Server.Core/Entities/Projectile.cs index f132707070..61e23690f3 100644 --- a/Intersect.Server.Core/Entities/Projectile.cs +++ b/Intersect.Server.Core/Entities/Projectile.cs @@ -7,7 +7,6 @@ using Intersect.Server.Framework.Items; using Intersect.Server.Maps; using Intersect.Utilities; -using MapAttribute = Intersect.Enums.MapAttribute; namespace Intersect.Server.Entities; @@ -328,7 +327,7 @@ public bool CheckForCollision(ProjectileSpawn spawn) } //Check for grapplehooks. - if (attribute.Type == MapAttribute.GrappleStone && + if (attribute.Type == MapAttributeType.GrappleStone && Base.GrappleHookOptions.Contains(GrappleOption.MapAttribute) && !spawn.Parent.HasGrappled && (spawn.X != Owner.X || spawn.Y != Owner.Y)) @@ -354,7 +353,7 @@ public bool CheckForCollision(ProjectileSpawn spawn) } if (!spawn.ProjectileBase.IgnoreMapBlocks && - ((attribute.Type == MapAttribute.Blocked) || (attribute.Type == MapAttribute.Animation && ((MapAnimationAttribute)attribute).IsBlock))) + ((attribute.Type == MapAttributeType.Blocked) || (attribute.Type == MapAttributeType.Animation && ((MapAnimationAttribute)attribute).IsBlock))) { killSpawn = true; } diff --git a/Intersect.Server.Core/Maps/MapInstance.cs b/Intersect.Server.Core/Maps/MapInstance.cs index a00e5b05ca..9de9b65aa1 100644 --- a/Intersect.Server.Core/Maps/MapInstance.cs +++ b/Intersect.Server.Core/Maps/MapInstance.cs @@ -11,7 +11,6 @@ using Intersect.Utilities; using Intersect.Server.Entities; using Intersect.Server.Classes.Maps; -using MapAttribute = Intersect.Enums.MapAttribute; using Intersect.Server.Core.MapInstancing; using Intersect.Server.Framework.Items; using Intersect.Server.Framework.Maps; @@ -473,7 +472,7 @@ private void FindNpcSpawnLocation(NpcSpawn spawn, out int x, out int y, out Dire { x = (byte)Randomization.Next(0, Options.MapWidth); y = (byte)Randomization.Next(0, Options.MapHeight); - if (mMapController.Attributes[x, y] == null || mMapController.Attributes[x, y].Type == (int)MapAttribute.Walkable) + if (mMapController.Attributes[x, y] == null || mMapController.Attributes[x, y].Type == (int)MapAttributeType.Walkable) { break; } @@ -955,11 +954,11 @@ private void SpawnAttributeItems() { if (mMapController.Attributes[x, y] != null) { - if (mMapController.Attributes[x, y].Type == MapAttribute.Item) + if (mMapController.Attributes[x, y].Type == MapAttributeType.Item) { SpawnAttributeItem(x, y); } - else if (mMapController.Attributes[x, y].Type == MapAttribute.Resource) + else if (mMapController.Attributes[x, y].Type == MapAttributeType.Resource) { SpawnAttributeResource(x, y); } @@ -1130,8 +1129,8 @@ public bool TileBlocked(int x, int y) } //Check if tile is a blocked attribute - if (mMapController.Attributes[x, y] != null && (mMapController.Attributes[x, y].Type == MapAttribute.Blocked || - mMapController.Attributes[x, y].Type == MapAttribute.Animation && ((MapAnimationAttribute)mMapController.Attributes[x, y]).IsBlock)) + if (mMapController.Attributes[x, y] != null && (mMapController.Attributes[x, y].Type == MapAttributeType.Blocked || + mMapController.Attributes[x, y].Type == MapAttributeType.Animation && ((MapAnimationAttribute)mMapController.Attributes[x, y]).IsBlock)) { return true; } @@ -1196,14 +1195,14 @@ public void CacheMapBlocks() { if (mMapController.Attributes[x, y] != null) { - if (mMapController.Attributes[x, y].Type == MapAttribute.Blocked || - mMapController.Attributes[x, y].Type == MapAttribute.GrappleStone || - mMapController.Attributes[x, y].Type == MapAttribute.Animation && ((MapAnimationAttribute)mMapController.Attributes[x, y]).IsBlock) + if (mMapController.Attributes[x, y].Type == MapAttributeType.Blocked || + mMapController.Attributes[x, y].Type == MapAttributeType.GrappleStone || + mMapController.Attributes[x, y].Type == MapAttributeType.Animation && ((MapAnimationAttribute)mMapController.Attributes[x, y]).IsBlock) { blocks.Add(new BytePoint(x, y)); npcBlocks.Add(new BytePoint(x, y)); } - else if (mMapController.Attributes[x, y].Type == MapAttribute.NpcAvoid) + else if (mMapController.Attributes[x, y].Type == MapAttributeType.NpcAvoid) { npcBlocks.Add(new BytePoint(x, y)); } diff --git a/Intersect.Server.Core/Networking/PacketHandler.cs b/Intersect.Server.Core/Networking/PacketHandler.cs index 340b847eb0..e3876d778b 100644 --- a/Intersect.Server.Core/Networking/PacketHandler.cs +++ b/Intersect.Server.Core/Networking/PacketHandler.cs @@ -34,7 +34,7 @@ internal sealed partial class PacketHandler { public IServerContext Context { get; } - public Logger Logger => Context.Logger; + public ILogger Logger => Context.Logger; public PacketHandlerRegistry Registry { get; } diff --git a/Intersect.Server.Framework/Intersect.Server.Framework.csproj b/Intersect.Server.Framework/Intersect.Server.Framework.csproj index 0dfdabe4aa..1b39c2829d 100644 --- a/Intersect.Server.Framework/Intersect.Server.Framework.csproj +++ b/Intersect.Server.Framework/Intersect.Server.Framework.csproj @@ -20,8 +20,8 @@ - - + + \ No newline at end of file diff --git a/Intersect.sln b/Intersect.sln index cb622e34d2..f925b5873c 100644 --- a/Intersect.sln +++ b/Intersect.sln @@ -10,8 +10,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Intersect.Client.Core", "In EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Intersect.Client.Framework", "Intersect.Client.Framework\Intersect.Client.Framework.csproj", "{40973F13-3339-4548-9008-FF76A0C8CD79}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Intersect.Editor", "Intersect.Editor\Intersect.Editor.csproj", "{5AC53DF1-8152-466D-B7D0-238657F013F7}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Intersect.Network", "Intersect.Network\Intersect.Network.csproj", "{E8F288CB-51DF-4D9D-A3B3-A61BD4FD3F45}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Intersect.Server", "Intersect.Server\Intersect.Server.csproj", "{9FFC7331-87BE-403B-82A0-B86D3CCE7C53}" @@ -75,6 +73,12 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Intersect.SinglePlayer", "I EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Single Player", "Single Player", "{F990372C-0580-4D69-89DC-A46A86396BBD}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Intersect.Editor", "Intersect.Editor\Intersect.Editor.csproj", "{5AC53DF1-8152-466D-B7D0-238657F013F7}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WinFormsUI", "vendor\dockpanelsuite\WinFormsUI\WinFormsUI.csproj", "{D831728A-6328-4F96-9692-8FE64E0B0AAD}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ThemeVS2015", "vendor\dockpanelsuite\WinFormsUI\ThemeVS2015.csproj", "{B9678B78-A00D-4765-9380-B1DC4EFD642D}" +EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Framework", "Framework", "{1ABC3725-EB8C-494E-8BA8-A991CE7BD7A1}" ProjectSection(SolutionItems) = preProject Framework\Directory.Build.props = Framework\Directory.Build.props @@ -82,9 +86,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Framework", "Framework", "{ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Intersect.Framework", "Framework\Intersect.Framework\Intersect.Framework.csproj", "{1E87D2A5-7E36-4583-A533-064C97E330EE}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WinFormsUI", "vendor\dockpanelsuite\WinFormsUI\WinFormsUI.csproj", "{D831728A-6328-4F96-9692-8FE64E0B0AAD}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ThemeVS2015", "vendor\dockpanelsuite\WinFormsUI\ThemeVS2015.csproj", "{B9678B78-A00D-4765-9380-B1DC4EFD642D}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Intersect.Framework.Core", "Framework\Intersect.Framework.Core\Intersect.Framework.Core.csproj", "{CD824F78-E469-496D-9DB6-0B0F0A24E5BF}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -117,12 +119,6 @@ Global {40973F13-3339-4548-9008-FF76A0C8CD79}.NoFody|Any CPU.Build.0 = Debug|Any CPU {40973F13-3339-4548-9008-FF76A0C8CD79}.Release|Any CPU.ActiveCfg = Release|Any CPU {40973F13-3339-4548-9008-FF76A0C8CD79}.Release|Any CPU.Build.0 = Release|Any CPU - {5AC53DF1-8152-466D-B7D0-238657F013F7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {5AC53DF1-8152-466D-B7D0-238657F013F7}.Debug|Any CPU.Build.0 = Debug|Any CPU - {5AC53DF1-8152-466D-B7D0-238657F013F7}.NoFody|Any CPU.ActiveCfg = Debug|Any CPU - {5AC53DF1-8152-466D-B7D0-238657F013F7}.NoFody|Any CPU.Build.0 = Debug|Any CPU - {5AC53DF1-8152-466D-B7D0-238657F013F7}.Release|Any CPU.ActiveCfg = Release|Any CPU - {5AC53DF1-8152-466D-B7D0-238657F013F7}.Release|Any CPU.Build.0 = Release|Any CPU {E8F288CB-51DF-4D9D-A3B3-A61BD4FD3F45}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {E8F288CB-51DF-4D9D-A3B3-A61BD4FD3F45}.Debug|Any CPU.Build.0 = Debug|Any CPU {E8F288CB-51DF-4D9D-A3B3-A61BD4FD3F45}.NoFody|Any CPU.ActiveCfg = Debug|Any CPU @@ -183,12 +179,12 @@ Global {999025E8-C034-4A91-8166-5C2D95E9C9C3}.NoFody|Any CPU.Build.0 = Debug|Any CPU {999025E8-C034-4A91-8166-5C2D95E9C9C3}.Release|Any CPU.ActiveCfg = Release|Any CPU {999025E8-C034-4A91-8166-5C2D95E9C9C3}.Release|Any CPU.Build.0 = Release|Any CPU - {1E87D2A5-7E36-4583-A533-064C97E330EE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {1E87D2A5-7E36-4583-A533-064C97E330EE}.Debug|Any CPU.Build.0 = Debug|Any CPU - {1E87D2A5-7E36-4583-A533-064C97E330EE}.NoFody|Any CPU.ActiveCfg = Debug|Any CPU - {1E87D2A5-7E36-4583-A533-064C97E330EE}.NoFody|Any CPU.Build.0 = Debug|Any CPU - {1E87D2A5-7E36-4583-A533-064C97E330EE}.Release|Any CPU.ActiveCfg = Release|Any CPU - {1E87D2A5-7E36-4583-A533-064C97E330EE}.Release|Any CPU.Build.0 = Release|Any CPU + {5AC53DF1-8152-466D-B7D0-238657F013F7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5AC53DF1-8152-466D-B7D0-238657F013F7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5AC53DF1-8152-466D-B7D0-238657F013F7}.NoFody|Any CPU.ActiveCfg = Debug|Any CPU + {5AC53DF1-8152-466D-B7D0-238657F013F7}.NoFody|Any CPU.Build.0 = Debug|Any CPU + {5AC53DF1-8152-466D-B7D0-238657F013F7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5AC53DF1-8152-466D-B7D0-238657F013F7}.Release|Any CPU.Build.0 = Release|Any CPU {D831728A-6328-4F96-9692-8FE64E0B0AAD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {D831728A-6328-4F96-9692-8FE64E0B0AAD}.Debug|Any CPU.Build.0 = Debug|Any CPU {D831728A-6328-4F96-9692-8FE64E0B0AAD}.NoFody|Any CPU.ActiveCfg = Debug|Any CPU @@ -201,6 +197,18 @@ Global {B9678B78-A00D-4765-9380-B1DC4EFD642D}.NoFody|Any CPU.Build.0 = Debug|Any CPU {B9678B78-A00D-4765-9380-B1DC4EFD642D}.Release|Any CPU.ActiveCfg = Release|Any CPU {B9678B78-A00D-4765-9380-B1DC4EFD642D}.Release|Any CPU.Build.0 = Release|Any CPU + {1E87D2A5-7E36-4583-A533-064C97E330EE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1E87D2A5-7E36-4583-A533-064C97E330EE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1E87D2A5-7E36-4583-A533-064C97E330EE}.NoFody|Any CPU.ActiveCfg = Debug|Any CPU + {1E87D2A5-7E36-4583-A533-064C97E330EE}.NoFody|Any CPU.Build.0 = Debug|Any CPU + {1E87D2A5-7E36-4583-A533-064C97E330EE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1E87D2A5-7E36-4583-A533-064C97E330EE}.Release|Any CPU.Build.0 = Release|Any CPU + {CD824F78-E469-496D-9DB6-0B0F0A24E5BF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CD824F78-E469-496D-9DB6-0B0F0A24E5BF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CD824F78-E469-496D-9DB6-0B0F0A24E5BF}.NoFody|Any CPU.ActiveCfg = Debug|Any CPU + {CD824F78-E469-496D-9DB6-0B0F0A24E5BF}.NoFody|Any CPU.Build.0 = Debug|Any CPU + {CD824F78-E469-496D-9DB6-0B0F0A24E5BF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CD824F78-E469-496D-9DB6-0B0F0A24E5BF}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -216,9 +224,10 @@ Global {03C1FB5D-DFB0-414D-831F-BD14DEE49B6A} = {31380BF9-EC1C-4ABE-8A1A-A715B6DF024A} {8BA9007B-9707-46F3-9836-F93C99F8C0C7} = {D89EF539-3EC6-4D07-9E98-65BC55F1DAA4} {999025E8-C034-4A91-8166-5C2D95E9C9C3} = {F990372C-0580-4D69-89DC-A46A86396BBD} - {1E87D2A5-7E36-4583-A533-064C97E330EE} = {1ABC3725-EB8C-494E-8BA8-A991CE7BD7A1} {D831728A-6328-4F96-9692-8FE64E0B0AAD} = {31380BF9-EC1C-4ABE-8A1A-A715B6DF024A} {B9678B78-A00D-4765-9380-B1DC4EFD642D} = {31380BF9-EC1C-4ABE-8A1A-A715B6DF024A} + {1E87D2A5-7E36-4583-A533-064C97E330EE} = {1ABC3725-EB8C-494E-8BA8-A991CE7BD7A1} + {CD824F78-E469-496D-9DB6-0B0F0A24E5BF} = {1ABC3725-EB8C-494E-8BA8-A991CE7BD7A1} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {06095334-0BBD-4FDA-A230-272D08AFB221} diff --git a/disable-windows-editor.patch b/disable-windows-editor.patch index c02c5cefd5..0ab27687bb 100644 --- a/disable-windows-editor.patch +++ b/disable-windows-editor.patch @@ -1,56 +1,36 @@ diff --git a/Intersect.sln b/Intersect.sln -index 203d495b..77933f38 100644 +index f925b5873..28d62e739 100644 --- a/Intersect.sln +++ b/Intersect.sln -@@ -8,8 +8,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Intersect.Client", "Interse +@@ -73,12 +73,12 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Intersect.SinglePlayer", "I EndProject - Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Intersect.Client.Framework", "Intersect.Client.Framework\Intersect.Client.Framework.csproj", "{40973F13-3339-4548-9008-FF76A0C8CD79}" + Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Single Player", "Single Player", "{F990372C-0580-4D69-89DC-A46A86396BBD}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Intersect.Editor", "Intersect.Editor\Intersect.Editor.csproj", "{5AC53DF1-8152-466D-B7D0-238657F013F7}" -EndProject -+#Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Intersect.Editor", "Intersect.Editor\Intersect.Editor.csproj", "{5AC53DF1-8152-466D-B7D0-238657F013F7}" -+#EndProject - Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Intersect.Network", "Intersect.Network\Intersect.Network.csproj", "{E8F288CB-51DF-4D9D-A3B3-A61BD4FD3F45}" - EndProject - Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Intersect.Server", "Intersect.Server\Intersect.Server.csproj", "{9FFC7331-87BE-403B-82A0-B86D3CCE7C53}" -@@ -80,10 +80,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Framework", "Framework", "{ - EndProject - Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Intersect.Framework", "Framework\Intersect.Framework\Intersect.Framework.csproj", "{1E87D2A5-7E36-4583-A533-064C97E330EE}" - EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WinFormsUI", "vendor\dockpanelsuite\WinFormsUI\WinFormsUI.csproj", "{D831728A-6328-4F96-9692-8FE64E0B0AAD}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ThemeVS2015", "vendor\dockpanelsuite\WinFormsUI\ThemeVS2015.csproj", "{B9678B78-A00D-4765-9380-B1DC4EFD642D}" -EndProject ++#Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Intersect.Editor", "Intersect.Editor\Intersect.Editor.csproj", "{5AC53DF1-8152-466D-B7D0-238657F013F7}" ++#EndProject +#Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WinFormsUI", "vendor\dockpanelsuite\WinFormsUI\WinFormsUI.csproj", "{D831728A-6328-4F96-9692-8FE64E0B0AAD}" +#EndProject +#Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ThemeVS2015", "vendor\dockpanelsuite\WinFormsUI\ThemeVS2015.csproj", "{B9678B78-A00D-4765-9380-B1DC4EFD642D}" +#EndProject - Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU -@@ -109,12 +109,12 @@ Global - {40973F13-3339-4548-9008-FF76A0C8CD79}.NoFody|Any CPU.Build.0 = Debug|Any CPU - {40973F13-3339-4548-9008-FF76A0C8CD79}.Release|Any CPU.ActiveCfg = Release|Any CPU - {40973F13-3339-4548-9008-FF76A0C8CD79}.Release|Any CPU.Build.0 = Release|Any CPU + Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Framework", "Framework", "{1ABC3725-EB8C-494E-8BA8-A991CE7BD7A1}" + ProjectSection(SolutionItems) = preProject + Framework\Directory.Build.props = Framework\Directory.Build.props +@@ -179,24 +179,24 @@ Global + {999025E8-C034-4A91-8166-5C2D95E9C9C3}.NoFody|Any CPU.Build.0 = Debug|Any CPU + {999025E8-C034-4A91-8166-5C2D95E9C9C3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {999025E8-C034-4A91-8166-5C2D95E9C9C3}.Release|Any CPU.Build.0 = Release|Any CPU - {5AC53DF1-8152-466D-B7D0-238657F013F7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {5AC53DF1-8152-466D-B7D0-238657F013F7}.Debug|Any CPU.Build.0 = Debug|Any CPU - {5AC53DF1-8152-466D-B7D0-238657F013F7}.NoFody|Any CPU.ActiveCfg = Debug|Any CPU - {5AC53DF1-8152-466D-B7D0-238657F013F7}.NoFody|Any CPU.Build.0 = Debug|Any CPU - {5AC53DF1-8152-466D-B7D0-238657F013F7}.Release|Any CPU.ActiveCfg = Release|Any CPU - {5AC53DF1-8152-466D-B7D0-238657F013F7}.Release|Any CPU.Build.0 = Release|Any CPU -+# {5AC53DF1-8152-466D-B7D0-238657F013F7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU -+# {5AC53DF1-8152-466D-B7D0-238657F013F7}.Debug|Any CPU.Build.0 = Debug|Any CPU -+# {5AC53DF1-8152-466D-B7D0-238657F013F7}.NoFody|Any CPU.ActiveCfg = Debug|Any CPU -+# {5AC53DF1-8152-466D-B7D0-238657F013F7}.NoFody|Any CPU.Build.0 = Debug|Any CPU -+# {5AC53DF1-8152-466D-B7D0-238657F013F7}.Release|Any CPU.ActiveCfg = Release|Any CPU -+# {5AC53DF1-8152-466D-B7D0-238657F013F7}.Release|Any CPU.Build.0 = Release|Any CPU - {E8F288CB-51DF-4D9D-A3B3-A61BD4FD3F45}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E8F288CB-51DF-4D9D-A3B3-A61BD4FD3F45}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E8F288CB-51DF-4D9D-A3B3-A61BD4FD3F45}.NoFody|Any CPU.ActiveCfg = Debug|Any CPU -@@ -181,18 +181,18 @@ Global - {1E87D2A5-7E36-4583-A533-064C97E330EE}.NoFody|Any CPU.Build.0 = Debug|Any CPU - {1E87D2A5-7E36-4583-A533-064C97E330EE}.Release|Any CPU.ActiveCfg = Release|Any CPU - {1E87D2A5-7E36-4583-A533-064C97E330EE}.Release|Any CPU.Build.0 = Release|Any CPU - {D831728A-6328-4F96-9692-8FE64E0B0AAD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D831728A-6328-4F96-9692-8FE64E0B0AAD}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D831728A-6328-4F96-9692-8FE64E0B0AAD}.NoFody|Any CPU.ActiveCfg = Debug|Any CPU @@ -63,6 +43,12 @@ index 203d495b..77933f38 100644 - {B9678B78-A00D-4765-9380-B1DC4EFD642D}.NoFody|Any CPU.Build.0 = Debug|Any CPU - {B9678B78-A00D-4765-9380-B1DC4EFD642D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B9678B78-A00D-4765-9380-B1DC4EFD642D}.Release|Any CPU.Build.0 = Release|Any CPU ++# {5AC53DF1-8152-466D-B7D0-238657F013F7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU ++# {5AC53DF1-8152-466D-B7D0-238657F013F7}.Debug|Any CPU.Build.0 = Debug|Any CPU ++# {5AC53DF1-8152-466D-B7D0-238657F013F7}.NoFody|Any CPU.ActiveCfg = Debug|Any CPU ++# {5AC53DF1-8152-466D-B7D0-238657F013F7}.NoFody|Any CPU.Build.0 = Debug|Any CPU ++# {5AC53DF1-8152-466D-B7D0-238657F013F7}.Release|Any CPU.ActiveCfg = Release|Any CPU ++# {5AC53DF1-8152-466D-B7D0-238657F013F7}.Release|Any CPU.Build.0 = Release|Any CPU +# {D831728A-6328-4F96-9692-8FE64E0B0AAD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU +# {D831728A-6328-4F96-9692-8FE64E0B0AAD}.Debug|Any CPU.Build.0 = Debug|Any CPU +# {D831728A-6328-4F96-9692-8FE64E0B0AAD}.NoFody|Any CPU.ActiveCfg = Debug|Any CPU @@ -75,17 +61,17 @@ index 203d495b..77933f38 100644 +# {B9678B78-A00D-4765-9380-B1DC4EFD642D}.NoFody|Any CPU.Build.0 = Debug|Any CPU +# {B9678B78-A00D-4765-9380-B1DC4EFD642D}.Release|Any CPU.ActiveCfg = Release|Any CPU +# {B9678B78-A00D-4765-9380-B1DC4EFD642D}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE -@@ -209,8 +209,8 @@ Global + {1E87D2A5-7E36-4583-A533-064C97E330EE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1E87D2A5-7E36-4583-A533-064C97E330EE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1E87D2A5-7E36-4583-A533-064C97E330EE}.NoFody|Any CPU.ActiveCfg = Debug|Any CPU +@@ -224,8 +224,8 @@ Global + {03C1FB5D-DFB0-414D-831F-BD14DEE49B6A} = {31380BF9-EC1C-4ABE-8A1A-A715B6DF024A} {8BA9007B-9707-46F3-9836-F93C99F8C0C7} = {D89EF539-3EC6-4D07-9E98-65BC55F1DAA4} {999025E8-C034-4A91-8166-5C2D95E9C9C3} = {F990372C-0580-4D69-89DC-A46A86396BBD} - {1E87D2A5-7E36-4583-A533-064C97E330EE} = {1ABC3725-EB8C-494E-8BA8-A991CE7BD7A1} - {D831728A-6328-4F96-9692-8FE64E0B0AAD} = {31380BF9-EC1C-4ABE-8A1A-A715B6DF024A} - {B9678B78-A00D-4765-9380-B1DC4EFD642D} = {31380BF9-EC1C-4ABE-8A1A-A715B6DF024A} +# {D831728A-6328-4F96-9692-8FE64E0B0AAD} = {31380BF9-EC1C-4ABE-8A1A-A715B6DF024A} +# {B9678B78-A00D-4765-9380-B1DC4EFD642D} = {31380BF9-EC1C-4ABE-8A1A-A715B6DF024A} + {1E87D2A5-7E36-4583-A533-064C97E330EE} = {1ABC3725-EB8C-494E-8BA8-A991CE7BD7A1} + {CD824F78-E469-496D-9DB6-0B0F0A24E5BF} = {1ABC3725-EB8C-494E-8BA8-A991CE7BD7A1} EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {06095334-0BBD-4FDA-A230-272D08AFB221} diff --git a/vendor/dockpanelsuite b/vendor/dockpanelsuite index 94b2dc0c72..a373cf7fba 160000 --- a/vendor/dockpanelsuite +++ b/vendor/dockpanelsuite @@ -1 +1 @@ -Subproject commit 94b2dc0c724cb7e5d27aefd3b46125e2b7bdeaf9 +Subproject commit a373cf7fbaa0a79c4790ac5cb26eba48944a58bc