current weapon is determined based on current slot

This commit is contained in:
in0finite 2019-07-07 00:23:32 +02:00
parent 42f8dedf2a
commit 2b0f955352
2 changed files with 9 additions and 7 deletions

View file

@ -79,8 +79,7 @@ namespace SanAndreasUnity.Behaviours {
#endregion
private Weapon m_currentWeapon;
public Weapon CurrentWeapon { get => m_currentWeapon; private set { m_currentWeapon = value; if (NetStatus.IsServer) m_ped.m_net_weaponGameObject = value != null ? value.gameObject : null; } }
public Weapon CurrentWeapon { get => this.weapons[this.currentWeaponSlot]; }
private Transform CurrentWeaponTransform { get { return CurrentWeapon != null ? CurrentWeapon.transform : null; } }
private int m_frameWhenSwitchedWeapon = 0;
@ -292,14 +291,15 @@ namespace SanAndreasUnity.Behaviours {
if (slotIndex >= 0) {
CurrentWeapon = weapons [slotIndex];
//CurrentWeapon = weapons [slotIndex];
var w = weapons [slotIndex];
// show the weapon
if (CurrentWeapon != null)
UnHideWeapon (CurrentWeapon);
if (w != null)
UnHideWeapon (w);
} else {
CurrentWeapon = null;
//CurrentWeapon = null;
}
currentWeaponSlot = slotIndex;
@ -343,7 +343,7 @@ namespace SanAndreasUnity.Behaviours {
if (slotIndex == currentWeaponSlot) {
// update current weapon variable
CurrentWeapon = weapons [slotIndex];
//CurrentWeapon = weapons [slotIndex];
// update it's transform
this.UpdateWeaponTransform ();

View file

@ -19,6 +19,8 @@
- sync aim direction
- when (un)hiding weapons, you can't disable their game object
- **vehicle is bumping on clients** - disable (or destroy) wheel colliders, and sync them - this should not be done on local player, see below