From 6852bda53a0ae7b02ab583f902aeb46c07eaf6f2 Mon Sep 17 00:00:00 2001 From: Redforce04 <74625280+Redforce04@users.noreply.github.com> Date: Sat, 21 Oct 2023 16:53:37 -0500 Subject: [PATCH 1/6] Fix Glass Countdown --- AutoEvent/Games/Glass/Plugin.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/AutoEvent/Games/Glass/Plugin.cs b/AutoEvent/Games/Glass/Plugin.cs index 79927e84..0490b125 100644 --- a/AutoEvent/Games/Glass/Plugin.cs +++ b/AutoEvent/Games/Glass/Plugin.cs @@ -40,6 +40,7 @@ public class Plugin : Event, IEventSound, IEventMap, IInternalEvent private GameObject _lava; private GameObject _finish; private int _matchTimeInSeconds; + private TimeSpan _remaining; protected override void RegisterEvents() { @@ -64,7 +65,6 @@ protected override void OnStart() { _lava = MapInfo.Map.AttachedBlocks.First(x => x.name == "Lava"); _lava.AddComponent(); - int platformCount; int playerCount = Player.GetPlayers().Count(r => r.IsAlive); if (playerCount <= 5) @@ -92,6 +92,7 @@ protected override void OnStart() platformCount = 15; _matchTimeInSeconds = 150; } + _remaining = TimeSpan.FromSeconds(_matchTimeInSeconds); var platform = MapInfo.Map.AttachedBlocks.First(x => x.name == "Platform"); var platform1 = MapInfo.Map.AttachedBlocks.First(x => x.name == "Platform1"); @@ -179,9 +180,10 @@ protected override bool IsRoundDone() protected override void ProcessFrame() { + _remaining -= TimeSpan.FromSeconds(FrameDelayInSeconds); var text = Translation.GlassStart; text = text.Replace("{plyAlive}", Player.GetPlayers().Count(r => r.IsAlive).ToString()); - text = text.Replace("{time}", $"{EventTime.Minutes:00}:{EventTime.Seconds:00}"); + text = text.Replace("{time}", $"{_remaining.Minutes:00}:{_remaining.Seconds:00}"); Extensions.Broadcast(text, 1); } From f39fe5e1e03c4768e8d3e6f6b07612a542be2e88 Mon Sep 17 00:00:00 2001 From: Redforce04 <74625280+Redforce04@users.noreply.github.com> Date: Sat, 21 Oct 2023 17:41:42 -0500 Subject: [PATCH 2/6] Fix Nvorbis --- AutoEvent/AutoEvent.csproj | 1 + AutoEvent/DebugLogger.cs | 26 ++++++++++++++++++++++++++ AutoEvent/FodyWeavers.xml | 1 + 3 files changed, 28 insertions(+) diff --git a/AutoEvent/AutoEvent.csproj b/AutoEvent/AutoEvent.csproj index b94ebdc4..bc6ca5c6 100644 --- a/AutoEvent/AutoEvent.csproj +++ b/AutoEvent/AutoEvent.csproj @@ -47,6 +47,7 @@ + diff --git a/AutoEvent/DebugLogger.cs b/AutoEvent/DebugLogger.cs index ebce37e0..11d3012f 100644 --- a/AutoEvent/DebugLogger.cs +++ b/AutoEvent/DebugLogger.cs @@ -13,6 +13,8 @@ using System; using System.Collections.Generic; using System.IO; +using MEC; +using PluginAPI; using PluginAPI.Core; using PluginAPI.Helpers; using UnityEngine; @@ -48,6 +50,30 @@ public DebugLogger(bool writeDirectly) } File.Create(_filePath).Close(); + /*Timing.CallDelayed(5f, () => + { + + string text = $"Plugin Api Info: \n" + + $" Version: {PluginApiVersion.Version}\n" + + $" VersionStatic: {PluginApiVersion.VersionStatic}\n" + + $" VersionString: {PluginApiVersion.VersionString}\n" + + $"Plugins Present: "; + /*Plugins Present: + * MapEditorReborn.dll (MapEditorReborn vX by Author) + * Assembly Hash: 142wesdvsdfsg + * + * + *//* + + foreach (var plugin in PluginAPI.Loader.AssemblyLoader.Plugins) + { + var hashId = plugin.Key.ManifestModule.ModuleVersionId; + + //text += $" {plugin.Key.FullName} {plugin.}"; + text += $" Assembly Hash: {hashId}"; + } + File.AppendAllText(_filePath,); + });*/ } } catch (Exception e) diff --git a/AutoEvent/FodyWeavers.xml b/AutoEvent/FodyWeavers.xml index ccae99ce..13ea034e 100644 --- a/AutoEvent/FodyWeavers.xml +++ b/AutoEvent/FodyWeavers.xml @@ -6,6 +6,7 @@ 0Harmony System.ComponentModel.DataAnnotations YamlDotNet + NVorbis From e4c2365f8b310e1188312097835dc47f95d523fe Mon Sep 17 00:00:00 2001 From: Redforce04 <74625280+Redforce04@users.noreply.github.com> Date: Sat, 21 Oct 2023 21:40:59 -0500 Subject: [PATCH 3/6] Cleanup git, make some projects external. --- AutoEvent-NWApi/Interfaces/Event.cs | 898 ------------------ AutoEvent-NWApi/Loader.cs | 398 -------- AutoEvent-NWApi/Plugin.cs | 196 ---- .../Components/SchematicCollisionComponent.cs | 4 +- AutoEvent/API/Extensions.cs | 4 +- AutoEvent/AutoEvent.csproj | 22 + AutoEvent/AutoEvent.sln | 12 + AutoEvent/Commands/Debug/PowerupCommand.cs | 8 +- AutoEvent/FodyWeavers.xml | 2 + .../Games/Battle/Features/RandomClass.cs | 2 +- AutoEvent/Games/Battle/Plugin.cs | 2 +- AutoEvent/Games/Boss/Features/RandomClass.cs | 2 +- AutoEvent/Games/Boss/Plugin.cs | 2 +- .../Games/DeathParty/Features/RandomClass.cs | 2 +- AutoEvent/Games/DeathParty/Plugin.cs | 2 +- .../Deathmatch/Extensions/RandomClass.cs | 2 +- AutoEvent/Games/Deathmatch/Plugin.cs | 2 +- .../Games/Example/Features/RandomClass.cs | 2 +- .../Games/FallDown/Extensions/RandomClass.cs | 2 +- AutoEvent/Games/FallDown/Plugin.cs | 2 +- .../Games/FinishWay/Extensions/RandomClass.cs | 2 +- AutoEvent/Games/FinishWay/Plugin.cs | 2 +- .../Games/Football/Features/RandomClass.cs | 2 +- AutoEvent/Games/Football/Plugin.cs | 2 +- AutoEvent/Games/Glass/Features/RandomClass.cs | 2 +- AutoEvent/Games/Glass/Plugin.cs | 2 +- AutoEvent/Games/GunGame/Plugin.cs | 2 +- .../Games/HideAndSeek/Features/RandomClass.cs | 2 +- AutoEvent/Games/HideAndSeek/Plugin.cs | 2 +- .../Games/Infection/Extensions/RandomClass.cs | 2 +- AutoEvent/Games/Infection/Plugin.cs | 2 +- AutoEvent/Games/Jail/Extensions/JailRandom.cs | 2 +- AutoEvent/Games/Jail/Plugin.cs | 2 +- .../Games/Knives/Features/RandomClass.cs | 2 +- AutoEvent/Games/Knives/Plugin.cs | 2 +- AutoEvent/Games/Lava/Features/RandomClass.cs | 2 +- AutoEvent/Games/Lava/Plugin.cs | 2 +- AutoEvent/Games/Line/Plugin.cs | 2 +- .../Games/Puzzle/Features/RandomClass.cs | 2 +- AutoEvent/Games/Puzzle/Plugin.cs | 2 +- .../Games/Survival/Extensions/RandomClass.cs | 2 +- AutoEvent/Games/Survival/Plugin.cs | 2 +- .../Games/Versus/Features/RandomClass.cs | 2 +- AutoEvent/Games/Versus/Plugin.cs | 2 +- .../ZombieEscape/Extensions/RandomClass.cs | 2 +- AutoEvent/Games/ZombieEscape/Plugin.cs | 2 +- AutoEvent/Interfaces/IEventMap.cs | 2 +- AutoEvent/Interfaces/MapInfo.cs | 2 +- AutoEvent/Plugin.cs | 5 +- AutoEvent/PowerupApi/API.cs | 35 + .../BaseCollisionDetectorComponent.cs | 117 +++ .../PlayerCollisionDetectorComponent.cs | 71 ++ .../Components/SchematicCollisionComponent.cs | 81 ++ .../Components/SpinningItemComponent.cs | 33 + .../Default}/AmmoPowerup.cs | 4 +- .../Default}/SpeedPowerup.cs | 5 +- .../Default}/TestPowerup.cs | 8 +- .../Extensions/AbstractTypeExtensions.cs | 65 ++ .../PowerupApi/Extensions/MirrorExtensions.cs | 590 ++++++++++++ AutoEvent/PowerupApi/FodyWeavers.xml | 12 + AutoEvent/PowerupApi/FodyWeavers.xsd | 141 +++ .../{Interfaces => PowerupApi}/Powerup.cs | 84 +- AutoEvent/PowerupApi/PowerupApi.csproj | 66 ++ .../PowerupManager.cs | 32 +- .../PowerupApi/Properties/AssemblyInfo.cs | 35 + AutoEvent/SchematicApi/API.cs | 35 + .../AnimationController.cs | 2 +- .../Components/PickupComponent.cs | 21 + .../Enums/BlockType.cs | 2 +- .../Enums/CullingType.cs | 2 +- .../Enums/LockerType.cs | 2 +- AutoEvent/SchematicApi/FodyWeavers.xml | 11 + AutoEvent/SchematicApi/FodyWeavers.xsd | 141 +++ .../Schematic => SchematicApi}/MapUtils.cs | 12 +- .../ObjectHelper.cs | 2 +- .../ObjectSpawner.cs | 5 +- .../Objects/LightSourceObjects.cs | 2 +- .../Objects/LockerObject.cs | 2 +- .../Objects/MapEditorObject.cs | 2 +- .../Objects/PrimitiveObject.cs | 2 +- .../Objects/SchematicObject.cs | 8 +- .../Objects/WorkstationObject.cs | 2 +- .../SchematicApi/Properties/AssemblyInfo.cs | 35 + AutoEvent/SchematicApi/SchematicApi.csproj | 64 ++ .../Serializable/LightSourcesSerializable.cs | 2 +- .../Serializable/LockerItemSerializable.cs | 2 +- .../Serializable/LockerSerializable.cs | 2 +- .../Serializable/PrimitiveSerializable.cs | 2 +- .../Serializable/SchematicObjectDataList.cs | 2 +- .../Serializable/SchematicSerializable.cs | 2 +- .../Serializable/SerializableObject.cs | 2 +- .../Serializable/SerializableRigidbody.cs | 2 +- .../Serializable/WorkstationSerializable.cs | 2 +- 93 files changed, 1773 insertions(+), 1603 deletions(-) delete mode 100644 AutoEvent-NWApi/Interfaces/Event.cs delete mode 100644 AutoEvent-NWApi/Loader.cs delete mode 100644 AutoEvent-NWApi/Plugin.cs create mode 100644 AutoEvent/PowerupApi/API.cs create mode 100644 AutoEvent/PowerupApi/Components/BaseCollisionDetectorComponent.cs create mode 100644 AutoEvent/PowerupApi/Components/PlayerCollisionDetectorComponent.cs create mode 100644 AutoEvent/PowerupApi/Components/SchematicCollisionComponent.cs create mode 100644 AutoEvent/PowerupApi/Components/SpinningItemComponent.cs rename AutoEvent/{Powerups => PowerupApi/Default}/AmmoPowerup.cs (95%) rename AutoEvent/{Powerups => PowerupApi/Default}/SpeedPowerup.cs (96%) rename AutoEvent/{Powerups => PowerupApi/Default}/TestPowerup.cs (80%) create mode 100644 AutoEvent/PowerupApi/Extensions/AbstractTypeExtensions.cs create mode 100644 AutoEvent/PowerupApi/Extensions/MirrorExtensions.cs create mode 100644 AutoEvent/PowerupApi/FodyWeavers.xml create mode 100644 AutoEvent/PowerupApi/FodyWeavers.xsd rename AutoEvent/{Interfaces => PowerupApi}/Powerup.cs (56%) create mode 100644 AutoEvent/PowerupApi/PowerupApi.csproj rename AutoEvent/{Powerups => PowerupApi}/PowerupManager.cs (72%) create mode 100644 AutoEvent/PowerupApi/Properties/AssemblyInfo.cs create mode 100644 AutoEvent/SchematicApi/API.cs rename AutoEvent/{API/Schematic => SchematicApi}/AnimationController.cs (97%) create mode 100644 AutoEvent/SchematicApi/Components/PickupComponent.cs rename AutoEvent/{API/Schematic => SchematicApi}/Enums/BlockType.cs (83%) rename AutoEvent/{API/Schematic => SchematicApi}/Enums/CullingType.cs (70%) rename AutoEvent/{API/Schematic => SchematicApi}/Enums/LockerType.cs (80%) create mode 100644 AutoEvent/SchematicApi/FodyWeavers.xml create mode 100644 AutoEvent/SchematicApi/FodyWeavers.xsd rename AutoEvent/{API/Schematic => SchematicApi}/MapUtils.cs (64%) rename AutoEvent/{API/Schematic => SchematicApi}/ObjectHelper.cs (99%) rename AutoEvent/{API/Schematic => SchematicApi}/ObjectSpawner.cs (95%) rename AutoEvent/{API/Schematic => SchematicApi}/Objects/LightSourceObjects.cs (97%) rename AutoEvent/{API/Schematic => SchematicApi}/Objects/LockerObject.cs (98%) rename AutoEvent/{API/Schematic => SchematicApi}/Objects/MapEditorObject.cs (98%) rename AutoEvent/{API/Schematic => SchematicApi}/Objects/PrimitiveObject.cs (98%) rename AutoEvent/{API/Schematic => SchematicApi}/Objects/SchematicObject.cs (97%) rename AutoEvent/{API/Schematic => SchematicApi}/Objects/WorkstationObject.cs (96%) create mode 100644 AutoEvent/SchematicApi/Properties/AssemblyInfo.cs create mode 100644 AutoEvent/SchematicApi/SchematicApi.csproj rename AutoEvent/{API/Schematic => SchematicApi}/Serializable/LightSourcesSerializable.cs (95%) rename AutoEvent/{API/Schematic => SchematicApi}/Serializable/LockerItemSerializable.cs (94%) rename AutoEvent/{API/Schematic => SchematicApi}/Serializable/LockerSerializable.cs (98%) rename AutoEvent/{API/Schematic => SchematicApi}/Serializable/PrimitiveSerializable.cs (93%) rename AutoEvent/{API/Schematic => SchematicApi}/Serializable/SchematicObjectDataList.cs (94%) rename AutoEvent/{API/Schematic => SchematicApi}/Serializable/SchematicSerializable.cs (90%) rename AutoEvent/{API/Schematic => SchematicApi}/Serializable/SerializableObject.cs (88%) rename AutoEvent/{API/Schematic => SchematicApi}/Serializable/SerializableRigidbody.cs (87%) rename AutoEvent/{API/Schematic => SchematicApi}/Serializable/WorkstationSerializable.cs (93%) diff --git a/AutoEvent-NWApi/Interfaces/Event.cs b/AutoEvent-NWApi/Interfaces/Event.cs deleted file mode 100644 index 807b4443..00000000 --- a/AutoEvent-NWApi/Interfaces/Event.cs +++ /dev/null @@ -1,898 +0,0 @@ -using AutoEvent.API.Attributes; -using PluginAPI.Core; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Reflection; -using AutoEvent.API; -using AutoEvent.API.Enums; -using AutoEvent.Configs; -using HarmonyLib; -using MEC; -using UnityEngine; -using YamlDotNet.Core; - -namespace AutoEvent.Interfaces -{ - public abstract class Event : IEvent - { -#region Static Implementations // Static tools for registering and viewing events. - /// - /// A list of all registered events including external events and events. - /// - public static List Events { get; set; } = new List(); - - - /// - /// Registers all of the Events. - /// - internal static void RegisterInternalEvents() - { - Assembly callingAssembly = Assembly.GetCallingAssembly(); - Type[] types = callingAssembly.GetTypes(); - - foreach (Type type in types) - { - try - { - if (type.IsAbstract || - type.IsEnum || - type.IsInterface || type.GetInterfaces().All(x => x != typeof(IEvent))) - continue; - - object evBase = Activator.CreateInstance(type); - if(evBase is null || evBase is not Event ev || - type.GetCustomAttributes(typeof(DisabledFeaturesAttribute), false).Any(x => x is not null)) - continue; - - if (!ev.AutoLoad) - continue; - ev.Id = Events.Count; - try - { - ev.VerifyEventInfo(); - ev.LoadConfigs(); - ev.LoadTranslation(); - ev.InstantiateEvent(); - } - catch (Exception e) - { - DebugLogger.LogDebug($"[EventLoader] {ev.Name} encountered an error while registering.", LogLevel.Warn, true); - DebugLogger.LogDebug($"[EventLoader] {e}", LogLevel.Debug); - } - string confs = ""; - foreach (var conf in ev.ConfigPresets) - { - confs += $"{conf.PresetName}, "; - } - Events.Add(ev); - DebugLogger.LogDebug($"[EventLoader] {ev.Name} has been registered. Presets: {(confs + ",").Replace(", ,", "")}", LogLevel.Info, true); - } - catch (MissingMethodException) { } - catch (Exception ex) - { - DebugLogger.LogDebug($"[EventLoader] cannot register an event.", LogLevel.Error, true); - DebugLogger.LogDebug($"{ex}", LogLevel.Debug); - - } - } - } - - /// - /// Gets an event by it's name. - /// - /// The name of the event to search for. - /// The first event found with the same name (Case-Insensitive). - public static Event GetEvent(string type) - { - Event ev = null; - - if (int.TryParse(type, out int id)) - return GetEvent(id); - - if (!TryGetEventByCName(type, out ev)) - return Events.FirstOrDefault(ev => ev.Name.ToLower() == type.ToLower()); - - return ev; - } - - /// - /// Gets an event by it's ID. - /// - /// The ID of the event to search for. - /// The first event found with the same ID. - public static Event GetEvent(int id) => Events.FirstOrDefault(x => x.Id == id); - - private static bool TryGetEventByCName(string type, out Event ev) - { - return (ev = Events.FirstOrDefault(x => x.CommandName == type)) != null; - } -#endregion -#region Abstract Implementations // Tools that have been abstracted into the event class. - #region Event Information // Information that event authors can specify about the event. - /// - /// The name of the event. - /// - public abstract string Name { get; set; } - - /// - /// The Id of the event. It is set by AutoEvent. - /// - public int Id { get; internal set; } - - /// - /// A description of the event. - /// - public abstract string Description { get; set; } - - /// - /// The name of the author of the event. - /// - public abstract string Author { get; set; } - - /// - /// The name of the map that is used to run the map via command. - /// - public abstract string CommandName { get; set; } - #endregion - #region Event Settings // Settings that event authors can define to modify the abstracted implementations - /// - /// How long to wait after the round finishes, before the cleanup begins. Default is 10 seconds. - /// - protected virtual float PostRoundDelay { get; set; } = 10f; - - /// - /// Obsolete. Use instead. - /// - [Obsolete("This is no longer supported. Inherit IExiledEvent instead.")] - public virtual bool UsesExiled { get; protected set; } = false; - - /// - /// If using NwApi or Exiled as the base plugin, set this to false, and manually add your plugin to Event.Events (List[Events]). - /// This prevents double-loading your plugin assembly. - /// - public virtual bool AutoLoad { get; protected set; } = true; - - /// - /// Used to safely kill the while loop, without have to forcible kill the coroutine. - /// - protected virtual bool KillLoop { get; set; } = false; - - /// - /// How many seconds the event waits after each ProcessFrame(). - /// - protected virtual float FrameDelayInSeconds { get; set; } = 1f; - - /// - /// Use this to force specific settings for friendly fire. - /// - protected virtual FriendlyFireSettings ForceEnableFriendlyFire { get; set; } = FriendlyFireSettings.Default; - - /// - /// Use this to force specific settings for friendly fire autoban. - /// - protected virtual FriendlyFireSettings ForceEnableFriendlyFireAutoban { get; set; } = FriendlyFireSettings.Default; - - #endregion - #region Event Variables // Variables that the event author has access too, which are abstracted into the event system. - - - /// - /// The coroutine handle of the main event thread which calls ProcessFrame(). - /// - protected virtual CoroutineHandle GameCoroutine { get; set; } - - /// - /// The coroutine handle for the start countdown broadcast. - /// - protected virtual CoroutineHandle BroadcastCoroutine { get; set; } - - // ReSharper disable once UnusedAutoPropertyAccessor.Global - /// - /// The DateTime (UTC) that the plugin started at. - /// - public virtual DateTime StartTime { get; protected set; } - - /// - /// The elapsed time since the plugin started. - /// - public virtual TimeSpan EventTime { get; protected set; } - - #endregion - #region Event API Methods // Methods that can be used as api calls such as starting music / spawning map. - /// - /// Starts the defined Audio. Can be used to trigger a late audio cue. SoundInfo.StartAutomatically - /// - /// Should the audio abide by - protected void StartAudio(bool checkIfAutomatic = false) - { - DebugLogger.LogDebug($"Starting Audio: " + - $"{(this is IEventSound s ? "true, " + - $"{(!string.IsNullOrEmpty(s.SoundInfo.SoundName)? "true" : "false")}, " + - $"{(!checkIfAutomatic ? "true" : "false")}, " + - $"{(s.SoundInfo.StartAutomatically ? "true" : "false")}" : "false")}", - LogLevel.Debug); - if (this is IEventSound sound && !string.IsNullOrEmpty(sound.SoundInfo.SoundName) && - (!checkIfAutomatic || sound.SoundInfo.StartAutomatically)) - { - // play sound - Extensions.PlayAudio( - sound.SoundInfo.SoundName, - sound.SoundInfo.Volume, - sound.SoundInfo.Loop, - Name); - } - } - - /// - /// Can be used to stop the running audio. - /// - protected void StopAudio() - { - DebugLogger.LogDebug("Stopping Audio", LogLevel.Debug); - Extensions.StopAudio(); - } - - /// - /// Spawns the defined Map. Can be used to trigger a late Map spawn. MapInfo.SpawnAutomatically - /// - /// Should the audio abide by - - protected void SpawnMap(bool checkIfAutomatic = false) - { - DebugLogger.LogDebug($"Spawning Map: " + - $"{(this is IEventMap m ? "true, " + - $"{(!string.IsNullOrEmpty(m.MapInfo.MapName)? "true" : "false")}, " + - $"{(!checkIfAutomatic ? "true" : "false")}, " + - $"{(m.MapInfo.SpawnAutomatically ? "true" : "false")}" : "false")}", - LogLevel.Debug); - if (this is IEventMap map && !string.IsNullOrEmpty(map.MapInfo.MapName) && - (!checkIfAutomatic || map.MapInfo.SpawnAutomatically)) - { - // load map - map.MapInfo.Map = Extensions.LoadMap( - map.MapInfo.MapName, - map.MapInfo.Position, - map.MapInfo.MapRotation, - map.MapInfo.Scale); - } - } - - /// - /// Can be used to de-spawn the map. - /// - protected void DeSpawnMap() - { - DebugLogger.LogDebug($"DeSpawning Map. {this is IEventMap}", LogLevel.Debug); - if (this is IEventMap eventMap) - { - Extensions.UnLoadMap(eventMap.MapInfo.Map); - } - } - - /// - /// Can be used to get a list of each defined in the plugin. - /// - /// Returns a list of the current values of each - public List GetCurrentConfigsValues() - { - List eventConfigs = new List(); - foreach (PropertyInfo propertyInfo in this.GetType().GetProperties()) - { - var attr = propertyInfo.GetCustomAttribute(); - if (attr is null) - continue; - object value = propertyInfo.GetValue(this); - if(value is not EventConfig conf) - continue; - eventConfigs.Add(conf); - } - - return eventConfigs; - } - - /// - /// Used to start the event safely. - /// - public void StartEvent() - { - DebugLogger.LogDebug($"Starting Event {Name}", LogLevel.Debug); - OnInternalStart(); - } - - /// - /// Used to stop the event safely. - /// - public void StopEvent() - { - DebugLogger.LogDebug($"Stopping Event {Name}", LogLevel.Debug); - OnInternalStop(); - } - - #endregion - #region Event Methods // Methods that event authors can / must utilize that are abstracted into the event system. - /// - /// Base constructor for an event. - /// - public Event(){ } - - /// - /// The method that is called when the event is registered. Should be used instead of a constructor to prevent type load exceptions. - /// - public virtual void InstantiateEvent() { } - - /// - /// Called when the event is started. - /// - protected abstract void OnStart(); - - /// - /// Used to register events for plugins. - /// - protected virtual void RegisterEvents() { } - - /// - /// Called after start in a coroutine. Can be used as a countdown coroutine. - /// - protected virtual IEnumerator BroadcastStartCountdown() - { - yield break; - } - - /// - /// Called after is finished. Can be used to remove walls, or give players items. - /// - protected virtual void CountdownFinished() { } - - /// - /// Used to determine whether the event should end or not. - /// - /// True if the round is finished. False if the round should continue running. - protected abstract bool IsRoundDone(); - - /// - /// Called once a second. - /// - protected virtual void ProcessFrame() { } - - /// - /// Called when the event is finished. If the event is stopped via , this won't be called, as the event never truly finishes properly. - /// - protected abstract void OnFinished(); - - /// - /// Called if the event is forcibly stopped. If this is called, won't be called. - /// - protected virtual void OnStop() { } - - /// - /// Used to unregister events for plugins. - /// - protected virtual void UnregisterEvents() { } - - /// - /// The overridable class for after and event is finished / stopped and cleanup is occuring. - /// - protected virtual void OnCleanup() { } - #endregion - #region Internal Event Methods // Methods that are for the internal use by the event system to call or modify other abstracted properties or methods. - - private string CreateConfigFolder() - { - string path = Path.Combine(AutoEvent.Singleton.Config.EventConfigsDirectoryPath, this.Name); - AutoEvent.CreateDirectoryIfNotExists(path); - AutoEvent.CreateDirectoryIfNotExists(Path.Combine(path, "Presets")); - return path; - } - - /// - /// A list of available config presets. WIP - /// - public List ConfigPresets { get; set; } = new List(); - - private List _confTypes { get; set; } = new List(); - - /// - /// Ensures that information such as the command name is valid. - /// - internal void VerifyEventInfo() - { - this.CommandName = CommandName.ToCamelCase(true); - } - - /// - /// Validates and loads any configs and presets for the given event. - /// - internal void LoadConfigs() - { - if (this.ConfigPresets is not null) - this.ConfigPresets.Clear(); - else - this.ConfigPresets = new List(); - - int loadedConfigs = 0; - var path = CreateConfigFolder(); - try - { - loadedConfigs = _loadValidConfigs(path); - } - catch (Exception e) - { - DebugLogger.LogDebug($"[EventLoader] LoadConfigs()->_loadValidConfigs(path) has caught an exception while loading configs for the plugin {Name}", LogLevel.Warn, true); - DebugLogger.LogDebug($"{e}", LogLevel.Debug); - } - - try - { - _createPresets(Path.Combine(path, "Presets")); - } - catch (Exception e) - { - DebugLogger.LogDebug($"[EventLoader] LoadConfigs()->_createPresets(path) has caught an exception while loading configs for the plugin {Name}", LogLevel.Warn, true); - DebugLogger.LogDebug($"{e}", LogLevel.Debug); - } - - try - { - _loadPresets(Path.Combine(path, "Presets")); - } - catch (Exception e) - { - DebugLogger.LogDebug($"[EventLoader] LoadConfigs()->_loadPresets(path) has caught an exception while loading configs for the plugin {Name}", LogLevel.Warn, true); - DebugLogger.LogDebug($"{e}", LogLevel.Debug); - } - // DebugLogger.LogDebug($"[EventLoader] Loaded {loadedConfigs} Configs, and {ConfigPresets.Count} Config Presets, for plugin {Name}", LogLevel.Info); - } - - /// - /// Loads any configs. - /// - /// The base event path. - private int _loadValidConfigs(string path) - { - int i = 0; - foreach (var property in this.GetType().GetProperties()) - { - var conf = property.GetCustomAttribute(); - if (conf is EventConfigPresetAttribute) - { - continue; - } - if (conf is null) - { - continue; - } - - DebugLogger.LogDebug($"Config \"{property.Name}\" found for {Name}", LogLevel.Debug); - object config = conf.Load(path, property.Name, property.PropertyType); - if (config is not EventConfig evConfig) - { - DebugLogger.LogDebug($"Config was found that does not inherit Event Config. It will be skipped.", LogLevel.Warn, true); - DebugLogger.LogDebug($"(Event {this.Name}) Config: {property.Name}.", LogLevel.Debug); - continue; - } - - if (ConfigPresets.Count > 0) - evConfig.PresetName = $"Default-{ConfigPresets.Count - 1}"; - else - evConfig.PresetName = "Default"; - _setRandomMap(evConfig); - _setRandomSound(evConfig); - - property.SetValue(this, config); - ConfigPresets.Add((EventConfig)config); - _confTypes.Add(config.GetType()); - - i++; - } - - return i; - } - - /// - /// Assigns a random map. - /// - /// - private void _setRandomMap(EventConfig conf) - { - if (this is IEventMap map && conf.AvailableMaps is not null && conf.AvailableMaps.Count > 0) - { - bool spawnAutomatically = map.MapInfo.SpawnAutomatically; - if (conf.AvailableMaps.Count == 1) - { - map.MapInfo = conf.AvailableMaps[0].Map; - map.MapInfo.SpawnAutomatically = spawnAutomatically; - goto Message; - } - - foreach (var mapItem in conf.AvailableMaps.Where(x => x.Chance <= 0)) - mapItem.Chance = 1; - - float totalChance = conf.AvailableMaps.Sum(x => x.Chance); - - for (int i = 0; i < conf.AvailableMaps.Count - 1; i++) - { - if (UnityEngine.Random.Range(0, totalChance) <= conf.AvailableMaps[i].Chance) - { - map.MapInfo = conf.AvailableMaps[i].Map; - map.MapInfo.SpawnAutomatically = spawnAutomatically; - goto Message; - } - } - map.MapInfo = conf.AvailableMaps[conf.AvailableMaps.Count - 1].Map; - map.MapInfo.SpawnAutomatically = spawnAutomatically; - Message: - DebugLogger.LogDebug($"[{this.Name}] Map {map.MapInfo.MapName} selected.", LogLevel.Debug); - } - - } - /// - /// Assigns a random sound. - /// - /// - private void _setRandomSound(EventConfig conf) - { - if (this is IEventSound sound && conf.AvailableSounds is not null && conf.AvailableSounds.Count > 0) - { - bool startAutomatically = sound.SoundInfo.StartAutomatically; - if (conf.AvailableSounds.Count == 1) - { - sound.SoundInfo = conf.AvailableSounds[0].Sound; - sound.SoundInfo.StartAutomatically = startAutomatically; - goto Message; - } - - foreach (var soundItem in conf.AvailableSounds.Where(x => x.Chance <= 0)) - soundItem.Chance = 1; - - float totalChance = conf.AvailableSounds.Sum(x => x.Chance); - - for (int i = 0; i < conf.AvailableSounds.Count - 1; i++) - { - if (UnityEngine.Random.Range(0, totalChance) <= conf.AvailableSounds[i].Chance) - { - sound.SoundInfo = conf.AvailableSounds[i].Sound; - sound.SoundInfo.StartAutomatically = startAutomatically; - goto Message; - } - } - sound.SoundInfo = conf.AvailableSounds[conf.AvailableSounds.Count - 1].Sound; - sound.SoundInfo.StartAutomatically = startAutomatically; - Message: - DebugLogger.LogDebug($"[{this.Name}] Sound {sound.SoundInfo.SoundName} selected.", LogLevel.Debug); - } - } - /// - /// Creates a preset.yml file for each preset found. - /// - /// The base event path. - private void _createPresets(string path) - { - foreach (var property in this.GetType().GetProperties()) - { - var conf = property.GetCustomAttribute(); - if (conf is null || conf.IsLoaded) - { - continue; - } - // DebugLogger.LogDebug($"Embedded Config Preset \"{property.Name}\" found for {Name}", LogLevel.Debug); - - conf.Load(path, property, property.GetValue(this)); - } - } - - /// - /// Loads all config presets to the preset List. - /// - /// The base event path. - private void _loadPresets(string path) - { - foreach (string file in Directory.GetFiles(path, "*.yml")) - { - string fileName = Path.GetFileNameWithoutExtension(file); - - object conf = Configs.Serialization.Deserializer.Deserialize(File.ReadAllText(file), _confTypes.FirstOrDefault() ?? typeof(EventConfig)); - if (conf is not EventConfig) - { - DebugLogger.LogDebug("Not Event Config."); - continue; - } - // DebugLogger.LogDebug($"Config Preset \"{file}\" loaded for {Name}", LogLevel.Debug); - ((EventConfig)conf).PresetName = fileName; - ConfigPresets.Add((EventConfig)conf); - DebugLogger.LogDebug($"Config Preset: {conf.GetType().Name}, BaseType: {conf.GetType().BaseType?.Name}"); - } - } - - /// - /// Loads any translations present - /// - internal void LoadTranslation() - { - /*if (this is ITranslation) - { - - }*/ - } - /// - /// Triggers internal actions to stop an event. - /// - private void OnInternalStop() - { - KillLoop = true; - Timing.KillCoroutines(new CoroutineHandle[] { BroadcastCoroutine }); - Timing.CallDelayed(FrameDelayInSeconds + .1f, () => - { - if (GameCoroutine.IsRunning) - { - Timing.KillCoroutines(new CoroutineHandle[] { GameCoroutine }); - } - OnInternalCleanup(); - }); - - try - { - OnStop(); - } - catch (Exception e) - { - - DebugLogger.LogDebug($"Caught an exception at Event.OnStop().", LogLevel.Warn, true); - DebugLogger.LogDebug($"{e}", LogLevel.Debug); - } - EventStopped?.Invoke(Name); - - } - /// - /// Used to trigger plugin events in the right order. - /// - private void OnInternalStart() - { - KillLoop = false; - _cleanupRun = false; - AutoEvent.ActiveEvent = this; - EventTime = new TimeSpan(); - StartTime = DateTime.UtcNow; - - try - { - // todo finish implementation. - if (this.ForceEnableFriendlyFire == FriendlyFireSettings.Enable) - { - FriendlyFireSystem.EnableFriendlyFire(this.ForceEnableFriendlyFireAutoban == FriendlyFireSettings.Enable); - return; - } - - if (this.ForceEnableFriendlyFire == FriendlyFireSettings.Disable) - { - FriendlyFireSystem.DisableFriendlyFire(); - return; - } - - if (this.ForceEnableFriendlyFireAutoban == FriendlyFireSettings.Enable) - { - FriendlyFireSystem.EnableFriendlyFireDetector(); - return; - } - - if (this.ForceEnableFriendlyFireAutoban == FriendlyFireSettings.Disable) - { - FriendlyFireSystem.DisableFriendlyFireDetector(); - } - } - catch (Exception e) - { - DebugLogger.LogDebug($"Could not modify friendly fire / ff autoban settings.", LogLevel.Error, true); - DebugLogger.LogDebug($"{e}"); - } - - SpawnMap(true); - try - { - RegisterEvents(); - } - catch (Exception e) - { - - DebugLogger.LogDebug($"Caught an exception at Event.RegisterEvents().", LogLevel.Warn, true); - DebugLogger.LogDebug($"{e}", LogLevel.Debug); - - } - - try - { - OnStart(); - } - catch (Exception e) - { - - DebugLogger.LogDebug($"Caught an exception at Event.OnStart().", LogLevel.Warn, true); - DebugLogger.LogDebug($"{e}", LogLevel.Debug); - } - EventStarted?.Invoke(Name); - StartAudio(true); - Timing.RunCoroutine(RunTimingCoroutine(), "TimingCoroutine"); - } - - /// - /// Used to prevent blocking the main game thread while triggering other coroutines. - /// - /// - private IEnumerator RunTimingCoroutine() - { - BroadcastCoroutine = Timing.RunCoroutine(BroadcastStartCountdown(), "Broadcast Coroutine"); - yield return Timing.WaitUntilDone(BroadcastCoroutine); - if (KillLoop) - { - yield break; - } - try - { - CountdownFinished(); - } - catch (Exception e) - { - DebugLogger.LogDebug($"Caught an exception at Event.CountdownFinished().", LogLevel.Warn, true); - DebugLogger.LogDebug($"{e}", LogLevel.Debug); - } - GameCoroutine = Timing.RunCoroutine(RunGameCoroutine(), "Event Coroutine"); - yield return Timing.WaitUntilDone(GameCoroutine); - if (KillLoop) - { - yield break; - } - try - { - OnFinished(); - } - catch (Exception e) - { - DebugLogger.LogDebug($"Caught an exception at Event.OnFinished().", LogLevel.Warn, true); - DebugLogger.LogDebug($"{e}", LogLevel.Debug); - } - var handle = Timing.CallDelayed(PostRoundDelay, () => - { - if (!_cleanupRun) - { - OnInternalCleanup(); - } - }); - yield return Timing.WaitUntilDone(handle); - } - - /// - /// The coroutine that is called for processing frames. We recommend avoiding overrides to this, since this may mess with other logic. - /// - /// - protected virtual IEnumerator RunGameCoroutine() - { - while (!IsRoundDone() || DebugLogger.AntiEnd) - { - if (KillLoop) - { - yield break; - } - try - { - ProcessFrame(); - } - catch (Exception e) - { - DebugLogger.LogDebug($"Caught an exception at Event.ProcessFrame().", LogLevel.Warn, true); - DebugLogger.LogDebug($"{e}", LogLevel.Debug); - } - - EventTime += TimeSpan.FromSeconds(FrameDelayInSeconds); - yield return Timing.WaitForSeconds(this.FrameDelayInSeconds); - } - yield break; - } - - /// - /// Used to prevent double cleanups. - /// - private bool _cleanupRun = false; - - /// - /// The internal method used to trigger cleanup for maps, ragdolls, items, sounds, and teleporting players to the spawn room. - /// - private void OnInternalCleanup() - { - _cleanupRun = true; - try - { - UnregisterEvents(); - } - catch (Exception e) - { - DebugLogger.LogDebug($"Caught an exception at Event.OnUnregisterEvents().", LogLevel.Warn, true); - DebugLogger.LogDebug($"{e}", LogLevel.Debug); - } - - try - { - FriendlyFireSystem.RestoreFriendlyFire(); - } - catch (Exception e) - { - DebugLogger.LogDebug($"Friendly Fire was not able to be restored. Please ensure it is disabled. PLAYERS MAY BE AUTO-BANNED ACCIDENTALLY OR MAY NOT BE BANNED FOR FF.", LogLevel.Error, true); - DebugLogger.LogDebug($"{e}"); - } - - try - { - DeSpawnMap(); - StopAudio(); - Extensions.CleanUpAll(); - Extensions.TeleportEnd(); - - } - catch (Exception e) - { - DebugLogger.LogDebug("Caught an exception at Event.OnInternalCleanup().GeneralCleanup().", LogLevel.Warn, true); - DebugLogger.LogDebug($"{e}", LogLevel.Debug); - } - - try - { - OnCleanup(); - } - catch (Exception e) - { - DebugLogger.LogDebug($"Caught an exception at Event.OnCleanup().", LogLevel.Warn, true); - DebugLogger.LogDebug($"{e}", LogLevel.Debug); - } - - // StartTime = null; - // EventTime = null; - try - { - CleanupFinished?.Invoke(Name); - } - catch (Exception e) - { - DebugLogger.LogDebug($"Caught an exception at Event.CleanupFinished.Invoke().", LogLevel.Warn, true); - DebugLogger.LogDebug($"{e}", LogLevel.Debug); - } - AutoEvent.ActiveEvent = null; - try - { - EventConfig conf = this.GetCurrentConfigsValues().FirstOrDefault(); - if (conf is not null) - { - this._setRandomMap(conf); - this._setRandomSound(conf); - } - } - catch (Exception e) - { - DebugLogger.LogDebug($"Caught an exception at Event._setMap.", LogLevel.Warn, true); - DebugLogger.LogDebug($"{e}", LogLevel.Debug); - } - - } - #endregion - #region Event Events // These events are triggered internally and can be used by an event manager to detect when certain stages are complete. - public delegate void EventStoppedHandler(string eventName); - public delegate void CleanupFinishedHandler(string eventName); - public delegate void EventStartedHandler(string eventName); - - /// - /// Called when the event start is triggered. - /// - public virtual event EventStartedHandler EventStarted; - - /// - /// Called when the event cleanup is finished. The event is completely finished and disposed of once this is called. - /// - public virtual event CleanupFinishedHandler CleanupFinished; - - /// - /// Called when the event is stopped. When the event is stopped, OnFinished() won't be called, but OnCleanup() will be called. - /// - public virtual event EventStoppedHandler EventStopped; - #endregion -#endregion - } -} diff --git a/AutoEvent-NWApi/Loader.cs b/AutoEvent-NWApi/Loader.cs deleted file mode 100644 index 2f5ec0f7..00000000 --- a/AutoEvent-NWApi/Loader.cs +++ /dev/null @@ -1,398 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.IO.Compression; -using System.Reflection; -using AutoEvent.Interfaces; -using PluginAPI.Helpers; -using PluginAPI.Core; - -namespace AutoEvent; - -public class Loader -{ - /// - /// Overrides the Exiled check for the version of the plugin that is exiled exclusive. - /// -#if EXILED - private const bool IsExiledPlugin = true; -#else - private const bool IsExiledPlugin = false; -#endif - /// - /// If enabled, a debug log is output everytime a plugin is loaded. Not necessary for players. - /// - private const bool LogAllPluginsOnRegister = false; - - /// - /// Debug logging only - /// - private static bool Debug => AutoEvent.Debug; - - /// - /// Checks to see if exiled is present on this server. - /// - /// - private static bool isExiledPresent() - { - if (IsExiledPlugin) - { - return true; - } - foreach (Assembly ass in AppDomain.CurrentDomain.GetAssemblies()) - { - if (ass.GetName().Name == "Exiled.Loader") - { - return true; - } - } - return false; - - } - /// - /// Gets plugin dependencies. - /// - public static List Dependencies { get; } = new(); - - /// - /// A list of additional events found. - /// - public static List Events = new List(); - - /// - /// Loads all plugins. - /// - public static void LoadEvents() - { - Dictionary locations = new Dictionary(); -#if !EXILED - string filepath = AutoEvent.Singleton.Config.ExternalEventsDirectoryPath; -#else - string filepath = Path.Combine(AutoEvent.BaseConfigPath, "Events"); -#endif - foreach (string assemblyPath in Directory.GetFiles(filepath, "*.dll")) - { - try - { - - Assembly assembly = LoadAssembly(assemblyPath); - - if (assembly is null) - continue; - - locations[assembly] = assemblyPath; - } - catch (TargetInvocationException e) - { - - DebugLogger.LogDebug("[ExternalEventLoader] Could not load a plugin. Check to make sure it does not require exiled or that you have exiled installed.", LogLevel.Warn, true); - DebugLogger.LogDebug(e.ToString(),LogLevel.Debug); - } - catch (Exception e) - { - - DebugLogger.LogDebug($"[ExternalEventLoader] Could not load a plugin due to an error.", LogLevel.Warn, true); - DebugLogger.LogDebug(e.ToString(),LogLevel.Debug); - } - } - - foreach (Assembly assembly in locations.Keys) - { - if (locations[assembly].Contains("dependencies")) - continue; - try - { - - List eventList = CreateEventPlugin(assembly); - foreach (Event eventPlugin in eventList) - { - try - { - - if (eventPlugin is null) - continue; - - if (!eventPlugin.AutoLoad) - { - continue; - } - AssemblyInformationalVersionAttribute attribute = - assembly.GetCustomAttribute(); - - DebugLogger.LogDebug($"[ExternalEventLoader] Loaded Event {eventPlugin.Name} by {(eventPlugin.Author is not null ? $"{eventPlugin.Author}" : attribute is not null ? attribute.InformationalVersion : string.Empty)}", LogLevel.Info, LogAllPluginsOnRegister); - - try - { - eventPlugin.VerifyEventInfo(); - eventPlugin.LoadConfigs(); - eventPlugin.LoadTranslation(); - eventPlugin.InstantiateEvent(); - } - catch (Exception e) - { - DebugLogger.LogDebug($"[EventLoader] {eventPlugin.Name} encountered an error while registering.",LogLevel.Warn, true); - DebugLogger.LogDebug(e.ToString(),LogLevel.Debug); - } - Events.Add(eventPlugin); - } - catch (Exception) - { - //unused - } - } - } - catch (Exception) - { - // unused - } - } - } - - /// - /// Loads an assembly. - /// - /// The path to load the assembly from. - /// Returns the loaded assembly or . - public static Assembly LoadAssembly(string path) - { - try - { - Assembly assembly = Assembly.Load(File.ReadAllBytes(path)); - - ResolveAssemblyEmbeddedResources(assembly); - - return assembly; - } - catch (Exception exception) - { - DebugLogger.LogDebug($"[ExternalEventLoader] Error while loading an assembly at {path}! {exception}", LogLevel.Warn); - } - - return null; - } - - /// - /// Create a plugin instance. - /// - /// The event assembly. - /// Returns the created plugin instance or . - public static List CreateEventPlugin(Assembly assembly) - { - List eventsFound = new List(); - try - { - foreach (Type type in assembly.GetTypes()) - { - try - { - if (type.IsAbstract || type.IsInterface) - { - DebugLogger.LogDebug( - $"[ExternalEventLoader] \"{type.FullName}\" is an interface or abstract class, skipping.", - LogLevel.Debug); - - continue; - } - - if (!IsDerivedFromPlugin(type)) - { - DebugLogger.LogDebug( - $"[ExternalEventLoader] \"{type.FullName}\" does not inherit from Event, skipping.", - LogLevel.Debug); - - continue; - } - - if(type.GetInterface(nameof(IExiledEvent)) is not null && !isExiledPresent()) - { - DebugLogger.LogDebug($"[ExternalEventLoader] Cannot register plugin {type.Name} because it requires exiled to work. Exiled has not loaded yet, or is not present at all.",LogLevel.Warn, true); - continue; - } - - DebugLogger.LogDebug($"[ExternalEventLoader] Loading type {type.FullName}", LogLevel.Debug); - - Event plugin = null; - - ConstructorInfo constructor = type.GetConstructor(Type.EmptyTypes); - if (constructor is not null) - { - - DebugLogger.LogDebug("[ExternalEventLoader] Public default constructor found, creating instance...", LogLevel.Debug); - - plugin = constructor.Invoke(null) as Event; - } - else - { - - DebugLogger.LogDebug($"[ExternalEventLoader] Constructor wasn't found, searching for a property with the {type.FullName} type...", LogLevel.Debug); - - - object value = Array - .Find( - type.GetProperties(BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public), - property => property.PropertyType == type)?.GetValue(null); - - if (value is not null) - plugin = value as Event; - } - - if (plugin is null) - { - DebugLogger.LogDebug($"[ExternalEventLoader] {type.FullName} is a valid event, but it cannot be instantiated! It either doesn't have a public default constructor without any arguments or a static property of the {type.FullName} type!", LogLevel.Error, true); - continue; - } - - DebugLogger.LogDebug($"[ExternalEventLoader] Instantiated type {type.FullName}", LogLevel.Debug); - - eventsFound.Add(plugin); - } - catch (ReflectionTypeLoadException reflectionTypeLoadException) - { - DebugLogger.LogDebug("[ExternalEventLoader] An external event has failed to load! Ensure that you have Exiled installed, or that all of the plugins don't require Exiled.", LogLevel.Warn, true); - DebugLogger.LogDebug($"[ExternalEventLoader] Error while initializing event {assembly.GetName().Name} (at {assembly.Location})! {reflectionTypeLoadException}", LogLevel.Debug); - - foreach (Exception loaderException in reflectionTypeLoadException.LoaderExceptions) - { - DebugLogger.LogDebug($"[ExternalEventLoader] {loaderException}", LogLevel.Warn); - } - } - catch (Exception exception) - { - DebugLogger.LogDebug("[ExternalEventLoader] An external event has failed to load! Ensure that you have Exiled installed, or that all of the plugins don't require Exiled.", LogLevel.Warn, true); - DebugLogger.LogDebug($"[ExternalEventLoader] Error while initializing plugin {assembly.GetName().Name} (at {assembly.Location})! {exception}", LogLevel.Debug); - } - } - return eventsFound; - } - catch (ReflectionTypeLoadException reflectionTypeLoadException) - { - DebugLogger.LogDebug("[ExternalEventLoader] An external event has failed to load! Ensure that you have Exiled installed, or that all of the plugins don't require Exiled.", LogLevel.Warn, true); - DebugLogger.LogDebug($"[ExternalEventLoader] Error while initializing event {assembly.GetName().Name} (at {assembly.Location})! {reflectionTypeLoadException}", LogLevel.Debug); - - - - foreach (Exception loaderException in reflectionTypeLoadException.LoaderExceptions) - { - DebugLogger.LogDebug($"[ExternalEventLoader] {loaderException}", LogLevel.Error); - } - } - catch (Exception exception) - { - DebugLogger.LogDebug("[ExternalEventLoader] An external event has failed to load! Ensure that you have Exiled installed, or that all of the plugins don't require Exiled.", LogLevel.Warn, true); - DebugLogger.LogDebug($"[ExternalEventLoader] Error while initializing plugin {assembly.GetName().Name} (at {assembly.Location})! {exception}", LogLevel.Error); - - } - - return eventsFound; - } - - /// - /// Indicates that the passed type is derived from the plugin type. - /// - /// Type. - /// if passed type is derived from , otherwise . - private static bool IsDerivedFromPlugin(Type type) - { - while (type is not null) - { - type = type.BaseType; - - if (type == typeof(Event)) - return true; - - if (type is { IsGenericType: true }) - { - Type genericTypeDef = type.GetGenericTypeDefinition(); - DebugLogger.LogDebug($"[ExternalEventLoader] Generic type {genericTypeDef}", LogLevel.Debug); - - - if (genericTypeDef == typeof(Event)) - return true; - } - else - { - DebugLogger.LogDebug($"[ExternalEventLoader] Not Generic Type {type?.Name}.", LogLevel.Debug); - } - } - - return false; - } - - /// - /// Attempts to load Embedded (compressed) assemblies from specified Assembly. - /// - /// Assembly to check for embedded assemblies. - private static void ResolveAssemblyEmbeddedResources(Assembly target) - { - try - { - - DebugLogger.LogDebug($"[ExternalEventLoader] Attempting to load embedded resources for {target.FullName}", LogLevel.Debug); - - - string[] resourceNames = target.GetManifestResourceNames(); - - foreach (string name in resourceNames) - { - - DebugLogger.LogDebug($"[ExternalEventLoader] Found resource {name}", LogLevel.Debug); - - - if (name.EndsWith(".dll", StringComparison.OrdinalIgnoreCase)) - { - using MemoryStream stream = new(); - - - DebugLogger.LogDebug($"[ExternalEventLoader] Loading resource {name}", LogLevel.Debug); - - - Stream dataStream = target.GetManifestResourceStream(name); - - if (dataStream == null) - { - - DebugLogger.LogDebug($"[ExternalEventLoader] Unable to resolve resource {name} Stream was null", LogLevel.Error, true); - continue; - } - - dataStream.CopyTo(stream); - - Dependencies.Add(Assembly.Load(stream.ToArray())); - - - - DebugLogger.LogDebug($"[ExternalEventLoader] Loaded resource {name}", LogLevel.Debug); - } - else if (name.EndsWith(".dll.compressed", StringComparison.OrdinalIgnoreCase)) - { - Stream dataStream = target.GetManifestResourceStream(name); - - if (dataStream == null) - { - - DebugLogger.LogDebug($"[ExternalEventLoader] Unable to resolve resource {name} Stream was null", LogLevel.Error, true); - continue; - } - - using DeflateStream stream = new(dataStream, CompressionMode.Decompress); - using MemoryStream memStream = new(); - - - DebugLogger.LogDebug($"[ExternalEventLoader] Loading resource {name}", LogLevel.Debug); - - stream.CopyTo(memStream); - - Dependencies.Add(Assembly.Load(memStream.ToArray())); - - - DebugLogger.LogDebug($"[ExternalEventLoader] Loaded resource {name}", LogLevel.Debug); - } - } - } - catch (Exception exception) - { - - DebugLogger.LogDebug($"[ExternalEventLoader] Failed to load embedded resources from {target.FullName}: {exception}", LogLevel.Error, true); - } - } -} \ No newline at end of file diff --git a/AutoEvent-NWApi/Plugin.cs b/AutoEvent-NWApi/Plugin.cs deleted file mode 100644 index ea6acae6..00000000 --- a/AutoEvent-NWApi/Plugin.cs +++ /dev/null @@ -1,196 +0,0 @@ -using System; -using System.IO; -using AutoEvent.Commands; -using AutoEvent.Interfaces; -using HarmonyLib; -using PluginAPI.Core.Attributes; -using PluginAPI.Enums; -using PluginAPI.Events; -using AutoEvent.Events.Handlers; -using Exiled.Loader; -using GameCore; -using MEC; -using PluginAPI.Core; -using Event = AutoEvent.Interfaces.Event; -using Log = PluginAPI.Core.Log; -using Paths = PluginAPI.Helpers.Paths; -using Server = PluginAPI.Core.Server; -#if EXILED -using Exiled.API.Features; - -#endif -namespace AutoEvent -{ -#if EXILED - public class AutoEvent : Plugin - { - public override System.Version Version => new System.Version(9, 1, 7); - public override string Name => "AutoEvent"; - public override string Author => "Created by KoT0XleB, extended by swd and sky, Co-Maintained by Redforce04"; - public static bool IsPlayedGames; - -#else - public class AutoEvent - { - [PluginConfig("Configs/autoevent.yml")] - public Config Config; - - [PluginConfig("Configs/translation.yml")] - public Translation Translation; -#endif - public const bool BetaRelease = true; // todo set beta to false before main release - /// - /// The location of the AutoEvent folder for schematics, music, external events and event config / translations. - /// - /// /home/container/.config/SCP Secret Laboratory/PluginAPI/plugins/global/AutoEvent/ - public static string BaseConfigPath { get; set;} - public static IEvent ActiveEvent; - public static AutoEvent Singleton; - public static Harmony HarmonyPatch; - public static bool Debug => DebugLogger.Debug; - EventHandler eventHandler; - -#if EXILED - public override void OnEnabled() -#else - [PluginPriority(LoadPriority.Low)] - [PluginEntryPoint("AutoEvent", "9.1.7", "An event manager plugin that allows you to run mini-games.", - "KoT0XleB and Redforce04")] - void OnEnabled() -#endif - { - if (!Config.IsEnabled) return; - if (BetaRelease) - { - Log.Warning("Warning: This release of AutoEvent is a Beta-Release." + - " If you encounter any bugs, please reach out to Redforce04 (redforce04) or KoT0XleB (spagettimen) via discord." + - " Alternatively, make an issue on our github (https://github.com/KoT0XleB/AutoEvent/). Have fun!"); - } - - // Call Costura first just to ensure dependencies are loaded. - // Also make sure there isn't anything that needs a dependency in this method. - CosturaUtility.Initialize(); - -#if !EXILED - // Root plugin path - AutoEvent.BaseConfigPath = Path.Combine(Paths.GlobalPlugins.Plugins, "AutoEvent"); -#else - AutoEvent.BaseConfigPath = Path.Combine(Exiled.API.Features.Paths.Configs, "AutoEvent"); -#endif - _startup(); - } - - private void _startup() - { - try - { - Singleton = this; - if (Config.IgnoredRoles.Contains(Config.LobbyRole)) - { - DebugLogger.LogDebug("The Lobby Role is also in ignored roles. This will break the game if not changed. The plugin will remove the lobby role from ignored roles.", LogLevel.Error, true); - Config.IgnoredRoles.Remove(Config.LobbyRole); - } - - FriendlyFireSystem.IsFriendlyFireEnabledByDefault = Server.FriendlyFire; - var debugLogger = new DebugLogger(Config.AutoLogDebug); - DebugLogger.Debug = Config.Debug; - if (DebugLogger.Debug) - { - DebugLogger.LogDebug($"Debug Mode Enabled", LogLevel.Info, true); - } - - try - { - HarmonyPatch = new Harmony("autoevent"); - HarmonyPatch.PatchAll(); - - } - catch (Exception e) - { - Log.Warning("Could not patch harmony methods."); - Log.Debug($"{e}"); - } - - eventHandler = new EventHandler(); - EventManager.RegisterEvents(eventHandler); - EventManager.RegisterEvents(this); - SCPSLAudioApi.Startup.SetupDependencies(); - - Servers.RemoteAdmin += eventHandler.OnRemoteAdmin; - try - { - DebugLogger.LogDebug($"Base Conf Path: {BaseConfigPath}"); - DebugLogger.LogDebug($"Configs paths: \n" + - $"{Config.SchematicsDirectoryPath}\n" + - $"{Config.MusicDirectoryPath}\n" + - $"{Config.ExternalEventsDirectoryPath}\n" + - $"{Config.EventConfigsDirectoryPath}\n"); - CreateDirectoryIfNotExists(BaseConfigPath); - CreateDirectoryIfNotExists(Config.SchematicsDirectoryPath); - CreateDirectoryIfNotExists(Config.MusicDirectoryPath); - CreateDirectoryIfNotExists(Config.ExternalEventsDirectoryPath); - CreateDirectoryIfNotExists(Config.EventConfigsDirectoryPath); - } - catch (Exception e) - { - DebugLogger.LogDebug($"An error has occured while trying to initialize directories.", LogLevel.Warn, true); - DebugLogger.LogDebug($"{e}"); - } - - - Event.RegisterInternalEvents(); - Loader.LoadEvents(); - Event.Events.AddRange(Loader.Events); - - DebugLogger.LogDebug( - Loader.Events.Count > 0 - ? $"[ExternalEventLoader] Loaded {Loader.Events.Count} external event{(Loader.Events.Count > 1 ? "s" : "")}." - : "No external events were found.", LogLevel.Info, true); - } - catch (Exception e) - { - Log.Warning("Caught an exception while starting plugin."); - Log.Debug($"{e}"); - - } - - Timing.CallDelayed(3f, () => - { - PermissionSystem.Load(); - }); - } - public static void CreateDirectoryIfNotExists(string directory, string subPath = "") - { - string path = ""; - try - { - path = subPath == "" ? directory : Path.Combine(directory, subPath); - // DebugLogger.LogDebug($"Filepath: {path}"); - if (!Directory.Exists(path)) - { - Directory.CreateDirectory(path); - } - } - catch (Exception e) - { - DebugLogger.LogDebug($"An error has occured while trying to create a new directory.", LogLevel.Warn, true); - DebugLogger.LogDebug($"Path: {path}"); - DebugLogger.LogDebug($"{e}"); - } - } -#if !EXILED - [PluginUnload] - void OnDisabled() -#else - public override void OnDisabled() -#endif - { - Servers.RemoteAdmin -= eventHandler.OnRemoteAdmin; - eventHandler = null; - - EventManager.UnregisterEvents(this); - HarmonyPatch.UnpatchAll(); - Singleton = null; - } - } -} diff --git a/AutoEvent/API/Components/SchematicCollisionComponent.cs b/AutoEvent/API/Components/SchematicCollisionComponent.cs index 27661cd9..05af241e 100644 --- a/AutoEvent/API/Components/SchematicCollisionComponent.cs +++ b/AutoEvent/API/Components/SchematicCollisionComponent.cs @@ -14,8 +14,8 @@ using System.Collections.Generic; using System.Linq; using AdminToys; -using AutoEvent.API.Schematic; -using AutoEvent.API.Schematic.Objects; +using MER.Lite; +using MER.Lite.Objects; using Mirror; using PlayerStatsSystem; using PluginAPI.Core; diff --git a/AutoEvent/API/Extensions.cs b/AutoEvent/API/Extensions.cs index ecfe3e4b..60fe52a7 100644 --- a/AutoEvent/API/Extensions.cs +++ b/AutoEvent/API/Extensions.cs @@ -7,8 +7,8 @@ using PlayerRoles; using SCPSLAudioApi.AudioCore; using VoiceChat; -using AutoEvent.API.Schematic.Objects; -using AutoEvent.API.Schematic; +using MER.Lite.Objects; +using MER.Lite; using PluginAPI.Core; using InventorySystem.Items.Pickups; using PlayerStatsSystem; diff --git a/AutoEvent/AutoEvent.csproj b/AutoEvent/AutoEvent.csproj index bc6ca5c6..56b8d2ba 100644 --- a/AutoEvent/AutoEvent.csproj +++ b/AutoEvent/AutoEvent.csproj @@ -78,4 +78,26 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/AutoEvent/AutoEvent.sln b/AutoEvent/AutoEvent.sln index ce9ffeb8..5e914e05 100644 --- a/AutoEvent/AutoEvent.sln +++ b/AutoEvent/AutoEvent.sln @@ -5,6 +5,10 @@ VisualStudioVersion = 17.5.33627.172 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutoEvent", "AutoEvent.csproj", "{3C3FC008-22E1-4B28-BA50-A241B30CC216}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SchematicApi", "SchematicApi\SchematicApi.csproj", "{580DFED2-B2D7-4B89-B245-D60246BCFB79}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PowerupApi", "PowerupApi\PowerupApi.csproj", "{1B07FE64-A112-499D-8A55-67EE912B1CB7}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Release NWApi|Any CPU = Release NWApi|Any CPU @@ -15,6 +19,14 @@ Global {3C3FC008-22E1-4B28-BA50-A241B30CC216}.Release NWApi|Any CPU.Build.0 = Release NWApi|Any CPU {3C3FC008-22E1-4B28-BA50-A241B30CC216}.Release Exiled|Any CPU.ActiveCfg = Release EXILED|Any CPU {3C3FC008-22E1-4B28-BA50-A241B30CC216}.Release Exiled|Any CPU.Build.0 = Release EXILED|Any CPU + {580DFED2-B2D7-4B89-B245-D60246BCFB79}.Release NWApi|Any CPU.ActiveCfg = Debug|Any CPU + {580DFED2-B2D7-4B89-B245-D60246BCFB79}.Release NWApi|Any CPU.Build.0 = Debug|Any CPU + {580DFED2-B2D7-4B89-B245-D60246BCFB79}.Release Exiled|Any CPU.ActiveCfg = Debug|Any CPU + {580DFED2-B2D7-4B89-B245-D60246BCFB79}.Release Exiled|Any CPU.Build.0 = Debug|Any CPU + {1B07FE64-A112-499D-8A55-67EE912B1CB7}.Release NWApi|Any CPU.ActiveCfg = Debug|Any CPU + {1B07FE64-A112-499D-8A55-67EE912B1CB7}.Release NWApi|Any CPU.Build.0 = Debug|Any CPU + {1B07FE64-A112-499D-8A55-67EE912B1CB7}.Release Exiled|Any CPU.ActiveCfg = Debug|Any CPU + {1B07FE64-A112-499D-8A55-67EE912B1CB7}.Release Exiled|Any CPU.Build.0 = Debug|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/AutoEvent/Commands/Debug/PowerupCommand.cs b/AutoEvent/Commands/Debug/PowerupCommand.cs index 42dbcb96..4613fe54 100644 --- a/AutoEvent/Commands/Debug/PowerupCommand.cs +++ b/AutoEvent/Commands/Debug/PowerupCommand.cs @@ -17,6 +17,8 @@ using AutoEvent.Interfaces; using CommandSystem; using PluginAPI.Core; +using Powerups; +using Powerups.Api; using UnityEngine; using Player = PluginAPI.Core.Player; #if EXILED @@ -28,7 +30,7 @@ namespace AutoEvent.Commands.Debug; public class PowerupCommand : ICommand, IPermission, IUsageProvider { - public string Command => nameof(Interfaces.Powerup); + public string Command => "Powerup"; public string[] Aliases => Array.Empty(); public string Description => "Manages powerups."; public string[] Usage => new []{ "Give / Remove / Spawn / List", "Player / Powerup", "Powerup / Position X", "Position Y", "Position Z" }; @@ -47,7 +49,7 @@ public bool Execute(ArraySegment arguments, ICommandSender sender, out s goto usage; } Player ply = null!; - Interfaces.Powerup powerup = null!; + Powerup powerup = null!; switch (arguments.At(0).ToLower()) { @@ -142,7 +144,7 @@ public bool Execute(ArraySegment arguments, ICommandSender sender, out s case 1: if (arguments.At(i) == "*") { - foreach (Interfaces.Powerup powerupInstance in PowerupManager.RegisteredPowerups) + foreach (Powerup powerupInstance in PowerupManager.RegisteredPowerups) { if (powerupInstance.ActivePlayers.ContainsKey(ply)) { diff --git a/AutoEvent/FodyWeavers.xml b/AutoEvent/FodyWeavers.xml index 13ea034e..447bbee0 100644 --- a/AutoEvent/FodyWeavers.xml +++ b/AutoEvent/FodyWeavers.xml @@ -7,6 +7,8 @@ System.ComponentModel.DataAnnotations YamlDotNet NVorbis + PowerupApi + SchematicApi diff --git a/AutoEvent/Games/Battle/Features/RandomClass.cs b/AutoEvent/Games/Battle/Features/RandomClass.cs index 56a3d460..2ae8b2f3 100644 --- a/AutoEvent/Games/Battle/Features/RandomClass.cs +++ b/AutoEvent/Games/Battle/Features/RandomClass.cs @@ -1,6 +1,6 @@ using System; using System.Collections.Generic; -using AutoEvent.API.Schematic.Objects; +using MER.Lite.Objects; using PluginAPI.Core; using System.Linq; using AutoEvent.Games.Example; diff --git a/AutoEvent/Games/Battle/Plugin.cs b/AutoEvent/Games/Battle/Plugin.cs index aa9339fb..66da4538 100644 --- a/AutoEvent/Games/Battle/Plugin.cs +++ b/AutoEvent/Games/Battle/Plugin.cs @@ -1,4 +1,4 @@ -using AutoEvent.API.Schematic.Objects; +using MER.Lite.Objects; using AutoEvent.Events.Handlers; using MEC; using PlayerRoles; diff --git a/AutoEvent/Games/Boss/Features/RandomClass.cs b/AutoEvent/Games/Boss/Features/RandomClass.cs index a67ca905..d140f373 100644 --- a/AutoEvent/Games/Boss/Features/RandomClass.cs +++ b/AutoEvent/Games/Boss/Features/RandomClass.cs @@ -1,4 +1,4 @@ -using AutoEvent.API.Schematic.Objects; +using MER.Lite.Objects; using PluginAPI.Core; using System.Linq; using UnityEngine; diff --git a/AutoEvent/Games/Boss/Plugin.cs b/AutoEvent/Games/Boss/Plugin.cs index 13c0f19a..b683b477 100644 --- a/AutoEvent/Games/Boss/Plugin.cs +++ b/AutoEvent/Games/Boss/Plugin.cs @@ -1,4 +1,4 @@ -using AutoEvent.API.Schematic.Objects; +using MER.Lite.Objects; using MEC; using PlayerRoles; using PluginAPI.Core; diff --git a/AutoEvent/Games/DeathParty/Features/RandomClass.cs b/AutoEvent/Games/DeathParty/Features/RandomClass.cs index ff6db92a..f56a3e44 100644 --- a/AutoEvent/Games/DeathParty/Features/RandomClass.cs +++ b/AutoEvent/Games/DeathParty/Features/RandomClass.cs @@ -1,4 +1,4 @@ -using AutoEvent.API.Schematic.Objects; +using MER.Lite.Objects; using System.Linq; using UnityEngine; diff --git a/AutoEvent/Games/DeathParty/Plugin.cs b/AutoEvent/Games/DeathParty/Plugin.cs index a3a54f37..8a245df3 100644 --- a/AutoEvent/Games/DeathParty/Plugin.cs +++ b/AutoEvent/Games/DeathParty/Plugin.cs @@ -7,7 +7,7 @@ using PlayerRoles; using PluginAPI.Core; using PluginAPI.Events; -using AutoEvent.API.Schematic.Objects; +using MER.Lite.Objects; using AutoEvent.Events.Handlers; using AutoEvent.Games.Infection; using AutoEvent.Interfaces; diff --git a/AutoEvent/Games/Deathmatch/Extensions/RandomClass.cs b/AutoEvent/Games/Deathmatch/Extensions/RandomClass.cs index 283e17d7..d3e7477c 100644 --- a/AutoEvent/Games/Deathmatch/Extensions/RandomClass.cs +++ b/AutoEvent/Games/Deathmatch/Extensions/RandomClass.cs @@ -1,4 +1,4 @@ -using AutoEvent.API.Schematic.Objects; +using MER.Lite.Objects; using System.Collections.Generic; using System.Linq; using UnityEngine; diff --git a/AutoEvent/Games/Deathmatch/Plugin.cs b/AutoEvent/Games/Deathmatch/Plugin.cs index 3261e166..0361a324 100644 --- a/AutoEvent/Games/Deathmatch/Plugin.cs +++ b/AutoEvent/Games/Deathmatch/Plugin.cs @@ -1,5 +1,5 @@ using CustomPlayerEffects; -using AutoEvent.API.Schematic.Objects; +using MER.Lite.Objects; using MEC; using PlayerRoles; using PluginAPI.Core; diff --git a/AutoEvent/Games/Example/Features/RandomClass.cs b/AutoEvent/Games/Example/Features/RandomClass.cs index 8d027ce2..3a280f5f 100644 --- a/AutoEvent/Games/Example/Features/RandomClass.cs +++ b/AutoEvent/Games/Example/Features/RandomClass.cs @@ -1,5 +1,5 @@ using System.Collections.Generic; -using AutoEvent.API.Schematic.Objects; +using MER.Lite.Objects; using PluginAPI.Core; using System.Linq; using UnityEngine; diff --git a/AutoEvent/Games/FallDown/Extensions/RandomClass.cs b/AutoEvent/Games/FallDown/Extensions/RandomClass.cs index dcc6cc06..83b0e270 100644 --- a/AutoEvent/Games/FallDown/Extensions/RandomClass.cs +++ b/AutoEvent/Games/FallDown/Extensions/RandomClass.cs @@ -1,4 +1,4 @@ -using AutoEvent.API.Schematic.Objects; +using MER.Lite.Objects; using System.Linq; using UnityEngine; diff --git a/AutoEvent/Games/FallDown/Plugin.cs b/AutoEvent/Games/FallDown/Plugin.cs index 328fe71a..4890808b 100644 --- a/AutoEvent/Games/FallDown/Plugin.cs +++ b/AutoEvent/Games/FallDown/Plugin.cs @@ -1,4 +1,4 @@ -using AutoEvent.API.Schematic.Objects; +using MER.Lite.Objects; using MEC; using PlayerRoles; using PluginAPI.Core; diff --git a/AutoEvent/Games/FinishWay/Extensions/RandomClass.cs b/AutoEvent/Games/FinishWay/Extensions/RandomClass.cs index bbacffb7..2b50624a 100644 --- a/AutoEvent/Games/FinishWay/Extensions/RandomClass.cs +++ b/AutoEvent/Games/FinishWay/Extensions/RandomClass.cs @@ -1,4 +1,4 @@ -using AutoEvent.API.Schematic.Objects; +using MER.Lite.Objects; using System.Linq; using UnityEngine; diff --git a/AutoEvent/Games/FinishWay/Plugin.cs b/AutoEvent/Games/FinishWay/Plugin.cs index a0833f54..4f8be8a4 100644 --- a/AutoEvent/Games/FinishWay/Plugin.cs +++ b/AutoEvent/Games/FinishWay/Plugin.cs @@ -1,4 +1,4 @@ -using AutoEvent.API.Schematic.Objects; +using MER.Lite.Objects; using AutoEvent.Events.Handlers; using MEC; using PlayerRoles; diff --git a/AutoEvent/Games/Football/Features/RandomClass.cs b/AutoEvent/Games/Football/Features/RandomClass.cs index 341190e7..908b7c36 100644 --- a/AutoEvent/Games/Football/Features/RandomClass.cs +++ b/AutoEvent/Games/Football/Features/RandomClass.cs @@ -1,4 +1,4 @@ -using AutoEvent.API.Schematic.Objects; +using MER.Lite.Objects; using System.Linq; using UnityEngine; diff --git a/AutoEvent/Games/Football/Plugin.cs b/AutoEvent/Games/Football/Plugin.cs index 9bf2fab3..ce5e989f 100644 --- a/AutoEvent/Games/Football/Plugin.cs +++ b/AutoEvent/Games/Football/Plugin.cs @@ -8,7 +8,7 @@ using AutoEvent.Games.Football.Features; using PluginAPI.Events; using PluginAPI.Core; -using AutoEvent.API.Schematic.Objects; +using MER.Lite.Objects; using AutoEvent.Events.Handlers; using AutoEvent.Games.Infection; using AutoEvent.Interfaces; diff --git a/AutoEvent/Games/Glass/Features/RandomClass.cs b/AutoEvent/Games/Glass/Features/RandomClass.cs index 3056b1c3..b9ddc839 100644 --- a/AutoEvent/Games/Glass/Features/RandomClass.cs +++ b/AutoEvent/Games/Glass/Features/RandomClass.cs @@ -1,4 +1,4 @@ -using AutoEvent.API.Schematic.Objects; +using MER.Lite.Objects; using System.Linq; using UnityEngine; diff --git a/AutoEvent/Games/Glass/Plugin.cs b/AutoEvent/Games/Glass/Plugin.cs index 0490b125..544951aa 100644 --- a/AutoEvent/Games/Glass/Plugin.cs +++ b/AutoEvent/Games/Glass/Plugin.cs @@ -11,7 +11,7 @@ using CustomPlayerEffects; using PluginAPI.Core; using PluginAPI.Events; -using AutoEvent.API.Schematic.Objects; +using MER.Lite.Objects; using AutoEvent.Events.Handlers; using AutoEvent.Games.Infection; using AutoEvent.Interfaces; diff --git a/AutoEvent/Games/GunGame/Plugin.cs b/AutoEvent/Games/GunGame/Plugin.cs index d323afb9..5e6fbad8 100644 --- a/AutoEvent/Games/GunGame/Plugin.cs +++ b/AutoEvent/Games/GunGame/Plugin.cs @@ -1,4 +1,4 @@ -using AutoEvent.API.Schematic.Objects; +using MER.Lite.Objects; using AutoEvent.Events.Handlers; using MEC; using PlayerRoles; diff --git a/AutoEvent/Games/HideAndSeek/Features/RandomClass.cs b/AutoEvent/Games/HideAndSeek/Features/RandomClass.cs index 2d401fa6..9d27da92 100644 --- a/AutoEvent/Games/HideAndSeek/Features/RandomClass.cs +++ b/AutoEvent/Games/HideAndSeek/Features/RandomClass.cs @@ -1,4 +1,4 @@ -using AutoEvent.API.Schematic.Objects; +using MER.Lite.Objects; using System.Linq; using UnityEngine; diff --git a/AutoEvent/Games/HideAndSeek/Plugin.cs b/AutoEvent/Games/HideAndSeek/Plugin.cs index 31121c0e..ce1b65e5 100644 --- a/AutoEvent/Games/HideAndSeek/Plugin.cs +++ b/AutoEvent/Games/HideAndSeek/Plugin.cs @@ -1,5 +1,5 @@ using CustomPlayerEffects; -using AutoEvent.API.Schematic.Objects; +using MER.Lite.Objects; using MEC; using PlayerRoles; using PluginAPI.Core; diff --git a/AutoEvent/Games/Infection/Extensions/RandomClass.cs b/AutoEvent/Games/Infection/Extensions/RandomClass.cs index 81d5e571..e0830cd0 100644 --- a/AutoEvent/Games/Infection/Extensions/RandomClass.cs +++ b/AutoEvent/Games/Infection/Extensions/RandomClass.cs @@ -1,4 +1,4 @@ -using AutoEvent.API.Schematic.Objects; +using MER.Lite.Objects; using System.Linq; using UnityEngine; diff --git a/AutoEvent/Games/Infection/Plugin.cs b/AutoEvent/Games/Infection/Plugin.cs index 415591b7..47e6df45 100644 --- a/AutoEvent/Games/Infection/Plugin.cs +++ b/AutoEvent/Games/Infection/Plugin.cs @@ -1,4 +1,4 @@ -using AutoEvent.API.Schematic.Objects; +using MER.Lite.Objects; using AutoEvent.Events.Handlers; using MEC; using PlayerRoles; diff --git a/AutoEvent/Games/Jail/Extensions/JailRandom.cs b/AutoEvent/Games/Jail/Extensions/JailRandom.cs index 9c1ea423..536208a6 100644 --- a/AutoEvent/Games/Jail/Extensions/JailRandom.cs +++ b/AutoEvent/Games/Jail/Extensions/JailRandom.cs @@ -1,5 +1,5 @@ using System; -using AutoEvent.API.Schematic.Objects; +using MER.Lite.Objects; using System.Linq; using UnityEngine; diff --git a/AutoEvent/Games/Jail/Plugin.cs b/AutoEvent/Games/Jail/Plugin.cs index 6f1605ec..784d77ce 100644 --- a/AutoEvent/Games/Jail/Plugin.cs +++ b/AutoEvent/Games/Jail/Plugin.cs @@ -1,4 +1,4 @@ -using AutoEvent.API.Schematic.Objects; +using MER.Lite.Objects; using MEC; using PlayerRoles; using System; diff --git a/AutoEvent/Games/Knives/Features/RandomClass.cs b/AutoEvent/Games/Knives/Features/RandomClass.cs index 6dcffe2e..54c08d71 100644 --- a/AutoEvent/Games/Knives/Features/RandomClass.cs +++ b/AutoEvent/Games/Knives/Features/RandomClass.cs @@ -1,4 +1,4 @@ -using AutoEvent.API.Schematic.Objects; +using MER.Lite.Objects; using System.Linq; using UnityEngine; diff --git a/AutoEvent/Games/Knives/Plugin.cs b/AutoEvent/Games/Knives/Plugin.cs index cd4a6988..ad00d0a9 100644 --- a/AutoEvent/Games/Knives/Plugin.cs +++ b/AutoEvent/Games/Knives/Plugin.cs @@ -1,4 +1,4 @@ -using AutoEvent.API.Schematic.Objects; +using MER.Lite.Objects; using MEC; using PlayerRoles; using PluginAPI.Core; diff --git a/AutoEvent/Games/Lava/Features/RandomClass.cs b/AutoEvent/Games/Lava/Features/RandomClass.cs index 764e040d..02b13d71 100644 --- a/AutoEvent/Games/Lava/Features/RandomClass.cs +++ b/AutoEvent/Games/Lava/Features/RandomClass.cs @@ -1,4 +1,4 @@ -using AutoEvent.API.Schematic.Objects; +using MER.Lite.Objects; using System.Linq; using UnityEngine; diff --git a/AutoEvent/Games/Lava/Plugin.cs b/AutoEvent/Games/Lava/Plugin.cs index 1871e9e1..6506bcb0 100644 --- a/AutoEvent/Games/Lava/Plugin.cs +++ b/AutoEvent/Games/Lava/Plugin.cs @@ -1,4 +1,4 @@ -using AutoEvent.API.Schematic.Objects; +using MER.Lite.Objects; using AutoEvent.Events.Handlers; using MEC; using PlayerRoles; diff --git a/AutoEvent/Games/Line/Plugin.cs b/AutoEvent/Games/Line/Plugin.cs index c36d9bca..2ef29f36 100644 --- a/AutoEvent/Games/Line/Plugin.cs +++ b/AutoEvent/Games/Line/Plugin.cs @@ -1,4 +1,4 @@ -using AutoEvent.API.Schematic.Objects; +using MER.Lite.Objects; using AutoEvent.Events.Handlers; using MEC; using PlayerRoles; diff --git a/AutoEvent/Games/Puzzle/Features/RandomClass.cs b/AutoEvent/Games/Puzzle/Features/RandomClass.cs index abdb42d0..8cb98451 100644 --- a/AutoEvent/Games/Puzzle/Features/RandomClass.cs +++ b/AutoEvent/Games/Puzzle/Features/RandomClass.cs @@ -1,4 +1,4 @@ -using AutoEvent.API.Schematic.Objects; +using MER.Lite.Objects; using System.Linq; using UnityEngine; diff --git a/AutoEvent/Games/Puzzle/Plugin.cs b/AutoEvent/Games/Puzzle/Plugin.cs index e581ccd7..2e459092 100644 --- a/AutoEvent/Games/Puzzle/Plugin.cs +++ b/AutoEvent/Games/Puzzle/Plugin.cs @@ -4,7 +4,7 @@ using System.Linq; using MEC; using PlayerRoles; -using AutoEvent.API.Schematic.Objects; +using MER.Lite.Objects; using UnityEngine; using PluginAPI.Core; using PluginAPI.Events; diff --git a/AutoEvent/Games/Survival/Extensions/RandomClass.cs b/AutoEvent/Games/Survival/Extensions/RandomClass.cs index fb16947e..fb070d88 100644 --- a/AutoEvent/Games/Survival/Extensions/RandomClass.cs +++ b/AutoEvent/Games/Survival/Extensions/RandomClass.cs @@ -1,4 +1,4 @@ -using AutoEvent.API.Schematic.Objects; +using MER.Lite.Objects; using System.Collections.Generic; using System.Linq; using UnityEngine; diff --git a/AutoEvent/Games/Survival/Plugin.cs b/AutoEvent/Games/Survival/Plugin.cs index f650405b..56bbfdcb 100644 --- a/AutoEvent/Games/Survival/Plugin.cs +++ b/AutoEvent/Games/Survival/Plugin.cs @@ -1,5 +1,5 @@ using CustomPlayerEffects; -using AutoEvent.API.Schematic.Objects; +using MER.Lite.Objects; using MEC; using PlayerRoles; using PluginAPI.Core; diff --git a/AutoEvent/Games/Versus/Features/RandomClass.cs b/AutoEvent/Games/Versus/Features/RandomClass.cs index b2bc9d0a..f4ce3b7f 100644 --- a/AutoEvent/Games/Versus/Features/RandomClass.cs +++ b/AutoEvent/Games/Versus/Features/RandomClass.cs @@ -1,4 +1,4 @@ -using AutoEvent.API.Schematic.Objects; +using MER.Lite.Objects; using System.Linq; using UnityEngine; diff --git a/AutoEvent/Games/Versus/Plugin.cs b/AutoEvent/Games/Versus/Plugin.cs index 74e5ee51..70c44f4b 100644 --- a/AutoEvent/Games/Versus/Plugin.cs +++ b/AutoEvent/Games/Versus/Plugin.cs @@ -4,7 +4,7 @@ using AutoEvent.API.Enums; using MEC; using PlayerRoles; -using AutoEvent.API.Schematic.Objects; +using MER.Lite.Objects; using UnityEngine; using PluginAPI.Core; using PluginAPI.Events; diff --git a/AutoEvent/Games/ZombieEscape/Extensions/RandomClass.cs b/AutoEvent/Games/ZombieEscape/Extensions/RandomClass.cs index 3aadd1fa..acb8d3b4 100644 --- a/AutoEvent/Games/ZombieEscape/Extensions/RandomClass.cs +++ b/AutoEvent/Games/ZombieEscape/Extensions/RandomClass.cs @@ -1,4 +1,4 @@ -using AutoEvent.API.Schematic.Objects; +using MER.Lite.Objects; using System.Collections.Generic; using System.Linq; using UnityEngine; diff --git a/AutoEvent/Games/ZombieEscape/Plugin.cs b/AutoEvent/Games/ZombieEscape/Plugin.cs index 050b2e01..7e4b460a 100644 --- a/AutoEvent/Games/ZombieEscape/Plugin.cs +++ b/AutoEvent/Games/ZombieEscape/Plugin.cs @@ -1,4 +1,4 @@ -using AutoEvent.API.Schematic.Objects; +using MER.Lite.Objects; using AutoEvent.Events.Handlers; using CustomPlayerEffects; using MEC; diff --git a/AutoEvent/Interfaces/IEventMap.cs b/AutoEvent/Interfaces/IEventMap.cs index 84305b6e..d623905d 100644 --- a/AutoEvent/Interfaces/IEventMap.cs +++ b/AutoEvent/Interfaces/IEventMap.cs @@ -10,7 +10,7 @@ // Created Date: 09/06/2023 4:10 PM // ----------------------------------------- -using AutoEvent.API.Schematic.Objects; +using MER.Lite.Objects; using UnityEngine; namespace AutoEvent.Interfaces; diff --git a/AutoEvent/Interfaces/MapInfo.cs b/AutoEvent/Interfaces/MapInfo.cs index 57f2e167..4d6fc0d2 100644 --- a/AutoEvent/Interfaces/MapInfo.cs +++ b/AutoEvent/Interfaces/MapInfo.cs @@ -11,7 +11,7 @@ // ----------------------------------------- using System.ComponentModel; -using AutoEvent.API.Schematic.Objects; +using MER.Lite.Objects; using UnityEngine; using YamlDotNet.Serialization; diff --git a/AutoEvent/Plugin.cs b/AutoEvent/Plugin.cs index 950887c3..b13d15d8 100644 --- a/AutoEvent/Plugin.cs +++ b/AutoEvent/Plugin.cs @@ -11,6 +11,7 @@ using GameCore; using MEC; using PluginAPI.Core; +using Powerups; using Event = AutoEvent.Interfaces.Event; using Log = PluginAPI.Core.Log; using Paths = PluginAPI.Helpers.Paths; @@ -85,6 +86,9 @@ private void _startup() try { Singleton = this; + MER.Lite.API.Initialize(AutoEvent.Singleton.Config.SchematicsDirectoryPath, Config.Debug); + Powerups.API.Initialize(); + if (Config.IgnoredRoles.Contains(Config.LobbyRole)) { DebugLogger.LogDebug("The Lobby Role is also in ignored roles. This will break the game if not changed. The plugin will remove the lobby role from ignored roles.", LogLevel.Error, true); @@ -116,7 +120,6 @@ private void _startup() EventManager.RegisterEvents(this); SCPSLAudioApi.Startup.SetupDependencies(); - var powerupManager = new PowerupManager(); Servers.RemoteAdmin += eventHandler.OnRemoteAdmin; try { diff --git a/AutoEvent/PowerupApi/API.cs b/AutoEvent/PowerupApi/API.cs new file mode 100644 index 00000000..278d1483 --- /dev/null +++ b/AutoEvent/PowerupApi/API.cs @@ -0,0 +1,35 @@ +using Powerups.Api; + +namespace Powerups +{ + public static class API + { + /// + /// Initializes necessary dependencies. + /// + /// Should debug logging be enabled. + public static void Initialize(bool debug = false) + { + if (_initialized) + { + return; + } + _initialized = true; + CosturaUtility.Initialize(); + var powerupManager = new PowerupManager(); + Debug = debug; + } + + private static bool _initialized = false; + + /// + /// Controls Debug Logs. If true, the Api will output debug logs. + /// + public static bool Debug { get; set; } = false; + + /// + /// The main instance of the powerup manager. + /// + public static PowerupManager PowerupManager => PowerupManager.Singleton; + } +} \ No newline at end of file diff --git a/AutoEvent/PowerupApi/Components/BaseCollisionDetectorComponent.cs b/AutoEvent/PowerupApi/Components/BaseCollisionDetectorComponent.cs new file mode 100644 index 00000000..83f2e5eb --- /dev/null +++ b/AutoEvent/PowerupApi/Components/BaseCollisionDetectorComponent.cs @@ -0,0 +1,117 @@ +// +// Copyright (c) Redforce04. All rights reserved. +// +// ----------------------------------------- +// Solution: AutoEvent +// Project: AutoEvent +// FileName: BaseCollisionComponent.cs +// Author: Redforce04#4091 +// Revision Date: 10/17/2023 5:33 PM +// Created Date: 10/17/2023 5:33 PM +// ----------------------------------------- + +using PluginAPI.Core; +using UnityEngine; + +namespace Powerups.Components; + +public class BaseCollisionDetectorComponent : MonoBehaviour + { + /// + /// Gets or sets the raycast distance. + /// + public virtual float RaycastDistance { get; set; } = 1; + + /// + /// Gets or sets the time delay (in seconds) before performing raycast collision checks during each update. + /// + public virtual float Delay { get; set; } = 0.1f; + + private float elapsedTime = 0; + + /// + /// Update is called once per frame. + /// + internal virtual void Update() + { + + if(elapsedTime > Delay) + { + // Raycast upwards + RaycastHit hitUp; + if (Physics.Raycast(transform.position, Vector3.up, out hitUp, RaycastDistance)) + { + OnCollisionWithSomething(hitUp.collider.transform.root.gameObject); + } + + // Raycast downwards + RaycastHit hitDown; + if (Physics.Raycast(transform.position, Vector3.down, out hitDown, RaycastDistance)) + { + + OnCollisionWithSomething(hitDown.collider.transform.root.gameObject); + } + + // Raycast forwards + + RaycastHit hitForward; + if (Physics.Raycast(transform.position, transform.forward, out hitForward, RaycastDistance)) + { + OnCollisionWithSomething(hitForward.collider.transform.root.gameObject); + } + + // Raycast backwards + RaycastHit hitBackward; + if (Physics.Raycast(transform.position, -transform.forward, out hitBackward, RaycastDistance)) + { + OnCollisionWithSomething(hitBackward.collider.transform.root.gameObject); + } + + // Raycast to the left + RaycastHit hitLeft; + if (Physics.Raycast(transform.position, -transform.right, out hitLeft, RaycastDistance)) + { + OnCollisionWithSomething(hitLeft.collider.transform.root.gameObject); + } + + // Raycast to the right + RaycastHit hitRight; + if (Physics.Raycast(transform.position, transform.right, out hitRight, RaycastDistance)) + { + OnCollisionWithSomething(hitRight.collider.transform.root.gameObject); + } + + elapsedTime = 0; + } + + elapsedTime += Time.deltaTime; + } + + /// + /// Called when a collision with an object is detected. + /// + /// The GameObject involved in the collision. + public virtual void OnCollisionWithSomething(GameObject gameObject) + { + // This method can be overridden in derived classes to handle collisions. + } + + public bool IsPlayer(GameObject gameObject, out Player? player) + { + if (gameObject == base.gameObject || gameObject.tag != "Player") + { + player = null; + return false; + } + + if(Player.TryGet(gameObject, out player)) + { + return true; + } + else + { + player = null; + return false; + } + } + } \ No newline at end of file diff --git a/AutoEvent/PowerupApi/Components/PlayerCollisionDetectorComponent.cs b/AutoEvent/PowerupApi/Components/PlayerCollisionDetectorComponent.cs new file mode 100644 index 00000000..3cae8304 --- /dev/null +++ b/AutoEvent/PowerupApi/Components/PlayerCollisionDetectorComponent.cs @@ -0,0 +1,71 @@ +// +// Copyright (c) Redforce04. All rights reserved. +// +// ----------------------------------------- +// Solution: AutoEvent +// Project: AutoEvent +// FileName: PlayerCollisionDetectorComponent.cs +// Author: Redforce04#4091 +// Revision Date: 10/17/2023 5:36 PM +// Created Date: 10/17/2023 5:36 PM +// ----------------------------------------- + +using System; +using PluginAPI.Core; +using UnityEngine; + +namespace Powerups.Components; + +public class PlayerCollisionDetectorComponent : BaseCollisionDetectorComponent +{ + public override float RaycastDistance { get; set; } = 1f; + public override float Delay { get; set; } = 2; + public Player? Player { get; private set; } + + public void Init(Player? ply = null) + { + Player = ply; + } + public override void OnCollisionWithSomething(GameObject gameObject) + { + if (!IsPlayer(gameObject, out var player)) + { + return; + } + + PlayerCollision.Invoke(new PlayerCollisionArgs(player, gameObject)); + } + public event Action PlayerCollision; + + public void Disable() + { + Destroy(this); + } +} +public class PlayerCollisionArgs +{ + /// + /// Initializes an instance of + /// + /// The player colliding with the schematic. + public PlayerCollisionArgs(Player ply, GameObject gameObject) + { + Player = ply; + GameObject = gameObject; + } + + /// + /// The player that collided with the component. + /// + public Player Player { get; init; } + + /// + /// The instance of the gameobject which was collided with. + /// + public GameObject GameObject { get; init; } + + /// + /// If the original object was a player, it will be present here. Otherwise it will be null. + /// + public Player? OriginalPlayer { get; init; } +} \ No newline at end of file diff --git a/AutoEvent/PowerupApi/Components/SchematicCollisionComponent.cs b/AutoEvent/PowerupApi/Components/SchematicCollisionComponent.cs new file mode 100644 index 00000000..ae55dc32 --- /dev/null +++ b/AutoEvent/PowerupApi/Components/SchematicCollisionComponent.cs @@ -0,0 +1,81 @@ +// +// Copyright (c) Redforce04. All rights reserved. +// +// ----------------------------------------- +// Solution: AutoEvent +// Project: AutoEvent +// FileName: SchematicCollisionComponent.cs +// Author: Redforce04#4091 +// Revision Date: 10/17/2023 12:53 AM +// Created Date: 10/17/2023 12:53 AM +// ----------------------------------------- + +using System; +using System.Collections.Generic; +using System.Linq; +using AdminToys; +using MER.Lite.Objects; +using Mirror; +using PlayerStatsSystem; +using PluginAPI.Core; +using UnityEngine; + +namespace Powerups.Components; + +public class SchematicCollisionComponent : MonoBehaviour +{ + private BoxCollider collider; + private Vector3 ColliderScale; + private SchematicObject schematic; + public void Init(SchematicObject schematicObject, Vector3 colliderScale) + { + schematic = schematicObject; + ColliderScale = colliderScale; + } + private void Start() + { + collider = gameObject.AddComponent(); + collider.isTrigger = true; + collider.size = ColliderScale; + } + + private void OnTriggerStay(Collider other) + { + if (Player.Get(other.gameObject) is not Player ply) + { + return; + } + + SchematicCollision?.Invoke(new SchematicCollisionArgs(ply, this.gameObject, schematic)); + } + public event Action SchematicCollision; +} + +public class SchematicCollisionArgs +{ + /// + /// Initializes an instance of + /// + /// The player colliding with the schematic. + public SchematicCollisionArgs(Player ply, GameObject gameObject, SchematicObject schematic) + { + Player = ply; + GameObject = gameObject; + Schematic = schematic; + } + + /// + /// The player that collided with the component. + /// + public Player Player { get; init; } + + /// + /// The instance of the gameobject which was collided with. + /// + public GameObject GameObject { get; init; } + + /// + /// The instance of the Schematic which was collided with. + /// + public SchematicObject Schematic { get; init; } +} \ No newline at end of file diff --git a/AutoEvent/PowerupApi/Components/SpinningItemComponent.cs b/AutoEvent/PowerupApi/Components/SpinningItemComponent.cs new file mode 100644 index 00000000..51febdb8 --- /dev/null +++ b/AutoEvent/PowerupApi/Components/SpinningItemComponent.cs @@ -0,0 +1,33 @@ +// +// Copyright (c) Redforce04. All rights reserved. +// +// ----------------------------------------- +// Solution: AutoEvent +// Project: AutoEvent +// FileName: PowerupItem.cs +// Author: Redforce04#4091 +// Revision Date: 10/17/2023 12:40 AM +// Created Date: 10/17/2023 12:40 AM +// ----------------------------------------- + +using UnityEngine; + +namespace Powerups.Components; + using UnityEngine; + + /// + /// Handles rotating a pickup indicator. + /// + public class SpinningItemComponent : MonoBehaviour + { + /// + /// The spinning speed. + /// + public float Speed = 100f; + + /// + private void Update() + { + transform.Rotate(Vector3.up, Time.deltaTime * Speed); + } + } \ No newline at end of file diff --git a/AutoEvent/Powerups/AmmoPowerup.cs b/AutoEvent/PowerupApi/Default/AmmoPowerup.cs similarity index 95% rename from AutoEvent/Powerups/AmmoPowerup.cs rename to AutoEvent/PowerupApi/Default/AmmoPowerup.cs index 9e20f131..006b0e21 100644 --- a/AutoEvent/Powerups/AmmoPowerup.cs +++ b/AutoEvent/PowerupApi/Default/AmmoPowerup.cs @@ -11,14 +11,12 @@ // ----------------------------------------- using System.Collections.Generic; -using AutoEvent.Commands.Debug; -using AutoEvent.Interfaces; using CustomPlayerEffects; using Exiled.API.Features.Items; using PluginAPI.Core; using UnityEngine; -namespace AutoEvent; +namespace Powerups.Default; public class AmmoPowerup : Powerup { diff --git a/AutoEvent/Powerups/SpeedPowerup.cs b/AutoEvent/PowerupApi/Default/SpeedPowerup.cs similarity index 96% rename from AutoEvent/Powerups/SpeedPowerup.cs rename to AutoEvent/PowerupApi/Default/SpeedPowerup.cs index 1d2b0594..5f09fd7a 100644 --- a/AutoEvent/Powerups/SpeedPowerup.cs +++ b/AutoEvent/PowerupApi/Default/SpeedPowerup.cs @@ -10,14 +10,13 @@ // Created Date: 10/17/2023 12:55 PM // ----------------------------------------- -using AutoEvent.API; -using AutoEvent.Interfaces; using CustomPlayerEffects; using InventorySystem.Items.Usables.Scp244.Hypothermia; using PluginAPI.Core; +using Powerups.Extensions; using UnityEngine; -namespace AutoEvent; +namespace Powerups.Default; public sealed class SpeedPowerup : Powerup { diff --git a/AutoEvent/Powerups/TestPowerup.cs b/AutoEvent/PowerupApi/Default/TestPowerup.cs similarity index 80% rename from AutoEvent/Powerups/TestPowerup.cs rename to AutoEvent/PowerupApi/Default/TestPowerup.cs index e0d3a172..258028ed 100644 --- a/AutoEvent/Powerups/TestPowerup.cs +++ b/AutoEvent/PowerupApi/Default/TestPowerup.cs @@ -9,15 +9,11 @@ // Revision Date: 10/17/2023 1:32 AM // Created Date: 10/17/2023 1:32 AM // ----------------------------------------- - -using AutoEvent.API.Components; -using AutoEvent.API.Schematic.Objects; -using AutoEvent.Interfaces; using CustomPlayerEffects; using PluginAPI.Core; using UnityEngine; -namespace AutoEvent; +namespace Powerups.Default; public class TestPowerup : Powerup { @@ -27,14 +23,12 @@ public class TestPowerup : Powerup public override float PowerupDuration { get; protected set; } = 60; protected override void OnApplyPowerup(Player ply) { - DebugLogger.LogDebug($"Applying Powerup {this.Name} to player {ply.Nickname}."); ply.EffectsManager.DisableEffect(); ply.EffectsManager.DisableEffect(); } protected override void OnRemovePowerup(Player ply) { - DebugLogger.LogDebug($"Removing powerup {this.Name} from player {ply.Nickname}."); ply.EffectsManager.EnableEffect(0f, false); ply.EffectsManager.EnableEffect(0f, false).Intensity = 30; } diff --git a/AutoEvent/PowerupApi/Extensions/AbstractTypeExtensions.cs b/AutoEvent/PowerupApi/Extensions/AbstractTypeExtensions.cs new file mode 100644 index 00000000..25b89b86 --- /dev/null +++ b/AutoEvent/PowerupApi/Extensions/AbstractTypeExtensions.cs @@ -0,0 +1,65 @@ +// +// Copyright (c) Redforce04. All rights reserved. +// +// ----------------------------------------- +// Solution: AutoEvent +// Project: AutoEvent +// FileName: AbstractTypeExtensions.cs +// Author: Redforce04#4091 +// Revision Date: 10/17/2023 1:30 AM +// Created Date: 10/17/2023 1:30 AM +// ----------------------------------------- + +namespace Powerups.Extensions; + +using System; +using System.Collections.Generic; +using System.Reflection; + +public static class AbstractedTypeExtensions +{ + /// + /// Every instance of the type found in any loaded assembly will be instantiated and returned into list form. + /// + /// The type to instantiate instances of. + /// A list of all found instances of . + public static List InstantiateAllInstancesOfType() + where T : class + { + Type type = typeof(T); + List instanceList = new List(); + + foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies()) + { + try + { + foreach (Type typeInstance in HarmonyLib.AccessTools.GetTypesFromAssembly(assembly)) + { + if (typeInstance.IsAbstract || typeInstance.IsInterface) + continue; + + if (!typeInstance.IsSubclassOf(type)) + continue; + + try + { + if (Activator.CreateInstance(typeInstance) is not T instance) + continue; + + instanceList.Add(instance); + } + catch + { + // + } + } + } + catch + { + // + } + } + + return instanceList; + } +} \ No newline at end of file diff --git a/AutoEvent/PowerupApi/Extensions/MirrorExtensions.cs b/AutoEvent/PowerupApi/Extensions/MirrorExtensions.cs new file mode 100644 index 00000000..375620e1 --- /dev/null +++ b/AutoEvent/PowerupApi/Extensions/MirrorExtensions.cs @@ -0,0 +1,590 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) Exiled Team. All rights reserved. +// Licensed under the CC BY-SA 3.0 license. +// +// ----------------------------------------------------------------------- + +using CustomPlayerEffects; +using NorthwoodLib.Pools; +using PluginAPI.Core; + +namespace Powerups.Extensions; + + using System; + using System.Collections.Generic; + using System.Collections.ObjectModel; + using System.Linq; + using System.Reflection; + using System.Reflection.Emit; + using System.Text; + + using InventorySystem.Items.Firearms; + + using Mirror; + + using PlayerRoles; + using PlayerRoles.FirstPersonControl; + using PlayerRoles.PlayableScps.Scp049.Zombies; + using RelativePositioning; + + using Respawning; + + using UnityEngine; + + /// + /// A set of extensions for Networking. + /// + public static class MirrorExtensions + { + private static readonly Dictionary WriterExtensionsValue = new(); + private static readonly Dictionary SyncVarDirtyBitsValue = new(); + private static readonly Dictionary RpcFullNamesValue = new(); + + private static readonly ReadOnlyDictionary ReadOnlyWriterExtensionsValue = + new(WriterExtensionsValue); + + private static readonly ReadOnlyDictionary ReadOnlySyncVarDirtyBitsValue = + new(SyncVarDirtyBitsValue); + + private static readonly ReadOnlyDictionary ReadOnlyRpcFullNamesValue = new(RpcFullNamesValue); + private static MethodInfo setDirtyBitsMethodInfoValue; + private static MethodInfo sendSpawnMessageMethodInfoValue; + private static MethodInfo bufferRpcMethodInfoValue; + + /// + /// Gets corresponding to . + /// + public static ReadOnlyDictionary WriterExtensions + { + get + { + if (WriterExtensionsValue.Count == 0) + { + foreach (MethodInfo method in typeof(NetworkWriterExtensions).GetMethods() + .Where(x => !x.IsGenericMethod && (x.GetParameters()?.Length == 2))) + WriterExtensionsValue.Add( + method.GetParameters().First(x => x.ParameterType != typeof(NetworkWriter)).ParameterType, + method); + + Type fuckNorthwood = + Assembly.GetAssembly(typeof(RoleTypeId)).GetType("Mirror.GeneratedNetworkCode"); + foreach (MethodInfo method in fuckNorthwood.GetMethods().Where(x => + !x.IsGenericMethod && (x.GetParameters()?.Length == 2) && + (x.ReturnType == typeof(void)))) + WriterExtensionsValue.Add( + method.GetParameters().First(x => x.ParameterType != typeof(NetworkWriter)).ParameterType, + method); + + foreach (Type serializer in typeof(ServerConsole).Assembly.GetTypes() + .Where(x => x.Name.EndsWith("Serializer"))) + { + foreach (MethodInfo method in serializer.GetMethods() + .Where(x => (x.ReturnType == typeof(void)) && x.Name.StartsWith("Write"))) + WriterExtensionsValue.Add( + method.GetParameters().First(x => x.ParameterType != typeof(NetworkWriter)) + .ParameterType, method); + } + } + + return ReadOnlyWriterExtensionsValue; + } + } + + /// + /// Gets a all DirtyBit from (format:classname.methodname). + /// + public static ReadOnlyDictionary SyncVarDirtyBits + { + get + { + if (SyncVarDirtyBitsValue.Count == 0) + { + foreach (PropertyInfo property in typeof(ServerConsole).Assembly.GetTypes() + .SelectMany(x => x.GetProperties()) + .Where(m => m.Name.StartsWith("Network"))) + { + MethodInfo setMethod = property.GetSetMethod(); + + if (setMethod is null) + continue; + + MethodBody methodBody = setMethod.GetMethodBody(); + + if (methodBody is null) + continue; + + byte[] bytecodes = methodBody.GetILAsByteArray(); + + if (!SyncVarDirtyBitsValue.ContainsKey($"{property.ReflectedType.Name}.{property.Name}")) + SyncVarDirtyBitsValue.Add($"{property.ReflectedType.Name}.{property.Name}", + bytecodes[bytecodes.LastIndexOf((byte)OpCodes.Ldc_I8.Value) + 1]); + } + } + + return ReadOnlySyncVarDirtyBitsValue; + } + } + + /// + /// Gets Rpc's FullName corresponding to (format:classname.methodname). + /// + public static ReadOnlyDictionary RpcFullNames + { + get + { + if (RpcFullNamesValue.Count == 0) + { + foreach (MethodInfo method in typeof(ServerConsole).Assembly.GetTypes() + .SelectMany(x => + x.GetMethods(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)) + .Where(m => m.GetCustomAttributes(typeof(ClientRpcAttribute), false).Length > 0 || + m.GetCustomAttributes(typeof(TargetRpcAttribute), false).Length > 0)) + { + MethodBody methodBody = method.GetMethodBody(); + + if (methodBody is null) + continue; + + byte[] bytecodes = methodBody.GetILAsByteArray(); + + if (!RpcFullNamesValue.ContainsKey($"{method.ReflectedType.Name}.{method.Name}")) + RpcFullNamesValue.Add($"{method.ReflectedType.Name}.{method.Name}", + method.Module.ResolveString(BitConverter.ToInt32(bytecodes, + bytecodes.IndexOf((byte)OpCodes.Ldstr.Value) + 1))); + } + } + + return ReadOnlyRpcFullNamesValue; + } + } + + /// + /// Gets a 's . + /// + public static MethodInfo SetDirtyBitsMethodInfo => setDirtyBitsMethodInfoValue ??= + typeof(NetworkBehaviour).GetMethod(nameof(NetworkBehaviour.SetSyncVarDirtyBit)); + + /// + /// Gets a NetworkServer.SendSpawnMessage's . + /// + public static MethodInfo SendSpawnMessageMethodInfo => sendSpawnMessageMethodInfoValue ??= + typeof(NetworkServer).GetMethod("SendSpawnMessage", BindingFlags.NonPublic | BindingFlags.Static); + + /// + /// Gets a NetworkConnectionToClient.BufferRpc's . + /// + public static MethodInfo BufferRpcMethodInfo => bufferRpcMethodInfoValue ??= + typeof(NetworkConnectionToClient).GetMethod("BufferRpc", BindingFlags.NonPublic | BindingFlags.Instance, + null, CallingConventions.HasThis, new Type[] { typeof(RpcMessage), typeof(int) }, null); + + /// + /// Plays a beep sound that only the target can hear. + /// + /// Target to play sound to. + public static void PlayBeepSound(this Player player) => SendFakeTargetRpc(player, + ReferenceHub.HostHub.networkIdentity, typeof(AmbientSoundPlayer), nameof(AmbientSoundPlayer.RpcPlaySound), + 7); + + /// + /// Set on the player that only the can see. + /// + /// Only this player can see info. + /// Target to set info. + /// Setting info. + public static void SetPlayerInfoForTargetOnly(this Player player, Player target, string info) => + player.SendFakeSyncVar(target.ReferenceHub.networkIdentity, typeof(NicknameSync), + nameof(NicknameSync.Network_customPlayerInfoString), info); + + /// + /// Plays a gun sound that only the can hear. + /// + /// Target to play. + /// Position to play on. + /// Weapon' sound to play. + /// Sound's volume to set. + /// GunAudioMessage's audioClipId to set (default = 0). + public static void PlayGunSound(this Player player, Vector3 position, ItemType itemType, byte volume, + byte audioClipId = 0) + { + GunAudioMessage message = new() + { + Weapon = itemType, + AudioClipId = audioClipId, + MaxDistance = volume, + ShooterHub = player.ReferenceHub, + ShooterPosition = new RelativePosition(position), + }; + + player.Connection.Send(message); + } + + /*/// + /// Sets of a that only the player can see. + /// + /// Room to modify. + /// Only this player can see room color. + /// Color to set. + public static void SetRoomColorForTargetOnly(this Room room, Player target, Color color) + { + target.SendFakeSyncVar(room.RoomLightControllerNetIdentity, typeof(RoomLightController), + nameof(RoomLightController.NetworkOverrideColor), color); + target.SendFakeSyncVar(room.RoomLightControllerNetIdentity, typeof(RoomLightController), + nameof(RoomLightController.NetworkOverrideColor), true); + }*/ + + /// + /// Sets of a that only the player can see. + /// + /// Only this player can see the name changed. + /// Player that will desync the CustomName. + /// Nickname to set. + public static void SetName(this Player target, Player player, string name) + { + target.SendFakeSyncVar(player.Connection.identity, typeof(NicknameSync), + nameof(NicknameSync.Network_displayName), name); + } + + /*/// + /// Sets of a that only the player can see. + /// + /// Room to modify. + /// Only this player can see room color. + /// Light intensity multiplier to set. + public static void SetRoomLightIntensityForTargetOnly(this Room room, Player target, float multiplier) + { + }*/ + + /// + /// Change character model for appearance. + /// It will continue until 's changes. + /// + /// Player to change. + /// Model type. + /// Whether or not to skip the little jump that works around an invisibility issue. + /// The UnitNameId to use for the player's new role, if the player's new role uses unit names. (is NTF). + public static void + ChangeAppearance(this Player player, RoleTypeId type, bool skipJump = false, byte unitId = 0) => + ChangeAppearance(player, type, Player.GetPlayers().Where(x => x != player), skipJump, unitId); + + /// + /// Change character model for appearance. + /// It will continue until 's changes. + /// + /// Player to change. + /// Model type. + /// The players who should see the changed appearance. + /// Whether or not to skip the little jump that works around an invisibility issue. + /// The UnitNameId to use for the player's new role, if the player's new role uses unit names. (is NTF). + public static void ChangeAppearance(this Player player, RoleTypeId type, IEnumerable playersToAffect, + bool skipJump = false, byte unitId = 0) + { + + if (player.RoleBase is not PlayerRoleBase roleBase) + return; + + bool isRisky = type.GetTeam() is Team.Dead || !player.IsAlive; + + NetworkWriterPooled writer = NetworkWriterPool.Get(); + writer.WriteUShort(38952); + writer.WriteUInt(player.NetworkId); + writer.WriteRoleType(type); + + if (roleBase is HumanRole humanRole && humanRole.UsesUnitNames) + { + if (player.RoleBase is not HumanRole) + isRisky = true; + writer.WriteByte(unitId); + } + + if (roleBase is FpcStandardRoleBase fpc) + { + if (player.RoleBase is not FpcStandardRoleBase playerfpc) + isRisky = true; + else + fpc = playerfpc; + + fpc.FpcModule.MouseLook.GetSyncValues(0, out ushort value, out ushort _); + var relativePos = player.RoleBase is IFpcRole fpcRole ? fpcRole.FpcModule.Motor.ReceivedPosition : default; + writer.WriteRelativePosition(relativePos); + + writer.WriteUShort(value); + } + + if (roleBase is ZombieRole) + { + if (player.RoleBase is not ZombieRole) + isRisky = true; + + writer.WriteUShort((ushort)Mathf.Clamp(Mathf.CeilToInt(player.MaxHealth), ushort.MinValue, + ushort.MaxValue)); + } + + foreach (Player target in playersToAffect) + { + if (target != player || !isRisky) + target.Connection.Send(writer.ToArraySegment()); + else + Log.Error($"Prevent Seld-Desync of {player.Nickname} with {type}"); + } + + NetworkWriterPool.Return(writer); + + // To counter a bug that makes the player invisible until they move after changing their appearance, we will teleport them upwards slightly to force a new position update for all clients. + if (!skipJump) + player.Position += Vector3.up * 0.25f; + } + + /// + /// Send CASSIE announcement that only can hear. + /// + /// Target to send. + /// Announcement words. + /// Same on 's isHeld. + /// Same on 's isNoisy. + /// Same on 's isSubtitles. + public static void PlayCassieAnnouncement(this Player player, string words, bool makeHold = false, + bool makeNoise = true, bool isSubtitles = false) + { + foreach (RespawnEffectsController controller in RespawnEffectsController.AllControllers) + { + if (controller != null) + { + SendFakeTargetRpc(player, controller.netIdentity, typeof(RespawnEffectsController), + nameof(RespawnEffectsController.RpcCassieAnnouncement), words, makeHold, makeNoise, + isSubtitles); + } + } + } + + public static void ApplyFakeEffect(this Player player, byte intensity) where T : StatusEffectBase + { + T effect; + if (!player.ReferenceHub.playerEffectsController.TryGetEffect(out effect)) + return; + ApplyFakeEffect(player, effect, intensity); + } + /// + /// Applies a status effect to a player on the client side. Only the player will notice the effect. + /// + /// The player to apply the effect to. + /// The effect to apply. + public static void ApplyFakeEffect(this Player player, StatusEffectBase effect, byte intensity) + { + for (int i = 0; i < player.ReferenceHub.playerEffectsController.EffectsLength; i++) + { + StatusEffectBase statusEffectBase = player.ReferenceHub.playerEffectsController.AllEffects[i]; + if (statusEffectBase == effect) + { + player.ReferenceHub.playerEffectsController._syncEffectsIntensity[i] = intensity; + return; + } + } + } + /// + /// Send CASSIE announcement with custom subtitles for translation that only can hear and see it. + /// + /// Target to send. + /// The message to be reproduced. + /// The translation should be show in the subtitles. + /// Same on 's isHeld. + /// Same on 's isNoisy. + /// Same on 's isSubtitles. + public static void MessageTranslated(this Player player, string words, string translation, + bool makeHold = false, bool makeNoise = true, bool isSubtitles = true) + { + StringBuilder announcement = StringBuilderPool.Shared.Rent(); + + string[] cassies = words.Split('\n'); + string[] translations = translation.Split('\n'); + + for (int i = 0; i < cassies.Length; i++) + announcement.Append($"{translations[i]} {cassies[i].Replace(' ', ' ')} "); + + string message = StringBuilderPool.Shared.ToStringReturn(announcement); + + foreach (RespawnEffectsController controller in RespawnEffectsController.AllControllers) + { + if (controller != null) + { + SendFakeTargetRpc(player, controller.netIdentity, typeof(RespawnEffectsController), + nameof(RespawnEffectsController.RpcCassieAnnouncement), message, makeHold, makeNoise, + isSubtitles); + } + } + } + + /// + /// Send fake values to client's . + /// + /// Target to send. + /// of object that owns . + /// 's type. + /// Property name starting with Network. + /// Value of send to target. + public static void SendFakeSyncVar(this Player target, NetworkIdentity behaviorOwner, Type targetType, + string propertyName, object value) + { + NetworkWriterPooled writer = NetworkWriterPool.Get(); + NetworkWriterPooled writer2 = NetworkWriterPool.Get(); + MakeCustomSyncWriter(behaviorOwner, targetType, null, CustomSyncVarGenerator, writer, writer2); + target.Connection.Send(new EntityStateMessage + { + netId = behaviorOwner.netId, + payload = writer.ToArraySegment(), + }); + + NetworkWriterPool.Return(writer); + NetworkWriterPool.Return(writer2); + + void CustomSyncVarGenerator(NetworkWriter targetWriter) + { + targetWriter.WriteULong(SyncVarDirtyBits[$"{targetType.Name}.{propertyName}"]); + WriterExtensions[value.GetType()]?.Invoke(null, new object[2] { targetWriter, value }); + } + } + + /// + /// Force resync to client's . + /// + /// of object that owns . + /// 's type. + /// Property name starting with Network. + public static void ResyncSyncVar(NetworkIdentity behaviorOwner, Type targetType, string propertyName) => + SetDirtyBitsMethodInfo.Invoke(behaviorOwner.gameObject.GetComponent(targetType), + new object[] { SyncVarDirtyBits[$"{targetType.Name}.{propertyName}"] }); + + /// + /// Send fake values to client's . + /// + /// Target to send. + /// of object that owns . + /// 's type. + /// Property name starting with Rpc. + /// Values of send to target. + public static void SendFakeTargetRpc(Player target, NetworkIdentity behaviorOwner, Type targetType, + string rpcName, params object[] values) + { + NetworkWriterPooled writer = NetworkWriterPool.Get(); + + foreach (object value in values) + WriterExtensions[value.GetType()].Invoke(null, new[] { writer, value }); + + RpcMessage msg = new() + { + netId = behaviorOwner.netId, + componentIndex = (byte)GetComponentIndex(behaviorOwner, targetType), + functionHash = (ushort)RpcFullNames[$"{targetType.Name}.{rpcName}"].GetStableHashCode(), + payload = writer.ToArraySegment(), + }; + + BufferRpcMethodInfo.Invoke(target.Connection, new object[] { msg, 0 }); + + NetworkWriterPool.Return(writer); + } + + /// + /// Send fake values to client's . + /// + /// Target to send. + /// of object that owns . + /// 's type. + /// Custom writing action. + /// + /// EffectOnlySCP207. + /// + /// MirrorExtensions.SendCustomSync(player, player.ReferenceHub.networkIdentity, typeof(PlayerEffectsController), (writer) => { + /// writer.WriteUInt64(1ul); // DirtyObjectsBit + /// writer.WriteUInt32(1); // DirtyIndexCount + /// writer.WriteByte((byte)SyncList<byte>.Operation.OP_SET); // Operations + /// writer.WriteUInt32(17); // EditIndex + /// writer.WriteByte(1); // Value + /// }); + /// + /// + public static void SendFakeSyncObject(Player target, NetworkIdentity behaviorOwner, Type targetType, + Action customAction) + { + NetworkWriterPooled writer = NetworkWriterPool.Get(); + NetworkWriterPooled writer2 = NetworkWriterPool.Get(); + MakeCustomSyncWriter(behaviorOwner, targetType, customAction, null, writer, writer2); + target.ReferenceHub.networkIdentity.connectionToClient.Send(new EntityStateMessage() + { netId = behaviorOwner.netId, payload = writer.ToArraySegment() }); + NetworkWriterPool.Return(writer); + NetworkWriterPool.Return(writer2); + } + + /// + /// Edit 's parameter and sync. + /// + /// Target object. + /// Edit function. + public static void EditNetworkObject(NetworkIdentity identity, Action customAction) + { + customAction.Invoke(identity); + + ObjectDestroyMessage objectDestroyMessage = new() + { + netId = identity.netId, + }; + + foreach (Player player in Player.GetPlayers()) + { + player.Connection.Send(objectDestroyMessage, 0); + SendSpawnMessageMethodInfo.Invoke(null, new object[] { identity, player.Connection }); + } + } + + // Get components index in identity.(private) + private static int GetComponentIndex(NetworkIdentity identity, Type type) + { + return Array.FindIndex(identity.NetworkBehaviours, (x) => x.GetType() == type); + } + + // Make custom writer(private) + private static void MakeCustomSyncWriter(NetworkIdentity behaviorOwner, Type targetType, + Action customSyncObject, Action customSyncVar, NetworkWriter owner, + NetworkWriter observer) + { + ulong value = 0; + NetworkBehaviour behaviour = null; + + // Get NetworkBehaviors index (behaviorDirty use index) + for (int i = 0; i < behaviorOwner.NetworkBehaviours.Length; i++) + { + if (behaviorOwner.NetworkBehaviours[i].GetType() == targetType) + { + behaviour = behaviorOwner.NetworkBehaviours[i]; + value = 1UL << (i & 31); + break; + } + } + + // Write target NetworkBehavior's dirty + Compression.CompressVarUInt(owner, value); + + // Write init position + int position = owner.Position; + owner.WriteByte(0); + int position2 = owner.Position; + + // Write custom sync data + if (customSyncObject is not null) + customSyncObject(owner); + else + behaviour.SerializeObjectsDelta(owner); + + // Write custom syncvar + customSyncVar?.Invoke(owner); + + // Write syncdata position data + int position3 = owner.Position; + owner.Position = position; + owner.WriteByte((byte)(position3 - position2 & 255)); + owner.Position = position3; + + // Copy owner to observer + if (behaviour.syncMode != SyncMode.Observers) + observer.WriteBytes(owner.ToArraySegment().Array, position, owner.Position - position); + } + } \ No newline at end of file diff --git a/AutoEvent/PowerupApi/FodyWeavers.xml b/AutoEvent/PowerupApi/FodyWeavers.xml new file mode 100644 index 00000000..5c41350f --- /dev/null +++ b/AutoEvent/PowerupApi/FodyWeavers.xml @@ -0,0 +1,12 @@ + + + + Newtonsoft.Json + 0Harmony + System.ComponentModel.DataAnnotations + YamlDotNet + SchematicApi + + + + \ No newline at end of file diff --git a/AutoEvent/PowerupApi/FodyWeavers.xsd b/AutoEvent/PowerupApi/FodyWeavers.xsd new file mode 100644 index 00000000..05e92c11 --- /dev/null +++ b/AutoEvent/PowerupApi/FodyWeavers.xsd @@ -0,0 +1,141 @@ + + + + + + + + + + + + A list of assembly names to exclude from the default action of "embed all Copy Local references", delimited with line breaks + + + + + A list of assembly names to include from the default action of "embed all Copy Local references", delimited with line breaks. + + + + + A list of runtime assembly names to exclude from the default action of "embed all Copy Local references", delimited with line breaks + + + + + A list of runtime assembly names to include from the default action of "embed all Copy Local references", delimited with line breaks. + + + + + A list of unmanaged 32 bit assembly names to include, delimited with line breaks. + + + + + A list of unmanaged 64 bit assembly names to include, delimited with line breaks. + + + + + The order of preloaded assemblies, delimited with line breaks. + + + + + + This will copy embedded files to disk before loading them into memory. This is helpful for some scenarios that expected an assembly to be loaded from a physical file. + + + + + Controls if .pdbs for reference assemblies are also embedded. + + + + + Controls if runtime assemblies are also embedded. + + + + + Controls whether the runtime assemblies are embedded with their full path or only with their assembly name. + + + + + Embedded assemblies are compressed by default, and uncompressed when they are loaded. You can turn compression off with this option. + + + + + As part of Costura, embedded assemblies are no longer included as part of the build. This cleanup can be turned off. + + + + + Costura by default will load as part of the module initialization. This flag disables that behavior. Make sure you call CosturaUtility.Initialize() somewhere in your code. + + + + + Costura will by default use assemblies with a name like 'resources.dll' as a satellite resource and prepend the output path. This flag disables that behavior. + + + + + A list of assembly names to exclude from the default action of "embed all Copy Local references", delimited with | + + + + + A list of assembly names to include from the default action of "embed all Copy Local references", delimited with |. + + + + + A list of runtime assembly names to exclude from the default action of "embed all Copy Local references", delimited with | + + + + + A list of runtime assembly names to include from the default action of "embed all Copy Local references", delimited with |. + + + + + A list of unmanaged 32 bit assembly names to include, delimited with |. + + + + + A list of unmanaged 64 bit assembly names to include, delimited with |. + + + + + The order of preloaded assemblies, delimited with |. + + + + + + + + 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed. + + + + + A comma-separated list of error codes that can be safely ignored in assembly verification. + + + + + 'false' to turn off automatic generation of the XML Schema file. + + + + + \ No newline at end of file diff --git a/AutoEvent/Interfaces/Powerup.cs b/AutoEvent/PowerupApi/Powerup.cs similarity index 56% rename from AutoEvent/Interfaces/Powerup.cs rename to AutoEvent/PowerupApi/Powerup.cs index 789c3d88..9250e063 100644 --- a/AutoEvent/Interfaces/Powerup.cs +++ b/AutoEvent/PowerupApi/Powerup.cs @@ -11,34 +11,67 @@ // ----------------------------------------- using System.Collections.Generic; -using AdminToys; -using AutoEvent.API.Components; -using AutoEvent.API.Schematic; -using AutoEvent.API.Schematic.Objects; -using CedMod.Addons.AdminSitSystem.Commands.Jail; -using MEC; -using Mirror; +using MER.Lite; +using MER.Lite.Objects; using PluginAPI.Core; +using Powerups.Components; using UnityEngine; -namespace AutoEvent.Interfaces; +namespace Powerups; +/// +/// The abstract implementation used to define powerups. +/// public abstract class Powerup { + /// + /// Initializes a new . + /// public Powerup() { ActivePlayers = new Dictionary(); Schematics = new List(); } + + /// + /// The name of the . If another is found by the same name, it will become "name-1" + /// public abstract string Name { get; protected set; } + + /// + /// A description of the powerup. + /// public abstract string Description { get; protected set; } - public virtual float PowerupDuration { get; protected set; } = float.MaxValue; + + /// + /// How long the should last. Set to -1 to disable the duration system (Non-Reversible Powerups). + /// + public virtual float PowerupDuration { get; protected set; } = -1; + + /// + /// The name of the schematic to spawn for the . + /// protected virtual string SchematicName { get; set; } + + /// + /// The scale of the . This makes the bigger or smaller when spawned. + /// protected virtual Vector3 SchematicScale { get; set; } = Vector3.one; + + /// + /// The Scale of the . This most likely won't scale the same as the , so use this to make the collider bigger / smaller. + /// protected virtual Vector3 ColliderScale { get; set; } = Vector3.one; + + /// + /// A list of all that give this . + /// protected List Schematics { get; set; } - internal Dictionary ActivePlayers { get; set; } + /// + /// A list of Players that have this effect active. This can be disabled by setting the to a negative amount. + /// + public Dictionary ActivePlayers { get; internal set; } /// /// Called when a player collides with the object. @@ -60,17 +93,20 @@ public virtual void SpawnPickup(Vector3 position, float scaleModifer = 1f, float { // Load the schematic of the powerup. - DebugLogger.LogDebug($"Spawning Powerup {this.Name} at ({position.x}, {position.y}, {position.z}), ({SchematicScale.x * scaleModifer}x{SchematicScale.y* scaleModifer}x{SchematicScale.z* scaleModifer})"); + if(API.Debug) + Log.Debug($"Spawning Powerup {this.Name} at ({position.x}, {position.y}, {position.z}), ({SchematicScale.x * scaleModifer}x{SchematicScale.y* scaleModifer}x{SchematicScale.z* scaleModifer})"); var schematic = ObjectSpawner.SpawnSchematic(this.SchematicName, position, Quaternion.Euler(Vector3.zero), this.SchematicScale* scaleModifer); if (schematic is null) { - DebugLogger.LogDebug($"Schematic is null. Cannot spawn pickup."); + if(API.Debug) + Log.Debug($"Schematic is null. Cannot spawn pickup."); return; } if (schematic.gameObject is null) { - DebugLogger.LogDebug($"Schematic Gameobject is null. Cannot spawn pickup."); + if(API.Debug) + Log.Debug($"Schematic Gameobject is null. Cannot spawn pickup."); return; } @@ -81,11 +117,18 @@ public virtual void SpawnPickup(Vector3 position, float scaleModifer = 1f, float collisionComponent.Init(schematic, ColliderScale * colliderScaleModifier); Schematics.Add(schematic); - DebugLogger.LogDebug($"Schematic position ({schematic.Position.z}, {schematic.Position.y}, {schematic.Position.z})."); + if(API.Debug) + Log.Debug($"Schematic position ({schematic.Position.z}, {schematic.Position.y}, {schematic.Position.z})."); } + /// + /// Use this to apply this to a player. + /// + /// The to apply the to. public void ApplyPowerup(Player ply) { + if (PowerupDuration < 0) + goto OnApplyPowerup; if (!ActivePlayers.ContainsKey(ply)) { ActivePlayers.Add(ply, this.PowerupDuration); @@ -94,11 +137,12 @@ public void ApplyPowerup(Player ply) { ActivePlayers[ply] = this.PowerupDuration; } + OnApplyPowerup: OnApplyPowerup(ply); } /// - /// Used to apply a Powerup to a player. + /// Used to apply a to a player. /// /// The player to apply it to. protected virtual void OnApplyPowerup(Player ply) @@ -115,6 +159,11 @@ public virtual void ExpirePowerup(Player ply) RemovePowerup(ply); } + + /// + /// Used to remove a from the effects of the . Not all Powerups can be removed (Ammo). + /// + /// The to remove the powerup from. public void RemovePowerup(Player ply) { if (ActivePlayers.ContainsKey(ply)) @@ -133,6 +182,11 @@ protected virtual void OnRemovePowerup(Player ply) } + /// + /// Checks if a has this effect active. Some powerups don't track this, and only apply the powerup once. (Ammo) + /// + /// The to check. + /// public virtual bool PlayerHasEffect(Player ply) { return this.ActivePlayers.ContainsKey(ply); diff --git a/AutoEvent/PowerupApi/PowerupApi.csproj b/AutoEvent/PowerupApi/PowerupApi.csproj new file mode 100644 index 00000000..6a82433d --- /dev/null +++ b/AutoEvent/PowerupApi/PowerupApi.csproj @@ -0,0 +1,66 @@ + + + net48 + latest + SLPowerups + SLPowerups + Copyright RisottoMan and Redforce04 © 2023 + bin\$(Configuration)\ + enable + Release + AnyCPU + Powerups + + + ..\bin\Release\NWApi + TRACE + true + true + x64 + v4.8 + 512 + true + default + + + + + all + runtime; compile; build; native; contentfiles; analyzers; buildtransitive + + + + all + runtime; compile; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/AutoEvent/Powerups/PowerupManager.cs b/AutoEvent/PowerupApi/PowerupManager.cs similarity index 72% rename from AutoEvent/Powerups/PowerupManager.cs rename to AutoEvent/PowerupApi/PowerupManager.cs index e871fd44..c684bb28 100644 --- a/AutoEvent/Powerups/PowerupManager.cs +++ b/AutoEvent/PowerupApi/PowerupManager.cs @@ -13,15 +13,17 @@ using System; using System.Collections.Generic; using System.Linq; -using AutoEvent.API; -using AutoEvent.Interfaces; using MEC; using PluginAPI.Core; +using Powerups.Extensions; -namespace AutoEvent; +namespace Powerups.Api; -public class PowerupManager +public sealed class PowerupManager { + /// + /// The main instance of the powerup manager. You must call or else the singleton will be null. + /// public static PowerupManager Singleton; internal PowerupManager() { @@ -48,10 +50,6 @@ private IEnumerator ProcessPowerups() { while (!KillLoop) { - if (AutoEvent.ActiveEvent == null) - { - goto skip; - } foreach (Powerup powerup in RegisteredPowerups) { @@ -77,13 +75,26 @@ private IEnumerator ProcessPowerups() } } + /// + /// A list of all registered powerups. + /// public static List RegisteredPowerups { get; set; } + /// + /// Gets a by its type. + /// + /// The type of the you are trying to get. + /// The (if it is found) or null. public static T GetPowerup() where T : Powerup { return (T)RegisteredPowerups.First(powerup => powerup is T); } + /// + /// Gets a by its type. + /// + /// The type of the you are trying to get. + /// The (if it is found) or null. public static Powerup? GetPowerup(Type type) { if (type.BaseType != typeof(Powerup)) @@ -94,6 +105,11 @@ public static T GetPowerup() where T : Powerup return RegisteredPowerups.FirstOrDefault(powerup => powerup.GetType() == type); } + /// + /// Gets a by its name. + /// + /// The name of the you are trying to get. + /// The (if it is found) or null. public static Powerup? GetPowerup(string name) { if (string.IsNullOrWhiteSpace(name)) diff --git a/AutoEvent/PowerupApi/Properties/AssemblyInfo.cs b/AutoEvent/PowerupApi/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..8a69fc70 --- /dev/null +++ b/AutoEvent/PowerupApi/Properties/AssemblyInfo.cs @@ -0,0 +1,35 @@ +using System.Reflection; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("PowerupApi")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("PowerupApi")] +[assembly: AssemblyCopyright("Copyright © 2023")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("1B07FE64-A112-499D-8A55-67EE912B1CB7")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] \ No newline at end of file diff --git a/AutoEvent/SchematicApi/API.cs b/AutoEvent/SchematicApi/API.cs new file mode 100644 index 00000000..40080040 --- /dev/null +++ b/AutoEvent/SchematicApi/API.cs @@ -0,0 +1,35 @@ +namespace MER.Lite +{ + public static class API + { + /// + /// Initializes MER Lite + /// + /// The location for the schematic folder. + /// Whether debug logs should be enabled. + public static void Initialize(string schematicLocation, bool debug = false) + { + if (_initialized) + { + return; + } + _initialized = true; + + SchematicLocation = schematicLocation; + Debug = debug; + CosturaUtility.Initialize(); + } + + private static bool _initialized = false; + + /// + /// Controls Debug Logs. If true, the Api will output debug logs. + /// + public static bool Debug { get; set; } + + /// + /// The location of the schematics folder. + /// + public static string SchematicLocation { get; set; } + } +} \ No newline at end of file diff --git a/AutoEvent/API/Schematic/AnimationController.cs b/AutoEvent/SchematicApi/AnimationController.cs similarity index 97% rename from AutoEvent/API/Schematic/AnimationController.cs rename to AutoEvent/SchematicApi/AnimationController.cs index 18fae3c7..aa7bc2c5 100644 --- a/AutoEvent/API/Schematic/AnimationController.cs +++ b/AutoEvent/SchematicApi/AnimationController.cs @@ -1,4 +1,4 @@ -namespace AutoEvent.API.Schematic +namespace MER.Lite { using System.Collections.Generic; using System.Linq; diff --git a/AutoEvent/SchematicApi/Components/PickupComponent.cs b/AutoEvent/SchematicApi/Components/PickupComponent.cs new file mode 100644 index 00000000..098f1d95 --- /dev/null +++ b/AutoEvent/SchematicApi/Components/PickupComponent.cs @@ -0,0 +1,21 @@ +// +// Copyright (c) Redforce04. All rights reserved. +// +// ----------------------------------------- +// Solution: AutoEvent +// Project: SchematicApi +// FileName: PickupComponent.cs +// Author: Redforce04#4091 +// Revision Date: 10/21/2023 8:31 PM +// Created Date: 10/21/2023 8:31 PM +// ----------------------------------------- + + +using UnityEngine; + +namespace MER.Lite.Components; + +public class PickupComponent : Component +{ + // Used to track pickups. +} \ No newline at end of file diff --git a/AutoEvent/API/Schematic/Enums/BlockType.cs b/AutoEvent/SchematicApi/Enums/BlockType.cs similarity index 83% rename from AutoEvent/API/Schematic/Enums/BlockType.cs rename to AutoEvent/SchematicApi/Enums/BlockType.cs index 150a83fa..7744646b 100644 --- a/AutoEvent/API/Schematic/Enums/BlockType.cs +++ b/AutoEvent/SchematicApi/Enums/BlockType.cs @@ -1,4 +1,4 @@ -namespace AutoEvent.API.Schematic.Enums +namespace MER.Lite.Enums { public enum BlockType { diff --git a/AutoEvent/API/Schematic/Enums/CullingType.cs b/AutoEvent/SchematicApi/Enums/CullingType.cs similarity index 70% rename from AutoEvent/API/Schematic/Enums/CullingType.cs rename to AutoEvent/SchematicApi/Enums/CullingType.cs index 26072479..7a44e395 100644 --- a/AutoEvent/API/Schematic/Enums/CullingType.cs +++ b/AutoEvent/SchematicApi/Enums/CullingType.cs @@ -1,4 +1,4 @@ -namespace AutoEvent.API.Schematic.Enums +namespace MER.Lite.Enums { public enum CullingType { diff --git a/AutoEvent/API/Schematic/Enums/LockerType.cs b/AutoEvent/SchematicApi/Enums/LockerType.cs similarity index 80% rename from AutoEvent/API/Schematic/Enums/LockerType.cs rename to AutoEvent/SchematicApi/Enums/LockerType.cs index 9d086741..b744e085 100644 --- a/AutoEvent/API/Schematic/Enums/LockerType.cs +++ b/AutoEvent/SchematicApi/Enums/LockerType.cs @@ -1,4 +1,4 @@ -namespace AutoEvent.API.Schematic.Enums +namespace MER.Lite.Enums { public enum LockerType { diff --git a/AutoEvent/SchematicApi/FodyWeavers.xml b/AutoEvent/SchematicApi/FodyWeavers.xml new file mode 100644 index 00000000..0b56460e --- /dev/null +++ b/AutoEvent/SchematicApi/FodyWeavers.xml @@ -0,0 +1,11 @@ + + + + Newtonsoft.Json + 0Harmony + System.ComponentModel.DataAnnotations + YamlDotNet + + + + \ No newline at end of file diff --git a/AutoEvent/SchematicApi/FodyWeavers.xsd b/AutoEvent/SchematicApi/FodyWeavers.xsd new file mode 100644 index 00000000..05e92c11 --- /dev/null +++ b/AutoEvent/SchematicApi/FodyWeavers.xsd @@ -0,0 +1,141 @@ + + + + + + + + + + + + A list of assembly names to exclude from the default action of "embed all Copy Local references", delimited with line breaks + + + + + A list of assembly names to include from the default action of "embed all Copy Local references", delimited with line breaks. + + + + + A list of runtime assembly names to exclude from the default action of "embed all Copy Local references", delimited with line breaks + + + + + A list of runtime assembly names to include from the default action of "embed all Copy Local references", delimited with line breaks. + + + + + A list of unmanaged 32 bit assembly names to include, delimited with line breaks. + + + + + A list of unmanaged 64 bit assembly names to include, delimited with line breaks. + + + + + The order of preloaded assemblies, delimited with line breaks. + + + + + + This will copy embedded files to disk before loading them into memory. This is helpful for some scenarios that expected an assembly to be loaded from a physical file. + + + + + Controls if .pdbs for reference assemblies are also embedded. + + + + + Controls if runtime assemblies are also embedded. + + + + + Controls whether the runtime assemblies are embedded with their full path or only with their assembly name. + + + + + Embedded assemblies are compressed by default, and uncompressed when they are loaded. You can turn compression off with this option. + + + + + As part of Costura, embedded assemblies are no longer included as part of the build. This cleanup can be turned off. + + + + + Costura by default will load as part of the module initialization. This flag disables that behavior. Make sure you call CosturaUtility.Initialize() somewhere in your code. + + + + + Costura will by default use assemblies with a name like 'resources.dll' as a satellite resource and prepend the output path. This flag disables that behavior. + + + + + A list of assembly names to exclude from the default action of "embed all Copy Local references", delimited with | + + + + + A list of assembly names to include from the default action of "embed all Copy Local references", delimited with |. + + + + + A list of runtime assembly names to exclude from the default action of "embed all Copy Local references", delimited with | + + + + + A list of runtime assembly names to include from the default action of "embed all Copy Local references", delimited with |. + + + + + A list of unmanaged 32 bit assembly names to include, delimited with |. + + + + + A list of unmanaged 64 bit assembly names to include, delimited with |. + + + + + The order of preloaded assemblies, delimited with |. + + + + + + + + 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed. + + + + + A comma-separated list of error codes that can be safely ignored in assembly verification. + + + + + 'false' to turn off automatic generation of the XML Schema file. + + + + + \ No newline at end of file diff --git a/AutoEvent/API/Schematic/MapUtils.cs b/AutoEvent/SchematicApi/MapUtils.cs similarity index 64% rename from AutoEvent/API/Schematic/MapUtils.cs rename to AutoEvent/SchematicApi/MapUtils.cs index f1b7c437..62bdbaf5 100644 --- a/AutoEvent/API/Schematic/MapUtils.cs +++ b/AutoEvent/SchematicApi/MapUtils.cs @@ -1,4 +1,6 @@ -namespace AutoEvent.API.Schematic +using PluginAPI.Core; + +namespace MER.Lite { using System.IO; using PluginAPI.Helpers; @@ -9,14 +11,16 @@ public static class MapUtils { public static SchematicObjectDataList GetSchematicDataByName(string schematicName) { - string dirPath = Path.Combine(AutoEvent.Singleton.Config.SchematicsDirectoryPath, schematicName); + string dirPath = Path.Combine(API.SchematicLocation, schematicName); - DebugLogger.LogDebug($"Path exists: {Directory.Exists(dirPath)}, Directory Path: {dirPath}"); + if(API.Debug) + Log.Debug($"Path exists: {Directory.Exists(dirPath)}, Directory Path: {dirPath}"); if (!Directory.Exists(dirPath)) return null; string schematicPath = Path.Combine(dirPath, $"{schematicName}.json"); - DebugLogger.LogDebug($"File Exists: {File.Exists(schematicPath)}, Schematic Path: {schematicPath}"); + if(API.Debug) + Log.Debug($"File Exists: {File.Exists(schematicPath)}, Schematic Path: {schematicPath}"); if (!File.Exists(schematicPath)) return null; diff --git a/AutoEvent/API/Schematic/ObjectHelper.cs b/AutoEvent/SchematicApi/ObjectHelper.cs similarity index 99% rename from AutoEvent/API/Schematic/ObjectHelper.cs rename to AutoEvent/SchematicApi/ObjectHelper.cs index 87aea59d..a6225dd3 100644 --- a/AutoEvent/API/Schematic/ObjectHelper.cs +++ b/AutoEvent/SchematicApi/ObjectHelper.cs @@ -4,7 +4,7 @@ using Mirror; using UnityEngine; -namespace AutoEvent.API.Schematic +namespace MER.Lite { public static class ObjectHelper { diff --git a/AutoEvent/API/Schematic/ObjectSpawner.cs b/AutoEvent/SchematicApi/ObjectSpawner.cs similarity index 95% rename from AutoEvent/API/Schematic/ObjectSpawner.cs rename to AutoEvent/SchematicApi/ObjectSpawner.cs index 153b73f9..d89555ed 100644 --- a/AutoEvent/API/Schematic/ObjectSpawner.cs +++ b/AutoEvent/SchematicApi/ObjectSpawner.cs @@ -1,10 +1,11 @@ -namespace AutoEvent.API.Schematic +using MER.Lite.Objects; + +namespace MER.Lite { using MapGeneration; using Serializable; using UnityEngine; using System.Linq; - using global::AutoEvent.API.Schematic.Objects; public static class ObjectSpawner { diff --git a/AutoEvent/API/Schematic/Objects/LightSourceObjects.cs b/AutoEvent/SchematicApi/Objects/LightSourceObjects.cs similarity index 97% rename from AutoEvent/API/Schematic/Objects/LightSourceObjects.cs rename to AutoEvent/SchematicApi/Objects/LightSourceObjects.cs index a259ad97..675863d7 100644 --- a/AutoEvent/API/Schematic/Objects/LightSourceObjects.cs +++ b/AutoEvent/SchematicApi/Objects/LightSourceObjects.cs @@ -1,5 +1,5 @@  -namespace AutoEvent.API.Schematic.Objects +namespace MER.Lite.Objects { using AdminToys; using MapGeneration; diff --git a/AutoEvent/API/Schematic/Objects/LockerObject.cs b/AutoEvent/SchematicApi/Objects/LockerObject.cs similarity index 98% rename from AutoEvent/API/Schematic/Objects/LockerObject.cs rename to AutoEvent/SchematicApi/Objects/LockerObject.cs index 9edca9ce..fb8362d9 100644 --- a/AutoEvent/API/Schematic/Objects/LockerObject.cs +++ b/AutoEvent/SchematicApi/Objects/LockerObject.cs @@ -1,4 +1,4 @@ -namespace AutoEvent.API.Schematic.Objects +namespace MER.Lite.Objects { using System; using System.Collections.Generic; diff --git a/AutoEvent/API/Schematic/Objects/MapEditorObject.cs b/AutoEvent/SchematicApi/Objects/MapEditorObject.cs similarity index 98% rename from AutoEvent/API/Schematic/Objects/MapEditorObject.cs rename to AutoEvent/SchematicApi/Objects/MapEditorObject.cs index 0d0bdd42..29bad1d3 100644 --- a/AutoEvent/API/Schematic/Objects/MapEditorObject.cs +++ b/AutoEvent/SchematicApi/Objects/MapEditorObject.cs @@ -1,4 +1,4 @@ -namespace AutoEvent.API.Schematic.Objects +namespace MER.Lite.Objects { using System; using System.Linq; diff --git a/AutoEvent/API/Schematic/Objects/PrimitiveObject.cs b/AutoEvent/SchematicApi/Objects/PrimitiveObject.cs similarity index 98% rename from AutoEvent/API/Schematic/Objects/PrimitiveObject.cs rename to AutoEvent/SchematicApi/Objects/PrimitiveObject.cs index 4979002f..a1bcd74e 100644 --- a/AutoEvent/API/Schematic/Objects/PrimitiveObject.cs +++ b/AutoEvent/SchematicApi/Objects/PrimitiveObject.cs @@ -1,4 +1,4 @@ -namespace AutoEvent.API.Schematic.Objects +namespace MER.Lite.Objects { using AdminToys; using Serializable; diff --git a/AutoEvent/API/Schematic/Objects/SchematicObject.cs b/AutoEvent/SchematicApi/Objects/SchematicObject.cs similarity index 97% rename from AutoEvent/API/Schematic/Objects/SchematicObject.cs rename to AutoEvent/SchematicApi/Objects/SchematicObject.cs index a47058f2..7354b82f 100644 --- a/AutoEvent/API/Schematic/Objects/SchematicObject.cs +++ b/AutoEvent/SchematicApi/Objects/SchematicObject.cs @@ -1,4 +1,6 @@ -namespace AutoEvent.API.Schematic.Objects +using MER.Lite.Components; + +namespace MER.Lite.Objects { using System; using System.Collections.Generic; @@ -23,7 +25,7 @@ public class SchematicObject : MapEditorObject { public SchematicObject Init(SchematicSerializable schematicSerializable, SchematicObjectDataList data) { - DebugLogger.LogDebug($"Initializing schematic \"{schematicSerializable.SchematicName}\"", LogLevel.Info, true); + // Log.Debug($"Initializing schematic \"{schematicSerializable.SchematicName}\""); Base = schematicSerializable; SchematicData = data; @@ -297,7 +299,7 @@ private bool TryGetAnimatorController(string animatorName, out RuntimeAnimatorCo if (!File.Exists(path)) { - DebugLogger.LogDebug($"{gameObject.name} block of {name} should have a {animatorName} animator attached, but the file does not exist!", LogLevel.Warn, true); + Log.Warning($"{gameObject.name} block of {name} should have a {animatorName} animator attached, but the file does not exist!"); return false; } diff --git a/AutoEvent/API/Schematic/Objects/WorkstationObject.cs b/AutoEvent/SchematicApi/Objects/WorkstationObject.cs similarity index 96% rename from AutoEvent/API/Schematic/Objects/WorkstationObject.cs rename to AutoEvent/SchematicApi/Objects/WorkstationObject.cs index c5c82e5d..c023626a 100644 --- a/AutoEvent/API/Schematic/Objects/WorkstationObject.cs +++ b/AutoEvent/SchematicApi/Objects/WorkstationObject.cs @@ -1,4 +1,4 @@ -namespace AutoEvent.API.Schematic.Objects +namespace MER.Lite.Objects { using InventorySystem.Items.Firearms.Attachments; using MapGeneration.Distributors; diff --git a/AutoEvent/SchematicApi/Properties/AssemblyInfo.cs b/AutoEvent/SchematicApi/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..aa14d5fb --- /dev/null +++ b/AutoEvent/SchematicApi/Properties/AssemblyInfo.cs @@ -0,0 +1,35 @@ +using System.Reflection; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("SchematicApi")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("SchematicApi")] +[assembly: AssemblyCopyright("Copyright © 2023")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("580DFED2-B2D7-4B89-B245-D60246BCFB79")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] \ No newline at end of file diff --git a/AutoEvent/SchematicApi/SchematicApi.csproj b/AutoEvent/SchematicApi/SchematicApi.csproj new file mode 100644 index 00000000..169a7974 --- /dev/null +++ b/AutoEvent/SchematicApi/SchematicApi.csproj @@ -0,0 +1,64 @@ + + + net48 + latest + MERLite + MERLite + Copyright RisottoMan and Redforce04 © 2023 + bin\$(Configuration)\ + enable + Release + AnyCPU + MER.Lite + + + ..\bin\Release\NWApi + TRACE + true + true + x64 + v4.8 + 512 + true + default + + + + + all + runtime; compile; build; native; contentfiles; analyzers; buildtransitive + + + + all + runtime; compile; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/AutoEvent/API/Schematic/Serializable/LightSourcesSerializable.cs b/AutoEvent/SchematicApi/Serializable/LightSourcesSerializable.cs similarity index 95% rename from AutoEvent/API/Schematic/Serializable/LightSourcesSerializable.cs rename to AutoEvent/SchematicApi/Serializable/LightSourcesSerializable.cs index c8e38c3d..77f4cc7f 100644 --- a/AutoEvent/API/Schematic/Serializable/LightSourcesSerializable.cs +++ b/AutoEvent/SchematicApi/Serializable/LightSourcesSerializable.cs @@ -1,4 +1,4 @@ -namespace AutoEvent.API.Schematic.Serializable +namespace MER.Lite.Serializable { using System; using UnityEngine; diff --git a/AutoEvent/API/Schematic/Serializable/LockerItemSerializable.cs b/AutoEvent/SchematicApi/Serializable/LockerItemSerializable.cs similarity index 94% rename from AutoEvent/API/Schematic/Serializable/LockerItemSerializable.cs rename to AutoEvent/SchematicApi/Serializable/LockerItemSerializable.cs index 13f429fa..6cb8bb46 100644 --- a/AutoEvent/API/Schematic/Serializable/LockerItemSerializable.cs +++ b/AutoEvent/SchematicApi/Serializable/LockerItemSerializable.cs @@ -4,7 +4,7 @@ using System.Text; using System.Threading.Tasks; -namespace AutoEvent.API.Schematic.Serializable +namespace MER.Lite.Serializable { using System.Collections.Generic; using InventorySystem.Items.Firearms.Attachments; diff --git a/AutoEvent/API/Schematic/Serializable/LockerSerializable.cs b/AutoEvent/SchematicApi/Serializable/LockerSerializable.cs similarity index 98% rename from AutoEvent/API/Schematic/Serializable/LockerSerializable.cs rename to AutoEvent/SchematicApi/Serializable/LockerSerializable.cs index ca78275e..0ddd4646 100644 --- a/AutoEvent/API/Schematic/Serializable/LockerSerializable.cs +++ b/AutoEvent/SchematicApi/Serializable/LockerSerializable.cs @@ -4,7 +4,7 @@ using System.Text; using System.Threading.Tasks; -namespace AutoEvent.API.Schematic.Serializable +namespace MER.Lite.Serializable { using System; using System.Collections.Generic; diff --git a/AutoEvent/API/Schematic/Serializable/PrimitiveSerializable.cs b/AutoEvent/SchematicApi/Serializable/PrimitiveSerializable.cs similarity index 93% rename from AutoEvent/API/Schematic/Serializable/PrimitiveSerializable.cs rename to AutoEvent/SchematicApi/Serializable/PrimitiveSerializable.cs index 7c62aae9..935e7e0a 100644 --- a/AutoEvent/API/Schematic/Serializable/PrimitiveSerializable.cs +++ b/AutoEvent/SchematicApi/Serializable/PrimitiveSerializable.cs @@ -1,4 +1,4 @@ -namespace AutoEvent.API.Schematic.Serializable +namespace MER.Lite.Serializable { using System; using UnityEngine; diff --git a/AutoEvent/API/Schematic/Serializable/SchematicObjectDataList.cs b/AutoEvent/SchematicApi/Serializable/SchematicObjectDataList.cs similarity index 94% rename from AutoEvent/API/Schematic/Serializable/SchematicObjectDataList.cs rename to AutoEvent/SchematicApi/Serializable/SchematicObjectDataList.cs index f4352939..7980a91a 100644 --- a/AutoEvent/API/Schematic/Serializable/SchematicObjectDataList.cs +++ b/AutoEvent/SchematicApi/Serializable/SchematicObjectDataList.cs @@ -1,4 +1,4 @@ -namespace AutoEvent.API.Schematic.Serializable +namespace MER.Lite.Serializable { #pragma warning disable SA1402 // File may only contain a single type using System; diff --git a/AutoEvent/API/Schematic/Serializable/SchematicSerializable.cs b/AutoEvent/SchematicApi/Serializable/SchematicSerializable.cs similarity index 90% rename from AutoEvent/API/Schematic/Serializable/SchematicSerializable.cs rename to AutoEvent/SchematicApi/Serializable/SchematicSerializable.cs index 38a960fc..ce1feef5 100644 --- a/AutoEvent/API/Schematic/Serializable/SchematicSerializable.cs +++ b/AutoEvent/SchematicApi/Serializable/SchematicSerializable.cs @@ -1,5 +1,5 @@  -namespace AutoEvent.API.Schematic.Serializable +namespace MER.Lite.Serializable { using System; using Enums; diff --git a/AutoEvent/API/Schematic/Serializable/SerializableObject.cs b/AutoEvent/SchematicApi/Serializable/SerializableObject.cs similarity index 88% rename from AutoEvent/API/Schematic/Serializable/SerializableObject.cs rename to AutoEvent/SchematicApi/Serializable/SerializableObject.cs index 87fffa45..b6c92d1b 100644 --- a/AutoEvent/API/Schematic/Serializable/SerializableObject.cs +++ b/AutoEvent/SchematicApi/Serializable/SerializableObject.cs @@ -1,5 +1,5 @@  -namespace AutoEvent.API.Schematic.Serializable +namespace MER.Lite.Serializable { using MapGeneration; using UnityEngine; diff --git a/AutoEvent/API/Schematic/Serializable/SerializableRigidbody.cs b/AutoEvent/SchematicApi/Serializable/SerializableRigidbody.cs similarity index 87% rename from AutoEvent/API/Schematic/Serializable/SerializableRigidbody.cs rename to AutoEvent/SchematicApi/Serializable/SerializableRigidbody.cs index 0db89724..fa0f3387 100644 --- a/AutoEvent/API/Schematic/Serializable/SerializableRigidbody.cs +++ b/AutoEvent/SchematicApi/Serializable/SerializableRigidbody.cs @@ -1,5 +1,5 @@  -namespace AutoEvent.API.Schematic.Serializable +namespace MER.Lite.Serializable { using UnityEngine; diff --git a/AutoEvent/API/Schematic/Serializable/WorkstationSerializable.cs b/AutoEvent/SchematicApi/Serializable/WorkstationSerializable.cs similarity index 93% rename from AutoEvent/API/Schematic/Serializable/WorkstationSerializable.cs rename to AutoEvent/SchematicApi/Serializable/WorkstationSerializable.cs index a4febca6..cd4b3bda 100644 --- a/AutoEvent/API/Schematic/Serializable/WorkstationSerializable.cs +++ b/AutoEvent/SchematicApi/Serializable/WorkstationSerializable.cs @@ -4,7 +4,7 @@ using System.Text; using System.Threading.Tasks; -namespace AutoEvent.API.Schematic.Serializable +namespace MER.Lite.Serializable { using System; From 62bea19992c123889e17788647aa253d1078411d Mon Sep 17 00:00:00 2001 From: Redforce04 <74625280+Redforce04@users.noreply.github.com> Date: Sat, 21 Oct 2023 22:03:19 -0500 Subject: [PATCH 4/6] Update Readme for more info --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 455a4cbb..35bafc93 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ # AutoEvent ## ENG: Allows you to run auto Mini-Games in the game. ## RUS: Позволяет запускать автоматические Мини-Игры в игре. +**Developers:** SchematicApi (MER.Lite) releases can be found [here](https://github.com/Redforce04/SchematicApi). Powerup Api releases can be found [here](https://github.com/Redforce04/PowerupApi). Development for both of these Api's occur on the dev branch of this repo. + ![Logo](https://github.com/KoT0XleB/AutoEvent/blob/main/Photos/MiniGames(mini).png) # Guides: From 88629584e8a5bd500133724a7e842c77f4be51ab Mon Sep 17 00:00:00 2001 From: Redforce04 <74625280+Redforce04@users.noreply.github.com> Date: Sat, 21 Oct 2023 22:21:08 -0500 Subject: [PATCH 5/6] minor systems change --- AutoEvent/PowerupApi/API.cs | 2 +- AutoEvent/PowerupApi/PowerupManager.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/AutoEvent/PowerupApi/API.cs b/AutoEvent/PowerupApi/API.cs index 278d1483..5c88f577 100644 --- a/AutoEvent/PowerupApi/API.cs +++ b/AutoEvent/PowerupApi/API.cs @@ -1,4 +1,4 @@ -using Powerups.Api; +using Powerups; namespace Powerups { diff --git a/AutoEvent/PowerupApi/PowerupManager.cs b/AutoEvent/PowerupApi/PowerupManager.cs index c684bb28..bf27ae99 100644 --- a/AutoEvent/PowerupApi/PowerupManager.cs +++ b/AutoEvent/PowerupApi/PowerupManager.cs @@ -17,8 +17,8 @@ using PluginAPI.Core; using Powerups.Extensions; -namespace Powerups.Api; - +namespace Powerups; + public sealed class PowerupManager { /// From 0546794a87063a90bba4b37dccf014c8b92b85cd Mon Sep 17 00:00:00 2001 From: Redforce04 <74625280+Redforce04@users.noreply.github.com> Date: Sun, 22 Oct 2023 00:40:23 -0500 Subject: [PATCH 6/6] basic fixes --- AutoEvent/API/RoleCount.cs | 7 ++++++- AutoEvent/Commands/Debug/PowerupCommand.cs | 1 - AutoEvent/Games/Boss/Plugin.cs | 2 +- .../FallDown/Configs/FallDownConfigPresets.cs | 2 +- AutoEvent/Games/FallDown/Plugin.cs | 2 +- AutoEvent/Games/HideAndSeek/Plugin.cs | 2 +- AutoEvent/Games/Jail/Plugin.cs | 2 +- AutoEvent/Games/Puzzle/Configs/PuzzleConfig.cs | 5 ++++- AutoEvent/Games/Survival/Plugin.cs | 2 +- AutoEvent/Games/ZombieEscape/Plugin.cs | 2 +- AutoEvent/Plugin.cs | 6 +++--- AutoEvent/PowerupApi/Properties/AssemblyInfo.cs | 15 +-------------- AutoEvent/SchematicApi/Properties/AssemblyInfo.cs | 15 +-------------- 13 files changed, 22 insertions(+), 41 deletions(-) diff --git a/AutoEvent/API/RoleCount.cs b/AutoEvent/API/RoleCount.cs index 7873c50d..ea641f22 100644 --- a/AutoEvent/API/RoleCount.cs +++ b/AutoEvent/API/RoleCount.cs @@ -40,7 +40,7 @@ public RoleCount(int minimumPlayers = 0, int maximumPlayers = -1, float playerPe [Description($"The percentage of players that will be on the team. -1 to ignore.")] public float PlayerPercentage { get; set; } = 100; - public List GetPlayers([CanBeNull] List availablePlayers = null) + public List GetPlayers(bool alwaysLeaveOnePlayer = true, List? availablePlayers = null) { float percent = Player.GetPlayers().Count * (PlayerPercentage / 100f); int players = Mathf.Clamp((int)percent, MinimumPlayers, @@ -75,6 +75,11 @@ public List GetPlayers([CanBeNull] List availablePlayers = null) DebugLogger.LogDebug("Could not assign player to list.", LogLevel.Warn); DebugLogger.LogDebug($"{e}", LogLevel.Debug); } + if(alwaysLeaveOnePlayer && validPlayers.Count >= (availablePlayers ?? Player.GetPlayers()).Count) + { + var plyToRemove = validPlayers.RandomItem(); + validPlayers.Remove(plyToRemove); + } return validPlayers; } } \ No newline at end of file diff --git a/AutoEvent/Commands/Debug/PowerupCommand.cs b/AutoEvent/Commands/Debug/PowerupCommand.cs index 4613fe54..e43acd83 100644 --- a/AutoEvent/Commands/Debug/PowerupCommand.cs +++ b/AutoEvent/Commands/Debug/PowerupCommand.cs @@ -18,7 +18,6 @@ using CommandSystem; using PluginAPI.Core; using Powerups; -using Powerups.Api; using UnityEngine; using Player = PluginAPI.Core.Player; #if EXILED diff --git a/AutoEvent/Games/Boss/Plugin.cs b/AutoEvent/Games/Boss/Plugin.cs index b683b477..36d1ae95 100644 --- a/AutoEvent/Games/Boss/Plugin.cs +++ b/AutoEvent/Games/Boss/Plugin.cs @@ -100,7 +100,7 @@ protected override void CountdownFinished() { _boss = new List(); StartAudio(); - foreach (var player in Config.BossCount.GetPlayers()) + foreach (var player in Config.BossCount.GetPlayers(true)) { _boss.Add(player); player.GiveLoadout(Config.BossLoadouts); diff --git a/AutoEvent/Games/FallDown/Configs/FallDownConfigPresets.cs b/AutoEvent/Games/FallDown/Configs/FallDownConfigPresets.cs index 7b52a13b..cb7bbb68 100644 --- a/AutoEvent/Games/FallDown/Configs/FallDownConfigPresets.cs +++ b/AutoEvent/Games/FallDown/Configs/FallDownConfigPresets.cs @@ -14,7 +14,7 @@ namespace AutoEvent.Games.Infection; public static class FallDownConfigPresets { - public static FallDownConfig PlatformWarning { get; } = new FallDownConfig() + public static FallDownConfig PlatformWarning() => new FallDownConfig() { PlatformsHaveColorWarning = true }; diff --git a/AutoEvent/Games/FallDown/Plugin.cs b/AutoEvent/Games/FallDown/Plugin.cs index 4890808b..dd431417 100644 --- a/AutoEvent/Games/FallDown/Plugin.cs +++ b/AutoEvent/Games/FallDown/Plugin.cs @@ -22,7 +22,7 @@ public class Plugin : Event, IEventSound, IEventMap, IInternalEvent public override string Author { get; set; } = "KoT0XleB"; public override string CommandName { get; set; } = AutoEvent.Singleton.Translation.FallTranslate.FallCommandName; [EventConfig] public FallDownConfig Config { get; set; } = null; - [EventConfig] public FallDownConfig Warning => FallDownConfigPresets.PlatformWarning; + [EventConfig] public FallDownConfig Warning => FallDownConfigPresets.PlatformWarning(); public MapInfo MapInfo { get; set; } = new MapInfo() {MapName = "FallDown", Position = new Vector3(10f, 1020f, -43.68f) }; public SoundInfo SoundInfo { get; set; } = new SoundInfo() diff --git a/AutoEvent/Games/HideAndSeek/Plugin.cs b/AutoEvent/Games/HideAndSeek/Plugin.cs index ce1b65e5..a13d63c1 100644 --- a/AutoEvent/Games/HideAndSeek/Plugin.cs +++ b/AutoEvent/Games/HideAndSeek/Plugin.cs @@ -130,7 +130,7 @@ private IEnumerator TagPeriod() private void SelectPlayers() { List playersToChoose = Player.GetPlayers().Where(x => x.IsAlive).ToList(); - foreach(Player ply in Config.TaggerCount.GetPlayers(playersToChoose)) + foreach(Player ply in Config.TaggerCount.GetPlayers(true, playersToChoose)) { ply.GiveLoadout(Config.TaggerLoadouts); var item = ply.AddItem(Config.TaggerWeapon); diff --git a/AutoEvent/Games/Jail/Plugin.cs b/AutoEvent/Games/Jail/Plugin.cs index 784d77ce..a7285a93 100644 --- a/AutoEvent/Games/Jail/Plugin.cs +++ b/AutoEvent/Games/Jail/Plugin.cs @@ -159,7 +159,7 @@ protected override void OnStart() } } - foreach (Player ply in Config.JailorRoleCount.GetPlayers()) + foreach (Player ply in Config.JailorRoleCount.GetPlayers(true)) { ply.GiveLoadout(Config.JailorLoadouts, LoadoutFlags.IgnoreWeapons); try diff --git a/AutoEvent/Games/Puzzle/Configs/PuzzleConfig.cs b/AutoEvent/Games/Puzzle/Configs/PuzzleConfig.cs index 56dab876..c3d5a444 100644 --- a/AutoEvent/Games/Puzzle/Configs/PuzzleConfig.cs +++ b/AutoEvent/Games/Puzzle/Configs/PuzzleConfig.cs @@ -44,9 +44,12 @@ public class PuzzleConfig : EventConfig [Description("Uses random platform colors instead of green and magenta.")] public bool UseRandomPlatformColors { get; set; } = false; [Description("How far the platforms are spread out.")] - public DifficultyItem PlatformSpread { get; set; } = new DifficultyItem(1, 5f); + public DifficultyItem PlatformSpread { get; set; } = new DifficultyItem(5, 30f); + [Description("Used for color selection. This will be reworked in the future.")] public DifficultyItem HueDifficulty { get; set; } = new DifficultyItem(1, 0.6f); + [Description("Used for color selection. This will be reworked in the future.")] public DifficultyItem SaturationDifficulty { get; set; } = new DifficultyItem(1, 0.6f); + [Description("Used for color selection. This will be reworked in the future.")] public DifficultyItem VDifficulty { get; set; } = new DifficultyItem(1, 0.6f); } \ No newline at end of file diff --git a/AutoEvent/Games/Survival/Plugin.cs b/AutoEvent/Games/Survival/Plugin.cs index 56bbfdcb..4d313343 100644 --- a/AutoEvent/Games/Survival/Plugin.cs +++ b/AutoEvent/Games/Survival/Plugin.cs @@ -88,7 +88,7 @@ protected override void CountdownFinished() { Extensions.PlayAudio("Zombie2.ogg", 7, true, Name); - List players =Config.Zombies.GetPlayers(); + List players = Config.Zombies.GetPlayers(true); foreach (Player x in players) { DebugLogger.LogDebug($"Making player {x.Nickname} a zombie."); diff --git a/AutoEvent/Games/ZombieEscape/Plugin.cs b/AutoEvent/Games/ZombieEscape/Plugin.cs index 7e4b460a..250508bc 100644 --- a/AutoEvent/Games/ZombieEscape/Plugin.cs +++ b/AutoEvent/Games/ZombieEscape/Plugin.cs @@ -106,7 +106,7 @@ protected override void CountdownFinished() { Extensions.PlayAudio("Zombie2.ogg", 7, false, Name); - foreach (Player ply in Config.Zombies.GetPlayers()) + foreach (Player ply in Config.Zombies.GetPlayers(true)) { DebugLogger.LogDebug($"{ply.Nickname} chosen as a zombie.", LogLevel.Debug); ply.GiveLoadout(Config.ZombieLoadouts); diff --git a/AutoEvent/Plugin.cs b/AutoEvent/Plugin.cs index b13d15d8..63192b17 100644 --- a/AutoEvent/Plugin.cs +++ b/AutoEvent/Plugin.cs @@ -25,7 +25,7 @@ namespace AutoEvent #if EXILED public class AutoEvent : Plugin { - public override System.Version Version => new System.Version(9, 1, 10); + public override System.Version Version => new System.Version(9, 2, 0); public override string Name => "AutoEvent"; public override string Author => "Created by KoT0XleB, extended by swd and sky, Co-Maintained by Redforce04"; public static bool IsPlayedGames; @@ -39,7 +39,7 @@ public class AutoEvent [PluginConfig("Configs/translation.yml")] public Translation Translation; #endif - public const bool BetaRelease = true; // todo set beta to false before main release + public const bool BetaRelease = false; // todo set beta to false before main release /// /// The location of the AutoEvent folder for schematics, music, external events and event config / translations. /// @@ -55,7 +55,7 @@ public class AutoEvent public override void OnEnabled() #else [PluginPriority(LoadPriority.Low)] - [PluginEntryPoint("AutoEvent", "9.1.5", "An event manager plugin that allows you to run mini-games.", + [PluginEntryPoint("AutoEvent", "9.2.0", "An event manager plugin that allows you to run mini-games.", "KoT0XleB and Redforce04")] void OnEnabled() #endif diff --git a/AutoEvent/PowerupApi/Properties/AssemblyInfo.cs b/AutoEvent/PowerupApi/Properties/AssemblyInfo.cs index 8a69fc70..f7ce16ff 100644 --- a/AutoEvent/PowerupApi/Properties/AssemblyInfo.cs +++ b/AutoEvent/PowerupApi/Properties/AssemblyInfo.cs @@ -1,17 +1,6 @@ using System.Reflection; using System.Runtime.InteropServices; -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("PowerupApi")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("PowerupApi")] -[assembly: AssemblyCopyright("Copyright © 2023")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] // Setting ComVisible to false makes the types in this assembly not visible // to COM components. If you need to access a type in this assembly from @@ -30,6 +19,4 @@ // // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] \ No newline at end of file +// [assembly: AssemblyVersion("1.0.*")] \ No newline at end of file diff --git a/AutoEvent/SchematicApi/Properties/AssemblyInfo.cs b/AutoEvent/SchematicApi/Properties/AssemblyInfo.cs index aa14d5fb..a7f05f71 100644 --- a/AutoEvent/SchematicApi/Properties/AssemblyInfo.cs +++ b/AutoEvent/SchematicApi/Properties/AssemblyInfo.cs @@ -1,17 +1,6 @@ using System.Reflection; using System.Runtime.InteropServices; -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("SchematicApi")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("SchematicApi")] -[assembly: AssemblyCopyright("Copyright © 2023")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] // Setting ComVisible to false makes the types in this assembly not visible // to COM components. If you need to access a type in this assembly from @@ -30,6 +19,4 @@ // // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] \ No newline at end of file +// [assembly: AssemblyVersion("1.0.*")] \ No newline at end of file