Repository navigation
Conversation
|
If you have any questions, you can write here or to me on Discord: scaletta2019 |
| /// <summary> | ||
| /// Gets or sets a value indicating whether the magazine is attached from the weapon. | ||
| /// </summary> | ||
| public bool IsMagazineDeattached | ||
| { | ||
| get => !IsMagazineAttached; | ||
| set => IsMagazineAttached = !value; | ||
| } |
There was a problem hiding this comment.
If you think this section of code is useless, then let's think this code is useless too:
It may be useless, but it is not beneficial to remove it because that would be a breaking change. There is also no reason to add new junk code.
There was a problem hiding this comment.
If you think this section of code is useless, then let's think this code is useless too:
It may be useless, but it is not beneficial to remove it because that would be a breaking change. There is also no reason to add new junk code.
No, no, no... you've had enough of this "critical code." You shouldn't have added it and then been afraid to remove it. As long as these and similar properties exist in the code, the code I've submitted will comply with Exiled standards.
This is excellent code; it reduces the cognitive load when reading it in plugins. There is no problem with it.
|
|
||
| /// <inheritdoc cref="Player.Count"/> | ||
| public static int PlayerCount => Player.Count; | ||
| /// <summary> | ||
| /// Gets the number of players excluding NPCs. | ||
| /// </summary> | ||
| public static int PlayerCount => Player.Dictionary.Values.Count(x => !x.IsNPC); |
There was a problem hiding this comment.
No please don't break all plugin that would use that
There was a problem hiding this comment.
No please don't break all plugin that would use that
Okay, I'll change it back. However, I don't understand why this property originally included NPCs. It once took me quite a while to figure out what was causing the bug. The problem was that someone misnamed the property. You should have named it something that would make it clear it included NPCs as well. If necessary, I can change the documentation for this property.
| { | ||
| if (gameObject != null) | ||
| { | ||
| // ParentDoor requires enabling "unsafe code" |
There was a problem hiding this comment.
Weird comment?
I will remove this comment.
| if (room.Type == RoomType.Surface) | ||
| return relativePos; |
There was a problem hiding this comment.
Surface is a functional room technically i only see the purpose of this for Unknown Room
Or if you do it with the surface let's do it to all non dynamic rooms (i prefer to only do it on null that would be unknown)
Surface and pocket
There was a problem hiding this comment.
Surface is a functional room technically i only see the purpose of this for Unknown Room
Or if you do it with the surface let's do it to all non dynamic rooms (i prefer to only do it on null that would be unknown)
Surface and pocket
I don't understand what you didn't like about this code.
| public static string ToHumanReadable(this TimeSpan timeSpan) | ||
| { | ||
| if (timeSpan.TotalHours < 1) | ||
| return timeSpan.ToString(@"mm\:ss"); | ||
|
|
||
| if (timeSpan.TotalDays < 1) | ||
| return timeSpan.ToString(@"hh\:mm\:ss"); | ||
|
|
||
| string daysPart = timeSpan.Days == 1 ? "1 day" : $"{timeSpan.Days} days"; | ||
| string timePart = timeSpan.ToString(@"hh\:mm\:ss"); | ||
| return $"{daysPart}, {timePart}"; | ||
| } |
There was a problem hiding this comment.
How does it handle differences like language/ 24h or 12h Am/Pm
There was a problem hiding this comment.
How does it handle differences like language/ 24h or 12h Am/Pm
Normal people use the 24-hour clock. In any case, I didn't intend for this method to be universal. If someone needs it, they can always add their own extension method to this class with a different name or a different overload. I don't see any problem with that.
There was a problem hiding this comment.
Normal people use the 24-hour clock. In any case, I didn't intend for this method to be universal. If someone needs it, they can always add their own extension method to this class with a different name or a different overload. I don't see any problem with that.
It's an API meant for many people to use. A lot of this code is pretty pointless or not helpful to many people.
There was a problem hiding this comment.
Normal people use the 24-hour clock. In any case, I didn't intend for this method to be universal. If someone needs it, they can always add their own extension method to this class with a different name or a different overload. I don't see any problem with that.
It's an API meant for many people to use. A lot of this code is pretty pointless or not helpful to many people.
Write your own method and add it. Be sure to take into account the 250 official languages. Keep in mind that each language has its own vocabulary and grammar. I used one specific method for 99% of tasks. But you can add your own.
There was a problem hiding this comment.
that why i don't see a point for HumanReadable on this one
There was a problem hiding this comment.
I don't really see why we need a TimeSpanExtensions, this is basic ToString stuff
And I repeat once again that the default ToString override isn't working as it should.
var timeSpan = TimeSpan.FromMinutes(1);
Log.Debug(timeSpan.ToString());
Log.Debug(timeSpan.ToString("c"));
Log.Debug(timeSpan.ToString("g"));
Log.Debug(timeSpan.ToString("G"));
Log.Debug(timeSpan.ToString(@"h\:mm\:ss"));
Log.Debug(timeSpan.ToString(@"m\:ss"));
Log.Debug(timeSpan.ToHumanReadable());[2026-09-26 13:24:16.581 +03:00] [DEBUG] [ToolTestHelper] 00:01:00
[2026-09-26 13:24:16.596 +03:00] [DEBUG] [ToolTestHelper] 00:01:00
[2026-09-26 13:24:16.612 +03:00] [DEBUG] [ToolTestHelper] 0:01:00
[2026-09-26 13:24:16.628 +03:00] [DEBUG] [ToolTestHelper] 0:00:01:00.0000000
[2026-09-26 13:24:16.643 +03:00] [DEBUG] [ToolTestHelper] 0:01:00
[2026-09-26 13:24:16.658 +03:00] [DEBUG] [ToolTestHelper] 1:00
[2026-09-26 13:24:16.674 +03:00] [DEBUG] [ToolTestHelper] 01:00There was a problem hiding this comment.
I’ve slightly updated this method.
Log.Debug(TimeSpan.FromTicks(1).ToHumanReadable());
Log.Debug(TimeSpan.FromMilliseconds(1).ToHumanReadable());
Log.Debug(TimeSpan.FromSeconds(1).ToHumanReadable());
Log.Debug(TimeSpan.FromMinutes(1).ToHumanReadable());
Log.Debug(TimeSpan.FromHours(1).ToHumanReadable());
Log.Debug(TimeSpan.FromDays(1).ToHumanReadable());
Log.Debug(TimeSpan.FromDays(1).Negate().ToHumanReadable());[2026-09-26 14:58:43.668 +03:00] [DEBUG] [ToolTestHelper] 0:00
[2026-09-26 14:58:43.683 +03:00] [DEBUG] [ToolTestHelper] 0:00
[2026-09-26 14:58:43.700 +03:00] [DEBUG] [ToolTestHelper] 0:01
[2026-09-26 14:58:43.715 +03:00] [DEBUG] [ToolTestHelper] 1:00
[2026-09-26 14:58:43.731 +03:00] [DEBUG] [ToolTestHelper] 01:00:00
[2026-09-26 14:58:43.746 +03:00] [DEBUG] [ToolTestHelper] 1:00:00:00
[2026-09-26 14:58:43.761 +03:00] [DEBUG] [ToolTestHelper] -1:00:00:00There was a problem hiding this comment.
I still think this should live outside of EXILED, and "ToString override isn't working as it should." is false, and I'm pretty sure you can use Cultures and DateTime to better represent what you need
There was a problem hiding this comment.
There was a problem hiding this comment.
I won't argue, please re-read what I said and next time refrain from saying offensive things, I'm trying to help you get the PR accepted
"My criticism" is towards the PR, not you
| public static bool NextBool(this Random rnd) | ||
| { | ||
| return rnd.Next(2) == 0; | ||
| } |
There was a problem hiding this comment.
Pretty sure this is very badly optimised
There was a problem hiding this comment.
Pretty sure this is very badly optimised
I don't see any particular problem here, but you can do it like this:
(rnd.Next() & 1) == 0
| /// <summary> | ||
| /// Generate a random float. | ||
| /// </summary> | ||
| /// <param name="rnd"><see cref="Random"/> object.</param> | ||
| /// <param name="min">Minimum value.</param> | ||
| /// <param name="max">Maximum value.</param> | ||
| /// <returns>Random value between minimum and maximum.</returns> | ||
| public static float NextFloat(this Random rnd, float min, float max) | ||
| { | ||
| return (float)((rnd.NextDouble() * (max - min)) + min); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Generate a random float. | ||
| /// </summary> | ||
| /// <param name="rnd"><see cref="Random"/> object.</param> | ||
| /// <param name="min">Minimum value.</param> | ||
| /// <param name="max">Maximum value.</param> | ||
| /// <returns>Random value between minimum and maximum.</returns> | ||
| public static float NextFloat(this Random rnd, double min, float max) | ||
| { | ||
| return (float)((rnd.NextDouble() * (max - min)) + min); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Generate a random float. | ||
| /// </summary> | ||
| /// <param name="rnd"><see cref="Random"/> object.</param> | ||
| /// <param name="min">Minimum value.</param> | ||
| /// <param name="max">Maximum value.</param> | ||
| /// <returns>Random value between minimum and maximum.</returns> | ||
| public static float NextFloat(this Random rnd, float min, double max) | ||
| { | ||
| return (float)((rnd.NextDouble() * (max - min)) + min); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Generate a random float. | ||
| /// </summary> | ||
| /// <param name="rnd"><see cref="Random"/> object.</param> | ||
| /// <param name="min">Minimum value.</param> | ||
| /// <param name="max">Maximum value.</param> | ||
| /// <returns>Random value between minimum and maximum.</returns> | ||
| public static float NextFloat(this Random rnd, double min, double max) | ||
| { | ||
| return (float)((rnd.NextDouble() * (max - min)) + min); | ||
| } |
There was a problem hiding this comment.
Doesn't Unity Random already handle some of these ?
There was a problem hiding this comment.
Doesn't Unity Random already handle some of these ?
Because not everyone likes Random from unity.
There was a problem hiding this comment.
Because not everyone likes Random from unity.
??? What is wrong with unity randoms?
There was a problem hiding this comment.
Because not everyone likes Random from unity.
??? What is wrong with unity randoms?
What difference does it make to you? What changes for you? Use the randomness you want.
There was a problem hiding this comment.
The difference is that there is a proper way to use the Engine and it's features, why do we need another random gen?
There was a problem hiding this comment.
The difference is that there is a proper way to use the Engine and it's features, why do we need another random gen?
Alright, you've convinced me. I removed those overloads that return a float.
7d85cb3 to
de125a4
Compare
| where T : Door => Get(doorVariant) as T; | ||
|
|
||
| /// <summary> | ||
| /// Gets the door object associated with a specific <see cref="ButtonVariant"/>, or creates a new one if there isn't one. |
There was a problem hiding this comment.
Why would you create a new door if there is not a door associated with that buttonvariant?
There was a problem hiding this comment.
Why would you create a new door if there is not a door associated with that buttonvariant?
fixed
| /// </summary> | ||
| /// <param name="message">The message to be sent.</param> | ||
| public static void Error(string message) => Send($"[{Assembly.GetCallingAssembly().GetName().Name}] {message}", Discord.LogLevel.Error, ConsoleColor.DarkRed); | ||
| public static void Error(string message = "") => Send($"[{Assembly.GetCallingAssembly().GetName().Name}] {message}", Discord.LogLevel.Error, ConsoleColor.DarkRed); |
There was a problem hiding this comment.
Why would anyone call a method meant to print to the console without passing a string to the method to be printed?
There was a problem hiding this comment.
Why would anyone call a method meant to print to the console without passing a string to the method to be printed?
Have you ever split console logs to make them easier to read?
There was a problem hiding this comment.
then you could just \n ?
Because I don't want to use \n. I want the methods in the Log class not to require any arguments from the user by default. I designed the code so that these changes wouldn't break any existing functionality.
9fefd96 to
61f4978
Compare
aeb9920 to
0bbaeb8
Compare
… forgot how it behaves. My mistake.
0bbaeb8 to
ab2bd62
Compare
|
why are you squashing all your commit ? |
|
I squash commits because I can't revert changes any other way. Which specific parts of all this do you consider "breaking changes"? |
Right now it's the FirearmType change. Regardless, I'm probably not gonna approve of this PR myself for quite a while because half of the things added here simply don't belong as a part of EXILED. |
|
some part of this PR are good to include but yeah we need to separate it |
| /// <summary> | ||
| /// Converts a world position to a position relative to the specified room's local coordinate system. | ||
| /// </summary> | ||
| /// <param name="worldPos">The world‑space position to convert.</param> | ||
| /// <param name="room">The room whose local space will be used as the reference.</param> | ||
| /// <returns> | ||
| /// The position expressed in the room's local space. | ||
| /// If the room is the <see cref="RoomType.Surface"/>, the original world position is returned unchanged. | ||
| /// </returns> | ||
| public static Vector3 FromWorldToRelativePos(this Vector3 worldPos, Room room) | ||
| { | ||
| if (room.Type == RoomType.Surface) | ||
| return worldPos; | ||
| return room.Transform.InverseTransformPoint(worldPos); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Converts a position relative to the specified room's local space back to world space. | ||
| /// </summary> | ||
| /// <param name="relativePos">The local‑space position to convert.</param> | ||
| /// <param name="room">The room whose local space was used as the reference.</param> | ||
| /// <returns> | ||
| /// The position expressed in world space. | ||
| /// If the room is the <see cref="RoomType.Surface"/>, the original local position is returned unchanged | ||
| /// (since surface uses world coordinates directly). | ||
| /// </returns> | ||
| public static Vector3 FromRelativeToWorldPos(this Vector3 relativePos, Room room) | ||
| { | ||
| if (room.Type == RoomType.Surface) | ||
| return relativePos; | ||
| return room.Transform.TransformPoint(relativePos); | ||
| } | ||
| } |
There was a problem hiding this comment.
| /// <summary> | |
| /// Converts a world position to a position relative to the specified room's local coordinate system. | |
| /// </summary> | |
| /// <param name="worldPos">The world‑space position to convert.</param> | |
| /// <param name="room">The room whose local space will be used as the reference.</param> | |
| /// <returns> | |
| /// The position expressed in the room's local space. | |
| /// If the room is the <see cref="RoomType.Surface"/>, the original world position is returned unchanged. | |
| /// </returns> | |
| public static Vector3 FromWorldToRelativePos(this Vector3 worldPos, Room room) | |
| { | |
| if (room.Type == RoomType.Surface) | |
| return worldPos; | |
| return room.Transform.InverseTransformPoint(worldPos); | |
| } | |
| /// <summary> | |
| /// Converts a position relative to the specified room's local space back to world space. | |
| /// </summary> | |
| /// <param name="relativePos">The local‑space position to convert.</param> | |
| /// <param name="room">The room whose local space was used as the reference.</param> | |
| /// <returns> | |
| /// The position expressed in world space. | |
| /// If the room is the <see cref="RoomType.Surface"/>, the original local position is returned unchanged | |
| /// (since surface uses world coordinates directly). | |
| /// </returns> | |
| public static Vector3 FromRelativeToWorldPos(this Vector3 relativePos, Room room) | |
| { | |
| if (room.Type == RoomType.Surface) | |
| return relativePos; | |
| return room.Transform.TransformPoint(relativePos); | |
| } | |
| } | |
| /// <summary> | |
| /// Converts a world position to a position relative to the specified room's local coordinate system. | |
| /// </summary> | |
| /// <param name="worldPos">The world‑space position to convert.</param> | |
| /// <param name="room">The transform whose local space will be used as the reference.</param> | |
| /// <returns> | |
| /// The position expressed in the room's local space. | |
| /// </returns> | |
| public static Vector3 FromWorldToRelativePos(this Vector3 worldPos, Transform transform) | |
| { | |
| return transform.InverseTransformPoint(worldPos); | |
| } | |
| /// <summary> | |
| /// Converts a position relative to the specified room's local space back to world space. | |
| /// </summary> | |
| /// <param name="relativePos">The local‑space position to convert.</param> | |
| /// <param name="transform">The transform whose local space was used as the reference.</param> | |
| /// <returns> | |
| /// The position expressed in world space. | |
| /// </returns> | |
| public static Vector3 FromRelativeToWorldPos(this Vector3 relativePos, Transform transform) | |
| { | |
| return transform.TransformPoint(relativePos); | |
| } | |
| } |
There was a problem hiding this comment.
i write this just to show how i would have prefered it but at this point i don't see the interest of making an extension for it (but i agreed original naming TransformPoint isn't very helpfull for new dev)
| /// <summary> | ||
| /// A set of extensions for <see cref="PlayerPermissions"/>. | ||
| /// </summary> | ||
| public static class PlayerPermissionsExtensions |
|
i have included some of these addition in main (3 last commit with Pudge as coauthor) |
|
Okay. And what was it that you didn’t like about the set of commits that didn’t spark any debate? |



Description
Describe the changes
Getmethod forDoor.Door.Get(GameObject)methodFirearmLogclass methodsPlayerServer.ReservedSlotsTypes of changes
Submission checklist
Other