yamp-project / v-issues

0 stars 0 forks source link

Vehicle API additions, that might be good #2

Open ByAlexius opened 5 months ago

ByAlexius commented 5 months ago

What is the scope of the api ?

Propose an api design A clear and concise description of what you want to happen.

I have think these additions would be great and help developers while programming with the Vehicle API. The code examples use Java variable types for parameters.

Note: While I primarily described setter methods, getters are also required. However, including them might make the list to long.

Code Example Functionality
getSeatedPed(int seatPosition/seatId) Returns the ped seated at the specified seat ID (described in code). If no one is seated, returns null.
getAllSeatedPeds() Returns an array or list containing all peds currently inside the vehicle, along with their corresponding seat IDs (described above).
eject(int seatId) Removes the ped from the vehicle based on the provided seat ID.
eject(Player player) Removes the ped from the vehicle based on a direct object reference.
ejectAll() Removes all the peds from the vehicle.
setLockState(boolean lockState) Sets the vehicle's lock state. If true, no ped can enter or exit (implementing the "cannot exit" part is optional).
setEngineHealth(int health) Sets the engine health.
setEngineState(boolean state) Sets the engine state. The state should be persisted until the state is again changed.
setLightState(int lightId, int brightness (optional)) Allows individual light control for the car. Enables/disables each light and optionally sets its brightness (not all lights may have adjustable brightness).
Please Read: The following functions could be combined into a single function that accepts a JSON string containing all the car's cosmetic features. However, I believe individual methods provide better readability.
setPrimaryColor(String hex) Sets the primary car color using a hex value.
setPrimaryColor(int r, int g, int b) Sets the primary car color using RGB values.
setPrimaryColor(String color) Sets the primary car color using predefined color names (white, black, yellow, etc.).
Please Read: Similar functionality can be implemented for secondary colors and the pearlescent effect.
setLicensePlate(String licensePlateText) Sets the license plate text. If exceeding the maximum length, truncates the text.
setVisibility(boolean state) Sets the vehicle's visibility. Consider adding an option to keep internal peds visible while hiding the vehicle itself.
getPosition() Gets the position of the vehicle in the world.
getDimension() Gets the dimension the vehicle is in.

I will update this list if i think of more methods.

If you have improvement idea's, don't hesitate to add comments.

Thanks for reading, have a nice day :)

drakeee commented 5 months ago

we appreciate your proposal, can you please somewhat refactor eject functions part? it would be impossible to differentiate between seat, player or ped ids

ByAlexius commented 5 months ago

we appreciate your proposal, can you please somewhat refactor eject functions part? it would be impossible to differentiate between seat, player or ped ids

I have removed the function's that are impossible to implement and have added a ejectAll() method. Can you take a look again?

With kind regards Alexander

drakeee commented 5 months ago

we appreciate your proposal, can you please somewhat refactor eject functions part? it would be impossible to differentiate between seat, player or ped ids

I have removed the function's that are impossible to implement and have added a ejectAll() method. Can you take a look again?

With kind regards Alexander

it is possible to differentiate different types of arguments, i.e: eject(playerObject) would be doable along with eject(int seatId)

ByAlexius commented 5 months ago

we appreciate your proposal, can you please somewhat refactor eject functions part? it would be impossible to differentiate between seat, player or ped ids

I have removed the function's that are impossible to implement and have added a ejectAll() method. Can you take a look again? With kind regards Alexander

it is possible to differentiate different types of arguments, i.e: eject(playerObject) would be doable along with eject(int seatId)

Ok, I added back eject(Player player), if i understood correctly this should work. Are there any other problems or just this?

drakeee commented 5 months ago

we appreciate your proposal, can you please somewhat refactor eject functions part? it would be impossible to differentiate between seat, player or ped ids

I have removed the function's that are impossible to implement and have added a ejectAll() method. Can you take a look again? With kind regards Alexander

it is possible to differentiate different types of arguments, i.e: eject(playerObject) would be doable along with eject(int seatId)

Ok, I added back eject(Player player), if i understood correctly this should work. Are there any other problems or just this?

yeah, sorry if it was gibberish, but that was exactly what I meant, other functions looks good

ByAlexius commented 5 months ago

Quick Addition:

getPosition(); and getDimension();

devpanda0 commented 5 months ago

Quick Addition:

getPosition(); and getDimension();

i think that has every entity later

ByAlexius commented 5 months ago

Quick Addition: getPosition(); and getDimension();

i think that has every entity later

Yeah, probably but writing something that is already planned is better then not writing it down. If you understand what i mean.

hasitotabla commented 5 months ago

In my opinion, a lot of these should be a getter/setter instead of methods, because they don't require more than 1 argument. So instead of .getDimension(), a .dim or .dimension getter would be better.

LeonMrBonnie commented 5 months ago

In my opinion, a lot of these should be a getter/setter instead of methods, because they don't require more than 1 argument. So instead of .getDimension(), a .dim or .dimension getter would be better.

Every method that has a get and a set that only accepts / returns one value, should be a property.

ByAlexius commented 5 months ago

Since you are probably talking about javascript/typescript i can't say much since i have very limited experience using it, sorry.

LeonMrBonnie commented 5 months ago

The same can be applied to any language that supports getters and setters

ByAlexius commented 5 months ago

I based my original code example of java, where i generally use get and set methods (generated by lombok) for variables if it is used outside it's own class, i generally use the variable directly only if the method is in the same class. But that is more like a coding convention I and my coworkers use

LeonMrBonnie commented 5 months ago

Nothing about the API here should be discussed in regards to Java because that is a dying language that will never be available in YAMP

ByAlexius commented 5 months ago

Nothing about the API here should be discussed in regards to Java because that is a dying language that will never be available in YAMP

Yeah fair enough (I used it for the example code since my main program language for work is java and I also didn't want to write wrong c++ or javascript code).

And this code is still just a suggestion, it's still the yamp developers decisions how or if they want to implement this.

kyro95 commented 5 months ago
destroyEngine( | Sets the engine health to zero (completely damaged).
repairEngine() | Sets the engine health to 100 (or the maximum value).
disableEngine() | Disables the engine, preventing it from starting until enableEngine() is called.
enableEngine() | Enables the engine, allowing it to start again (counterpart to disableEngine()

to ->

setEngineHealth(health: number);
setEngineState(state: bool)
ByAlexius commented 5 months ago

Changes: removed: destroyEngine() repairEngine() disableEngine() enableEngine()

added: setEngineHealth(int health) setEngineState(boolean state)

Thanks @kyro95 for the suggestion :)