1
This commit is contained in:
@@ -4,7 +4,8 @@
|
||||
"references": [
|
||||
"GUID:14fe60d984bf9f84eac55c6ea033a8f4",
|
||||
"GUID:75469ad4d38634e559750d17036d5f7c",
|
||||
"GUID:709caf8d7fb6ef24bbba0ab9962a3ad0"
|
||||
"GUID:709caf8d7fb6ef24bbba0ab9962a3ad0",
|
||||
"GUID:7efac18f239530141802fb139776f333"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
|
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Security.Permissions;
|
||||
using UnityEngine;
|
||||
using BITKit.Entities;
|
||||
using BITKit.Events;
|
||||
@@ -23,7 +24,7 @@ namespace BITKit.Vehicles
|
||||
public WheelType wheelType;
|
||||
}
|
||||
|
||||
public sealed class Vehicle : MonoBehaviour
|
||||
public sealed class Vehicle : EntityBehavior
|
||||
{
|
||||
[Header(Constant.Header.Settings)] public float maxMotorTorque = 64;
|
||||
[SerializeField] private float maxSteeringAngle = 45;
|
||||
@@ -36,6 +37,9 @@ namespace BITKit.Vehicles
|
||||
[SerializeField]
|
||||
private new Rigidbody rigidbody;
|
||||
|
||||
[SerializeField] private GameObject[] objects;
|
||||
[SerializeField] private GameObject[] destroyedObjects;
|
||||
|
||||
[SerializeField] private Transform driveAnchor;
|
||||
|
||||
[Header(Constant.Header.Gameobjects)]
|
||||
@@ -53,7 +57,29 @@ namespace BITKit.Vehicles
|
||||
private bool isBraking;
|
||||
private readonly ValidHandle highSpeedHandle = new();
|
||||
private IUnityEntity _unityEntity;
|
||||
private void Start()
|
||||
|
||||
[Inject]
|
||||
private IHealth _health;
|
||||
|
||||
public override void OnAwake()
|
||||
{
|
||||
base.OnAwake();
|
||||
_health.OnSetAlive += OnSetAlive;
|
||||
}
|
||||
|
||||
private void OnSetAlive(bool obj)
|
||||
{
|
||||
foreach (var x in objects)
|
||||
{
|
||||
x.SetActive(obj);
|
||||
}
|
||||
foreach (var x in destroyedObjects)
|
||||
{
|
||||
x.SetActive(!obj);
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnStart()
|
||||
{
|
||||
highSpeedHandle.AddListener(x =>
|
||||
{
|
||||
@@ -69,8 +95,7 @@ namespace BITKit.Vehicles
|
||||
});
|
||||
highSpeedHandle.Invoke();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
public override void OnUpdate(float deltaTime)
|
||||
{
|
||||
var torque = maxMotorTorque *(optionalVertical.Allow ? optionalVertical.Value : vertical);
|
||||
var steel =maxSteeringAngle * (optionalHorizontal.Allow ? optionalHorizontal.Value : horizontal);
|
||||
|
Reference in New Issue
Block a user