Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/surface #86

Merged
merged 8 commits into from
Jan 15, 2022
Merged

Feature/surface #86

merged 8 commits into from
Jan 15, 2022

Conversation

Jacob-Mango
Copy link
Collaborator

auto surface = CF_Surface.At(GetGame().GetPlayer().GetPosition());
surface = CF_Surface.At(GetGame().GetPlayer().GetPosition()); // if the player didn't move, then the surface will be of the same instance
Print(surface.Interior); // check if we are in an interior surface

@Jacob-Mango Jacob-Mango changed the base branch from production to development January 5, 2022 14:37
@Jacob-Mango
Copy link
Collaborator Author

Jacob-Mango commented Jan 6, 2022

Tested in Expansion for getting vehicle surface information. Works.

Copy link
Owner

@Arkensor Arkensor left a comment

Choose a reason for hiding this comment

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

I did not know this kind of stuff was needed but looks like it could save someone a bit of pain so alrighty ...

I would suggest you change the constructors of the Surfaces to protected so they can only be constructed once (singleton) internally. Also I would then recommend to make the class members constant to avoid someone modifying the instances?

@Jacob-Mango
Copy link
Collaborator Author

I would suggest you change the constructors of the Surfaces to protected so they can only be constructed once (singleton) internally.

I'll have to make it private as Enforce Script produces a compile error with it protected. Still allows people to mod the class which will be much more likely than a modder creating a new class.

Also I would then recommend to make the class members constant to avoid someone modifying the instances?

Unfortunately, that will result in a compile error.

@Arkensor
Copy link
Owner

Arkensor commented Jan 8, 2022

Also I would then recommend to make the class members constant to avoid someone modifying the instances?

Unfortunately, that will result in a compile error.

I think you can do do const string m_Value = GetValue(); or I think also const string m_Value = valueVariable; that both execute when the class is being created.

The idea would be to store the values in static buffers which can be private to the class. Then have a static CF_Surface.Create(...) method where you accept all the values as parameters. Assign them to the buffers, then create a real new CF_Surface instance where its normal public const members are assigned with the buffer values. It appears a bit complicated at first, but I think this way would work and allow us to have const variables that we assign once that are not compile time constants.

If the error you got was unrelated to assigning cost variables let me know which one it was.

@Arkensor Arkensor added the enhancement New feature or request label Jan 8, 2022
@Jacob-Mango
Copy link
Collaborator Author

You never "completed" the previous review so consider this the notification to re-review

Arkensor
Arkensor previously approved these changes Jan 15, 2022
@Jacob-Mango Jacob-Mango merged commit eb7bf2a into development Jan 15, 2022
@Jacob-Mango Jacob-Mango deleted the feature/surface branch January 15, 2022 10:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants