Skip to content

Commit cdb24cf

Browse files
authored
Merge pull request #28 from UncomplicatedCustomServer/3.5.0-Dev
3.5.0 Update I forgor
2 parents 9b965bf + 9197c80 commit cdb24cf

104 files changed

Lines changed: 4414 additions & 1338 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

UncomplicatedCustomItems.sln

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Global
2020
{B39EE633-0EFE-42FC-B3E8-C6C4C86029E5}.Release|Any CPU.ActiveCfg = Release|Any CPU
2121
{B39EE633-0EFE-42FC-B3E8-C6C4C86029E5}.Release|Any CPU.Build.0 = Release|Any CPU
2222
{B39EE633-0EFE-42FC-B3E8-C6C4C86029E5}.Release|x64.ActiveCfg = Release|x64
23-
{B39EE633-0EFE-42FC-B3E8-C6C4C86029E5}.Release|x64.Build.0 = Release|x64
23+
{B39EE633-0EFE-42FC-B3E8-C6C4C86029E5}.Release|x64.Build.0 = Release|x64
2424
EndGlobalSection
2525
GlobalSection(SolutionProperties) = preSolution
2626
HideSolutionNode = FALSE
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
using System;
2+
3+
namespace UncomplicatedCustomItems.API.Attributes
4+
{
5+
[AttributeUsage(AttributeTargets.Class)]
6+
public class PluginCustomItem : Attribute { }
7+
}

UncomplicatedCustomItems/API/Features/AudioApi.cs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using Exiled.Loader;
2+
using System;
23
using System.IO;
34
using System.Linq;
45
using UncomplicatedCustomItems.API.Features.Helper;
@@ -22,12 +23,12 @@ public AudioApi()
2223
{
2324
if (!CheckForNVorbisDependency())
2425
{
25-
LogManager.Error("You don't have the AudioPlayerApi dependency NVorbis installed!\nInstall it to use the custom sound custom flag.\nIf you need support join our Discord server: https://discord.gg/5StRGu8EJV");
26+
LogManager.Error("You don't have the AudioPlayerApi dependency NVorbis installed!\nInstall it to use the custom sound custom flag.\nIf you need support join our Discord server: https://discord.gg/5StRGu8EJV\nError code: 0x400");
2627
EnableAudioApi = false;
2728
}
2829
if (!CheckForAudioPlayerApiDependency())
2930
{
30-
LogManager.Error("You don't have the dependency AudioPlayerApi installed!\nInstall it to use the custom sound custom flag.\nIf you need support join our Discord server: https://discord.gg/5StRGu8EJV");
31+
LogManager.Error("You don't have the dependency AudioPlayerApi installed!\nInstall it to use the custom sound custom flag.\nIf you need support join our Discord server: https://discord.gg/5StRGu8EJV\nError code: 0x405");
3132
EnableAudioApi = false;
3233
}
3334
else
@@ -61,24 +62,24 @@ public void PlayAudio(SummonedCustomItem CustomItem, Vector3 Coords)
6162
LogManager.Debug($"Audio API is enabled!");
6263
if (!string.IsNullOrEmpty(AudioSettings.AudioPath))
6364
{
65+
string clipId = $"sound_{Guid.NewGuid()}";
6466
LogManager.Debug($"Succesfully loaded audio path {AudioSettings.AudioPath}");
65-
AudioPlayer audioPlayer = AudioPlayer.CreateOrGet($"Global_Audio_{CustomItem.Serial}", onIntialCreation: (p) =>
67+
AudioPlayer audioPlayer = AudioPlayer.CreateOrGet($"Global_Audio_{Guid.NewGuid()}", onIntialCreation: (p) =>
6668
{
67-
float maxDistance = AudioSettings.AudibleDistance ?? 1f;
68-
Speaker speaker = p.AddSpeaker("Main", Coords, isSpatial: true, maxDistance: maxDistance);
69+
Speaker speaker = p.AddSpeaker("Main", Coords, isSpatial: true, maxDistance: AudioSettings.AudibleDistance ?? 1f);
6970
});
7071
float volume = Clamp(AudioSettings.SoundVolume, 1f, 100f);
71-
audioPlayer.AddClip($"sound_{CustomItem.Serial}", volume);
72-
AudioClipStorage.LoadClip(AudioSettings.AudioPath, $"sound_{CustomItem.Serial}");
72+
audioPlayer.AddClip($"{clipId}", volume);
73+
AudioClipStorage.LoadClip(AudioSettings.AudioPath, $"{clipId}");
7374
LogManager.Debug($"Playing {Path.GetFileName(AudioSettings.AudioPath)}");
7475
LogManager.Debug($"Audio should have been played.");
7576
}
7677
else
77-
LogManager.Error($"Audio path is null please fill out the config properly.");
78+
LogManager.Warn($"Audio path is null please fill out the config properly.");
7879
}
7980
else
8081
{
81-
LogManager.Error("You don't have AudioPlayerApi or its dependency NVorbis installed!\nInstall it to use the custom sound custom flag.\nIf you need support join our Discord server: https://discord.gg/5StRGu8EJV");
82+
LogManager.Warn("You don't have AudioPlayerApi or its dependency NVorbis installed!\nInstall it to use the custom sound custom flag.\nIf you need support join our Discord server: https://discord.gg/5StRGu8EJV");
8283
}
8384
}
8485
}

UncomplicatedCustomItems/API/Features/BadgeManager.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using System.Collections.Generic;
22

3-
43
namespace UncomplicatedCustomItems.API.Features
54
{
65
internal class BadgeManager

UncomplicatedCustomItems/API/Features/CustomItem.cs

Lines changed: 43 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using UnityEngine;
88
using UncomplicatedCustomItems.Enums;
99
using UncomplicatedCustomItems.API.Features.Helper;
10+
using UncomplicatedCustomItems.Extensions;
1011

1112
namespace UncomplicatedCustomItems.API.Features
1213
{
@@ -18,7 +19,13 @@ public class CustomItem : ICustomItem
1819
/// </summary>
1920
public static List<ICustomItem> List => CustomItems.Values.ToList();
2021

22+
/// <summary>
23+
/// Gets a list of every unregistered <see cref="ICustomItem"/>
24+
/// </summary>
25+
public static List<ICustomItem> UnregisteredList => UnregisteredCustomItems.Values.ToList();
26+
2127
internal static Dictionary<uint, ICustomItem> CustomItems { get; set; } = new();
28+
internal static Dictionary<uint, ICustomItem> UnregisteredCustomItems { get; set; } = new();
2229

2330
/// <summary>
2431
/// Register a new <see cref="ICustomItem"/> inside the plugin
@@ -29,26 +36,41 @@ public static void Register(ICustomItem item)
2936
if (!Utilities.CustomItemValidator(item, out string error))
3037
{
3138
LogManager.Warn($"Unable to register the ICustomItem with the Id {item.Id} and name '{item.Name}':\n{error}\nError code: 0x029");
39+
UnregisteredCustomItems.TryAdd(item.Id, item);
3240
return;
3341
}
34-
CustomItems.Add(item.Id, item);
42+
CustomItems.TryAdd(item.Id, item);
3543
LogManager.Info($"Successfully registered ICustomItem '{item.Name}' (Id: {item.Id}) into the plugin!");
3644
}
3745

46+
internal bool HasModule(CustomFlags Flag)
47+
{
48+
if (CustomFlags.HasValue && CustomFlags.Value.HasFlag(Flag))
49+
{
50+
LogManager.Silent($"{Name} has {Flag}");
51+
return true;
52+
}
53+
else
54+
return false;
55+
}
56+
3857
/// <summary>
39-
/// Unregister a <see cref="ICustomItem"/> from the plugin by it's class
58+
/// Unregister a <see cref="ICustomItem"/> from the plugin by its class
4059
/// </summary>
4160
/// <param name="item"></param>
4261
public static void Unregister(ICustomItem item) => Unregister(item.Id);
4362

4463
/// <summary>
45-
/// Unregister a <see cref="ICustomItem"/> from the plugin by it's Id
64+
/// Unregister a <see cref="ICustomItem"/> from the plugin by its Id
4665
/// </summary>
4766
/// <param name="item"></param>
4867
public static void Unregister(uint item)
4968
{
50-
if (CustomItems.ContainsKey(item))
69+
if (CustomItems.ContainsKey(item) || UnregisteredCustomItems.ContainsKey(item))
70+
{
5171
CustomItems.Remove(item);
72+
UnregisteredCustomItems.Remove(item);
73+
}
5274
}
5375

5476
/// <summary>
@@ -66,82 +88,83 @@ public static uint GetFirstFreeId(uint from = 0)
6688
}
6789

6890
/// <summary>
69-
/// The unique Id of the Custom Item. Can't be <= 0
91+
/// The unique Id of the Custom Item. Can't be less than 1
7092
/// </summary>
71-
public uint Id { get; set; } = 1;
93+
public virtual uint Id { get; set; } = 1;
7294

7395
/// <summary>
7496
/// The Name of the object. Can appears when for example you pick it up
7597
/// </summary>
7698
[Description("The name of the custom item")]
77-
public string Name { get; set; } = "Detonator";
99+
public virtual string Name { get; set; } = "Detonator";
78100

79101
/// <summary>
80102
/// The description. Useful at the moment ig
81103
/// </summary>
82104
[Description("The description of the custom item")]
83-
public string Description { get; set; } = "25/06/2024";
105+
public virtual string Description { get; set; } = "25/06/2024";
84106

85107
/// <summary>
86108
/// Gets or sets the badge name
87109
/// </summary>
88110
[Description("Sets the badge name")]
89-
public string BadgeName { get; set; } = "Uncomplicated Custom Items";
111+
public virtual string BadgeName { get; set; } = "Uncomplicated Custom Items";
90112

91113
/// <summary>
92114
/// Gets or sets the badge color
93115
/// </summary>
94-
[Description("Sets the badge color")]
95-
public string BadgeColor { get; set; } = "pumpkin";
116+
[Description("Sets the badge color. This uses the badge colors available for server")]
117+
public virtual string BadgeColor { get; set; } = "pumpkin";
96118

97119
/// <summary>
98120
/// The weight of the item
99121
/// </summary>
100122
[Description("The weight of the custom item")]
101-
public float Weight { get; set; } = 2f;
123+
public virtual float Weight { get; set; } = 2f;
102124

103125
/// <summary>
104126
/// Whether if the item won't be removed from the player's inventory
105127
/// </summary>
106128
[Description("Whether if the item won't be removed from the player's inventory after being used. Available only for Consumable items!")]
107-
public bool Reusable { get; set; } = false;
129+
public virtual bool Reusable { get; set; } = false;
108130

109131
/// <summary>
110132
/// The <see cref="ItemType"/> (Base) of the Custom Item
111133
/// </summary>
112134
[Description("The Item base for the custom item")]
113-
public ItemType Item { get; set; } = ItemType.Coin;
135+
public virtual ItemType Item { get; set; } = ItemType.Coin;
114136

115137
/// <summary>
116138
/// The Scale of the Custom Item. If 0, 0, 0 then it's disabled
117139
/// </summary>
118140
[Description("The scale of the custom item, 0 0 0 means disabled")]
119-
public Vector3 Scale { get; set; } = Vector3.one;
141+
public virtual Vector3 Scale { get; set; } = Vector3.one;
120142

121143
/// <summary>
122144
/// The Spawn data for the custom item.
123145
/// </summary>
124-
public ISpawn Spawn { get; set; } = new Spawn();
146+
public virtual ISpawn Spawn { get; set; } = new Spawn();
125147

126148
/// <summary>
127149
/// Custom flags of the item
128150
/// </summary>
129151
[Description("Custom flags for the item")]
130-
public CustomFlags? CustomFlags { get; set; } = new();
152+
public virtual CustomFlags? CustomFlags { get; set; } = new();
131153

132154
/// <summary>
133155
/// Custom flag settings of the item
134156
/// </summary>
135-
public IFlagSettings FlagSettings { get; set; } = new FlagSettings();
157+
[Description("Settings for the CustomFlags. You can remove any unused settings.")]
158+
public virtual IFlagSettings FlagSettings { get; set; } = new FlagSettings();
136159

137160
/// <summary>
138161
/// The <see cref="CustomItemType"/> of the Custom Item
139162
/// </summary>
140-
public CustomItemType CustomItemType { get; set; } = CustomItemType.Item;
163+
public virtual CustomItemType CustomItemType { get; set; } = CustomItemType.Item;
141164

142165
/// <summary>
143166
/// The <see cref="IData">Custom Data</see>, based on the CustomItemType
144167
/// </summary>
145-
public IData CustomData { get; set; } = new ItemData();
168+
public virtual IData CustomData { get; set; } = new ItemData();
146169
}
147170
}

UncomplicatedCustomItems/API/Features/CustomModules/CoroutineModule.cs

Lines changed: 0 additions & 34 deletions
This file was deleted.

UncomplicatedCustomItems/API/Features/CustomModules/CustomModule.cs

Lines changed: 0 additions & 112 deletions
This file was deleted.

0 commit comments

Comments
 (0)