Skip to content

Refactor socket - #328

Open
Vitroze wants to merge 20 commits into
StyledStrike:mainfrom
Vitroze:refactor_socket
Open

Refactor socket#328
Vitroze wants to merge 20 commits into
StyledStrike:mainfrom
Vitroze:refactor_socket

Conversation

@Vitroze

@Vitroze Vitroze commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Summary

In this PR, the socket code has been completely rewritten from scratch.
It eliminates the need for timers and Think hooks (except in dev mode) in favor of the Touch function.

Features

  • Creation of a dedicated Socket entity for better socket behavior management.
  • Uses the Touch function instead of a timer to locate the nearest socket.
  • Micro-optimization regarding entity removal.
  • The vehiclesWithSockets table is retained for backward compatibility but is not used in Glide.
  • Added the radius argument to the socket, allowing the detection zone to be configured.

Dev Mode

  • Dev mode logic is currently implemented directly within the entity's Think function; this will be reworked in a future PR to use a timer that is created or destroyed based on the activation or deactivation of the developer convar.

@StyledStrike

Copy link
Copy Markdown
Owner

I think the only breaking change here is that ENT:InitializeSockets( socket ) copies the properties from a socket by value, so editing a vehicle's ENT.Sockets won't apply the changes right away, and requires respawning the vehicle

@StyledStrike

Copy link
Copy Markdown
Owner

Also InitializeSockets (plural) is a bit of a misnomer since it handles one of the sockets from ENT.Sockets, not the whole table

@Vitroze

Vitroze commented Jul 9, 2026

Copy link
Copy Markdown
Contributor Author

InitializeSockets

Essentially, it just calls the ENT:InitializeSockets function, and the problem will be resolved.

However, if you really want full compatibility without calling that function, I can make a modification if you like.

For better compatibility, `setpos` and `setangles` will be handled within the `ENT:InitializeSocket` function.
@Vitroze

Vitroze commented Jul 9, 2026

Copy link
Copy Markdown
Contributor Author

Also InitializeSockets (plural) is a bit of a misnomer since it handles one of the sockets from ENT.Sockets, not the whole table

I’ve changed it, the name was indeed quite misleading.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants