Skip to content

Commit

Permalink
Synchronize rubber sniper
Browse files Browse the repository at this point in the history
Essentially just disable inputManager-requiring stuff
  • Loading branch information
toberge committed May 29, 2024
1 parent 0f5fec9 commit 0925ad7
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 5 deletions.
8 changes: 6 additions & 2 deletions Assets/Scenes/Menu.unity
Original file line number Diff line number Diff line change
Expand Up @@ -416,14 +416,18 @@ PrefabInstance:
serializedVersion: 3
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 3717336014748129540, guid: 0e2ad36662a02c3488301a5286b27635, type: 3}
propertyPath: startingBody
value:
objectReference: {fileID: 11400000, guid: 0abfdcb5f304f2647b378f82907d538c, type: 2}
- target: {fileID: 3717336014748129540, guid: 0e2ad36662a02c3488301a5286b27635, type: 3}
propertyPath: startingBarrel
value:
objectReference: {fileID: 11400000, guid: 02969ed0b9ffe874eaeaf0b581b01450, type: 2}
objectReference: {fileID: 11400000, guid: 9c1da148c8d07ab428c6bc9a70aecae8, type: 2}
- target: {fileID: 3717336014748129540, guid: 0e2ad36662a02c3488301a5286b27635, type: 3}
propertyPath: startingExtension
value:
objectReference: {fileID: 11400000, guid: 87e98f42380f122a486cd5034ef1d278, type: 2}
objectReference: {fileID: 11400000, guid: 2c332edf0b10a07489ea78f82b8f7045, type: 2}
- target: {fileID: 8579357797008554893, guid: 0e2ad36662a02c3488301a5286b27635, type: 3}
propertyPath: m_Name
value: StaticInfo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ private void Fire(GunStats stats)

public void UpdateAimTarget(GunStats stats)
{
if (!gunController.Player.inputManager)
return;
Vector3 cameraCenter = gunController.Player.inputManager.transform.position;
Vector3 cameraDirection = gunController.Player.inputManager.transform.rotation * jigglePhysics.Direction;
Vector3 startPoint = cameraCenter + cameraDirection * gunController.Player.TargetStartOffset;
Expand All @@ -64,7 +66,7 @@ public void UpdateAimTarget(GunStats stats)

private void FixedUpdate()
{
if (!gunController || !gunController.Player)
if (!gunController || !gunController.Player || !gunController.Player.inputManager)
return;
var correctedDirection = gunController.Player.inputManager.transform.rotation * jigglePhysics.NormalizedPointer;
gunController.Player.HUDController.MoveCrosshair(correctedDirection.x, correctedDirection.y);
Expand Down
4 changes: 2 additions & 2 deletions Assets/Scripts/Augment/FloppyExtensionJiggleMesh.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ private void Start()

public void AnimatePushback()
{
previousDiff += Vector3.up*3;
previousDiff += Vector3.up * 3;
}

private void UpdatePointer(Vector3 target)
Expand All @@ -40,7 +40,7 @@ private void Update()
var distance = target;
jiggleMaterial.SetVector("_Distance", target);
var sensitivity = movementSensitivity;
if (player)
if (player && player.inputManager)
sensitivity = player.inputManager.moveInput.magnitude < 0.2f ? movementSensitivity : movementSensitivityWalking;
previousTarget = target + Quaternion.Inverse(transform.rotation) * -(oldPosition - transform.position) * sensitivity;
previousDiff -= distance * jiggleFalloff;
Expand Down
4 changes: 4 additions & 0 deletions Assets/Scripts/Augment/GunController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,10 @@ private void CmdFire(Quaternion rotation)
private void RpcFire(Quaternion rotation)
{
onFireStart?.Invoke(stats);
// TODO does this work? if so, remove output
//if (authority)
//projectile.projectileOutput = outputs[0];
//projectile.projectileOutput = outputs[0];
projectile.projectileOutput = outputs[0];
projectile.projectileRotation = rotation;
ActuallyFire();
Expand Down
4 changes: 4 additions & 0 deletions Assets/Scripts/Augment/ProjectileController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ public abstract class ProjectileController : NetworkBehaviour
{
[HideInInspector]
public Transform projectileOutput;

public Vector3 actualPosition;
public Vector3 actualDirection;

public Quaternion projectileRotation = Quaternion.identity;

// Used for muzzle-flashes and other effects, is not where the projectile path actually starts
Expand Down
20 changes: 20 additions & 0 deletions Assets/Scripts/Control&Input/Peer2PeerTransport.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
Expand Down Expand Up @@ -172,6 +173,25 @@ public override void OnClientConnect()
PlayerInstanceByID = new(playerInstances);
playerIndex = 0;
}
// TODO OnClientDisconnect and the like must be implemented!!!
// - OnServerDisconnect seems to be the one that runs on the server when a client disconnects

//public override void OnServerDisconnect(NetworkConnectionToClient conn)
//{
// base.OnServerDisconnect(conn);
// throw new NotImplementedException();
//}
//public override void OnClientDisconnect()
//{
// base.OnClientDisconnect();
// throw new NotImplementedException();
//}
//// TODO should this be different?
//public override void OnStopClient()
//{
// base.OnStopClient();
// throw new NotImplementedException();
//}

public void JoinLobby(string address = "127.0.0.1")
{
Expand Down

0 comments on commit 0925ad7

Please sign in to comment.