Skip to content

feat: Method to Get wrapper from GameObject & option to not spawn prefab helper networked.#785

Open
Saskyc wants to merge 7 commits into
ExMod-Team:masterfrom
Saskyc:master
Open

feat: Method to Get wrapper from GameObject & option to not spawn prefab helper networked.#785
Saskyc wants to merge 7 commits into
ExMod-Team:masterfrom
Saskyc:master

Conversation

@Saskyc

@Saskyc Saskyc commented Mar 26, 2026

Copy link
Copy Markdown

Description

Describe the changes
Adds methods to Get/TryGet Camera and AdminToy directly from GameObject.
Adds boolean paramater to Method PrefabHelper.Spawn that's set defaultly to true, which specified if prefab should use NetworkServer.Spawn or not.

What is the current behavior? (You can also link to an open issue here): No methods that get X wrapper from GameObject.

What is the new behavior? (if this is a feature change): Method that get X wrapper from GameObject.

Does this PR introduce a breaking change? (What changes might users need to make in their application due to this PR?): No breaking changes are in this PR.

Other information: X


Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentations

Submission checklist

  • I have checked the project can be compiled
  • I have tested my changes and it worked as expected

Patches (if there are any changes related to Harmony patches)

  • I have checked no IL patching errors in the console

Other

  • Still requires more testing

Camera.cs changes: New method to get camera from GameObject and TryGet method with it.
PrefabHelper.cs changes: Simple bool defining if prefab should be spawned by server or not.
AdminToy.cs changes: Method to Get AdminToy by GameObject, which basically just gets the component. It's there to make lives of developers easier.
@github-actions github-actions Bot added the API label Mar 26, 2026
@Saskyc Saskyc changed the title All changes in this commit are non-breaking. feat: Method to Get wrapper from GameObject & option to not spawn prefab helper networked. Mar 26, 2026
@Saskyc

Saskyc commented Mar 26, 2026

Copy link
Copy Markdown
Author

This is my first Pull Request for Exiled if there are any issues let me know. I should be able to answer within a day or two max.

Comment thread EXILED/Exiled.API/Features/Camera.cs Outdated
Comment on lines +278 to +293
/// <summary>
/// Gets the <see cref="Camera"/> belonging to the <see cref="GameObject"/>, if any.
/// </summary>
/// <param name="gameObject">The <see cref="GameObject"/> of the camera.</param>
/// <returns>A <see cref="Camera"/> or <see langword="null"/> if not found.</returns>
public static Camera Get(GameObject gameObject)
{
foreach (Scp079InteractableBase scp079InteractableBase in Scp079InteractableBase.AllInstances)
{
if (scp079InteractableBase.gameObject == gameObject)
return Get((Scp079Camera)scp079InteractableBase);
}

return null;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you better have to use Camera.List

technically we do .GetComponent() but true that slow compared to a loop

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to Camera.List, went through all checks, relolved.

@Saskyc

Saskyc commented Mar 27, 2026

Copy link
Copy Markdown
Author

I accidentally clicked resolve on Yamatos changes it's not resolved and I remember what needs to be changed

Comment thread EXILED/Exiled.API/Features/PrefabHelper.cs Outdated

@louis1706 louis1706 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad my previous comment wasn't right for Camera.List we are forced to go with .GetComponent() even if it's slower

@louis1706 louis1706 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with master merged into pr the problem got solved

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants