Fixing networked interaction handler
This commit is contained in:
parent
f553471278
commit
990d992276
@ -48,17 +48,10 @@ namespace Item
|
|||||||
private GameObject targetObject;
|
private GameObject targetObject;
|
||||||
private float timeSinceLightDuration;
|
private float timeSinceLightDuration;
|
||||||
public bool IsLightOn => targetingLight.gameObject.activeSelf;
|
public bool IsLightOn => targetingLight.gameObject.activeSelf;
|
||||||
|
|
||||||
|
|
||||||
//private Dictionary<int,float> projectiles = new Dictionary<int, float>();
|
//private Dictionary<int,float> projectiles = new Dictionary<int, float>();
|
||||||
public override void OnStartClient()
|
|
||||||
{
|
|
||||||
base.OnStartClient();
|
|
||||||
|
|
||||||
if (!IsOwner)
|
|
||||||
{
|
|
||||||
this.enabled = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Start is called before the first frame update
|
// Start is called before the first frame update
|
||||||
private void Start()
|
private void Start()
|
||||||
{
|
{
|
||||||
|
@ -48,16 +48,16 @@ public class PlayerInteractionHandler : NetworkBehaviour
|
|||||||
public Item.Inventory Inventory => invent;
|
public Item.Inventory Inventory => invent;
|
||||||
public bool IsCarrying => heavyInvent != null;
|
public bool IsCarrying => heavyInvent != null;
|
||||||
public bool GunEnabled { get; private set; }
|
public bool GunEnabled { get; private set; }
|
||||||
|
|
||||||
|
|
||||||
public Transform CarryingPos => carryingPos;
|
public Transform CarryingPos => carryingPos;
|
||||||
|
private bool inputEnbaled = true;
|
||||||
|
|
||||||
public override void OnStartClient()
|
public override void OnStartClient()
|
||||||
{
|
{
|
||||||
base.OnStartClient();
|
base.OnStartClient();
|
||||||
if (!base.IsOwner)
|
inputEnbaled = IsOwner;
|
||||||
{
|
|
||||||
this.enabled = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start is called before the first frame update
|
// Start is called before the first frame update
|
||||||
@ -87,9 +87,9 @@ public class PlayerInteractionHandler : NetworkBehaviour
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (manager.IsPaused || isDead) return;
|
if ((manager.IsPaused || isDead)&&!inputEnbaled) return;
|
||||||
|
|
||||||
if (Input.GetButtonDown("Fire1") || fireDown.IsDown())
|
if ((Input.GetButtonDown("Fire1") || fireDown.IsDown())&&inputEnbaled)
|
||||||
{
|
{
|
||||||
if (GunEnabled)
|
if (GunEnabled)
|
||||||
{
|
{
|
||||||
@ -169,7 +169,7 @@ public class PlayerInteractionHandler : NetworkBehaviour
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Input.GetButtonDown("Fire2"))
|
if (Input.GetButtonDown("Fire2")&&inputEnbaled)
|
||||||
{
|
{
|
||||||
//print(this.GunEnabled);
|
//print(this.GunEnabled);
|
||||||
if (!GunEnabled)
|
if (!GunEnabled)
|
||||||
@ -185,7 +185,7 @@ public class PlayerInteractionHandler : NetworkBehaviour
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Input.GetButtonDown("Fire3"))
|
if (Input.GetButtonDown("Fire3")&&inputEnbaled)
|
||||||
if (!IsCarrying)
|
if (!IsCarrying)
|
||||||
{
|
{
|
||||||
GunEnabled = !GunEnabled;
|
GunEnabled = !GunEnabled;
|
||||||
@ -201,14 +201,14 @@ public class PlayerInteractionHandler : NetworkBehaviour
|
|||||||
DisableFlashlight();
|
DisableFlashlight();
|
||||||
|
|
||||||
var aimAxis = Input.GetAxis("Aim");
|
var aimAxis = Input.GetAxis("Aim");
|
||||||
|
|
||||||
if (aimAxis > 0.5f)
|
if (aimAxis > 0.5f)
|
||||||
pistol.aimMode = Item.PistolComponent.AimMode.CAMERA;
|
pistol.aimMode = Item.PistolComponent.AimMode.CAMERA;
|
||||||
else
|
else
|
||||||
pistol.aimMode = Item.PistolComponent.AimMode.MODIFIED;
|
pistol.aimMode = Item.PistolComponent.AimMode.MODIFIED;
|
||||||
}
|
}
|
||||||
|
if(!inputEnbaled)
|
||||||
shift.SetCenter(!GunEnabled);
|
shift.SetCenter(!GunEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user