-
Notifications
You must be signed in to change notification settings - Fork 24
Vehicles #89
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
Vehicles #89
Conversation
# Conflicts: # S1API/Products/ProductInstance.cs
prefix s1 namespaces with S1
Questpatches
MaxtorCoder
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Re-order the access modifiers as well to how it looks like in the NPC class for example.
S1API/Vehicles/LandVehicle.cs
Outdated
| private void _setConnection() | ||
| { | ||
| var nm = InstanceFinder.NetworkManager; | ||
| if (nm.IsClientOnly) | ||
| { | ||
| var tempConn = InstanceFinder.ClientManager.Connection; | ||
| if (tempConn != null && tempConn.IsValid) | ||
| _conn = tempConn; | ||
| } | ||
| else if (nm.IsServerOnly || (nm.IsServer && !nm.IsClient)) | ||
| { | ||
| var owner = S1LandVehicle.Owner; | ||
| if (owner != null && owner.IsValid) | ||
| _conn = owner; | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| private void _setConnection() | |
| { | |
| var nm = InstanceFinder.NetworkManager; | |
| if (nm.IsClientOnly) | |
| { | |
| var tempConn = InstanceFinder.ClientManager.Connection; | |
| if (tempConn != null && tempConn.IsValid) | |
| _conn = tempConn; | |
| } | |
| else if (nm.IsServerOnly || (nm.IsServer && !nm.IsClient)) | |
| { | |
| var owner = S1LandVehicle.Owner; | |
| if (owner != null && owner.IsValid) | |
| _conn = owner; | |
| } | |
| } | |
| private void SetConnection() | |
| { | |
| var nm = InstanceFinder.NetworkManager; | |
| if (nm.IsClientOnly) | |
| { | |
| var tempConn = InstanceFinder.ClientManager.Connection; | |
| if (tempConn != null && tempConn.IsValid) | |
| _conn = tempConn; | |
| } | |
| else if (nm.IsServerOnly || (nm.IsServer && !nm.IsClient)) | |
| { | |
| var owner = S1LandVehicle.Owner; | |
| if (owner != null && owner.IsValid) | |
| _conn = owner; | |
| } | |
| } |
S1API/Vehicles/LandVehicle.cs
Outdated
| private void _setIsPlayerOwned(bool isPlayerOwned) | ||
| { | ||
| S1LandVehicle.SetIsPlayerOwned(_conn, isPlayerOwned); | ||
| // make sure to add/remove the vehicle from the player owned vehicles list | ||
| if (isPlayerOwned) | ||
| NetworkSingleton<S1Vehicles.VehicleManager>.Instance.PlayerOwnedVehicles.Add(S1LandVehicle); | ||
| else | ||
| NetworkSingleton<S1Vehicles.VehicleManager>.Instance.PlayerOwnedVehicles.Remove(S1LandVehicle); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| private void _setIsPlayerOwned(bool isPlayerOwned) | |
| { | |
| S1LandVehicle.SetIsPlayerOwned(_conn, isPlayerOwned); | |
| // make sure to add/remove the vehicle from the player owned vehicles list | |
| if (isPlayerOwned) | |
| NetworkSingleton<S1Vehicles.VehicleManager>.Instance.PlayerOwnedVehicles.Add(S1LandVehicle); | |
| else | |
| NetworkSingleton<S1Vehicles.VehicleManager>.Instance.PlayerOwnedVehicles.Remove(S1LandVehicle); | |
| } | |
| private void SetIsPlayerOwned(bool isPlayerOwned) | |
| { | |
| S1LandVehicle.SetIsPlayerOwned(_conn, isPlayerOwned); | |
| // make sure to add/remove the vehicle from the player owned vehicles list | |
| if (isPlayerOwned) | |
| NetworkSingleton<S1Vehicles.VehicleManager>.Instance.PlayerOwnedVehicles.Add(S1LandVehicle); | |
| else | |
| NetworkSingleton<S1Vehicles.VehicleManager>.Instance.PlayerOwnedVehicles.Remove(S1LandVehicle); | |
| } |
S1API/Vehicles/LandVehicle.cs
Outdated
| private void _setColor(VehicleColor color) | ||
| { | ||
| var setOwnedColorMethod = | ||
| typeof(S1Vehicles.LandVehicle).GetMethod("SetOwnedColor", | ||
| BindingFlags.Instance | BindingFlags.NonPublic); | ||
| if (setOwnedColorMethod == null) | ||
| { | ||
| Logger.Error("SetOwnedColor method not found!"); | ||
| return; | ||
| } | ||
|
|
||
| setOwnedColorMethod.Invoke(S1LandVehicle, [_conn, (S1Vehicles.Modification.EVehicleColor)color]); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| private void _setColor(VehicleColor color) | |
| { | |
| var setOwnedColorMethod = | |
| typeof(S1Vehicles.LandVehicle).GetMethod("SetOwnedColor", | |
| BindingFlags.Instance | BindingFlags.NonPublic); | |
| if (setOwnedColorMethod == null) | |
| { | |
| Logger.Error("SetOwnedColor method not found!"); | |
| return; | |
| } | |
| setOwnedColorMethod.Invoke(S1LandVehicle, [_conn, (S1Vehicles.Modification.EVehicleColor)color]); | |
| } | |
| private void SetColor(VehicleColor color) | |
| { | |
| var setOwnedColorMethod = | |
| typeof(S1Vehicles.LandVehicle).GetMethod("SetOwnedColor", | |
| BindingFlags.Instance | BindingFlags.NonPublic); | |
| if (setOwnedColorMethod == null) | |
| { | |
| Logger.Error("SetOwnedColor method not found!"); | |
| return; | |
| } | |
| setOwnedColorMethod.Invoke(S1LandVehicle, [_conn, (S1Vehicles.Modification.EVehicleColor)color]); | |
| } |
S1API/Vehicles/LandVehicle.cs
Outdated
| /// <summary> | ||
| /// Logger for the LandVehicle class. | ||
| /// </summary> | ||
| private static readonly Log Logger = new Log("S1API.LandVehicle"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| private static readonly Log Logger = new Log("S1API.LandVehicle"); | |
| private static readonly Log _logger = new Log("S1API.LandVehicle"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't use the NetworkSingleton generic either. You can just call S1Vehicles.VehicleManager.Instance directly.
Should've been in the last one and I forgot, my bad.
|
Thanks for the PR, I will fix any further issues with build :) |
Add a simple way to spawn and customize vehicles with S1API.
Example: