drive-by WIP

This commit is contained in:
in0finite 2020-02-12 18:26:25 +01:00
parent 33b8d217aa
commit e50a1e70e2
4 changed files with 97 additions and 8 deletions

View file

@ -29,6 +29,7 @@ GameObject:
- component: {fileID: 114803762585694722}
- component: {fileID: 114244562150032294}
- component: {fileID: 114293662543306134}
- component: {fileID: 7181738364298022858}
m_Layer: 11
m_Name: States
m_TagString: Untagged
@ -297,6 +298,18 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 4e111211033b048ca9ca00766168ed4b, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!114 &7181738364298022858
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1154474390377672}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 603044a9ff214434db928f6a43fd0b8a, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &1273918895060814
GameObject:
m_ObjectHideFlags: 0
@ -368,12 +381,9 @@ MonoBehaviour:
m_EditorClassIdentifier:
syncInterval: 0.1
shouldPlayAnims: 1
TurnSpeed: 10
jumpSpeed: 8
m_cameraDistance: 3
m_cameraDistanceVehicle: 6
m_cameraClampValue: {x: 60, y: 60}
m_maxHealth: 100
m_inputSendInterval: 0.033333335
m_enterVehicleRadius: 2
--- !u!114 &114173420020992462
MonoBehaviour:
@ -387,7 +397,6 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 57e796a954503384dbd1282729710af5, type: 3}
m_Name:
m_EditorClassIdentifier:
CursorSensitivity: {x: 7, y: 7}
clampInDegrees: {x: 60, y: 60}
smoothing: {x: 10, y: 10}
m_doSmooth: 0

View file

@ -0,0 +1,61 @@
using UnityEngine;
using SanAndreasUnity.Behaviours.Vehicles;
namespace SanAndreasUnity.Behaviours.Peds.States
{
public class DriveByState : VehicleSittingState, IAimState
{
public override void EnterVehicle(Vehicle vehicle, Vehicle.Seat seat)
{
this.CurrentVehicle = vehicle;
this.CurrentVehicleSeatAlignment = seat.Alignment;
m_ped.SwitchState<DriveByState> ();
}
protected override void EnterVehicleInternal()
{
if (m_isServer)
m_vehicleParentOffset = m_model.VehicleParentOffset;
else if (m_isClientOnly)
m_model.VehicleParentOffset = m_vehicleParentOffset;
BaseVehicleState.PreparePedForVehicle(m_ped, this.CurrentVehicle, this.CurrentVehicleSeat);
PlayAnims();
}
protected override void UpdateAnims()
{
PlayAnims();
}
void PlayAnims()
{
if (this.CurrentVehicleSeat != null)
m_model.PlayAnim(new Importing.Animation.AnimId("ped", "DrivebyL_" + (this.CurrentVehicleSeat.IsLeftHand ? "L" : "R")));
}
void IAimState.StartFiring()
{
// switch to firing state
}
// camera
public override void OnAimButtonPressed()
{
// switch to sitting state
if (m_isServer)
m_ped.GetStateOrLogError<VehicleSittingState>().EnterVehicle(this.CurrentVehicle, this.CurrentVehicleSeatAlignment);
else
base.OnAimButtonPressed();
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 603044a9ff214434db928f6a43fd0b8a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -9,7 +9,7 @@ namespace SanAndreasUnity.Behaviours.Peds.States
public class VehicleSittingState : BaseVehicleState
{
Vector3 m_vehicleParentOffset = Vector3.zero;
protected Vector3 m_vehicleParentOffset = Vector3.zero;
//Vector3 m_rootFramePos = Vector3.zero;
@ -51,7 +51,7 @@ namespace SanAndreasUnity.Behaviours.Peds.States
this.EnterVehicle(vehicle, vehicle.GetSeat(seatAlignment));
}
public void EnterVehicle(Vehicle vehicle, Vehicle.Seat seat)
public virtual void EnterVehicle(Vehicle vehicle, Vehicle.Seat seat)
{
this.CurrentVehicle = vehicle;
this.CurrentVehicleSeatAlignment = seat.Alignment;
@ -59,7 +59,7 @@ namespace SanAndreasUnity.Behaviours.Peds.States
m_ped.SwitchState<VehicleSittingState> ();
}
void EnterVehicleInternal()
protected virtual void EnterVehicleInternal()
{
Vehicle vehicle = this.CurrentVehicle;
Vehicle.Seat seat = this.CurrentVehicleSeat;
@ -118,6 +118,14 @@ namespace SanAndreasUnity.Behaviours.Peds.States
}
public override void OnAimButtonPressed()
{
if (m_isServer)
m_ped.GetStateOrLogError<DriveByState>().EnterVehicle(this.CurrentVehicle, this.CurrentVehicleSeatAlignment);
else
base.OnAimButtonPressed();
}
public override void UpdateState() {
base.UpdateState();