2
0
Fork 0
mirror of https://github.com/GTA-ASM/SanAndreasUnity synced 2025-02-24 11:17:11 +00:00

explosion is synced

This commit is contained in:
in0finite 2020-07-04 18:52:23 +02:00
parent 24e1e7c27b
commit e47d8d0adf
5 changed files with 79 additions and 1 deletions

View file

@ -23296,6 +23296,8 @@ GameObject:
- component: {fileID: 10800000}
- component: {fileID: 7300375720519918962}
- component: {fileID: 3101637387823967307}
- component: {fileID: 2824767527029105014}
- component: {fileID: 7648126233732117826}
m_Layer: 0
m_Name: Explosion
m_TagString: Untagged
@ -23499,6 +23501,35 @@ AudioSource:
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
--- !u!114 &2824767527029105014
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 100010}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 9b91ecbcc199f4492b9a91e820070131, type: 3}
m_Name:
m_EditorClassIdentifier:
serverOnly: 0
localPlayerAuthority: 0
m_AssetId: 2894e2899fe860745afbc810459e2cc2
m_SceneId: 0
--- !u!114 &7648126233732117826
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 100010}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 0ffc1f761a29d814f9984e62b5eaf369, type: 3}
m_Name:
m_EditorClassIdentifier:
syncInterval: 0.1
--- !u!1 &100012
GameObject:
m_ObjectHideFlags: 0

View file

@ -65,6 +65,7 @@ MonoBehaviour:
- {fileID: 5841438317718401360, guid: abddce9c98c1ba5a992f109cfd8c5a5c, type: 3}
- {fileID: 4054766663391349888, guid: df1f8ef3d99c152cfb414f719d5e2bbf, type: 3}
- {fileID: 5998353205578393877, guid: 919ee6fe912ab4940abdedd633508610, type: 3}
- {fileID: 100010, guid: 2894e2899fe860745afbc810459e2cc2, type: 3}
--- !u!114 &4862460140142645991
MonoBehaviour:
m_ObjectHideFlags: 0

View file

@ -195,6 +195,9 @@ namespace SanAndreasUnity.Behaviours.Vehicles
GameObject explosionGo = Object.Instantiate(VehicleManager.Instance.explosionPrefab, this.transform.position, this.transform.rotation);
if (NetStatus.IsServer)
NetManager.Spawn(explosionGo);
// modify strength of explosion based on vehicle mass
float forceFactor = Mathf.Sqrt(this.HandlingData.Mass) / Mathf.Sqrt(1500f);
var physicsForce = explosionGo.GetComponentOrThrow<ExplosionForce>();
@ -250,7 +253,7 @@ namespace SanAndreasUnity.Behaviours.Vehicles
}
}
void AssignExplosionSound(GameObject explosionGo)
public static void AssignExplosionSound(GameObject explosionGo)
{
if (null == ExplosionSound)
ExplosionSound = AudioManager.CreateAudioClipFromSfx("GENRL", 45, 1);

View file

@ -0,0 +1,32 @@
using Mirror;
using SanAndreasUnity.Behaviours.Vehicles;
using SanAndreasUnity.Utilities;
using UnityEngine;
namespace SanAndreasUnity.Net
{
public class NetworkedExplosion : NetworkBehaviour
{
void Awake()
{
if (!NetStatus.IsServer)
{
// these scripts should not run on client
this.gameObject.DestroyComponent<ExplosionForce>();
this.gameObject.DestroyComponent<DestroyWhenParticleSystemsFinish>();
}
}
public override void OnStartClient()
{
if (NetStatus.IsServer)
return;
F.RunExceptionSafe(() => Vehicle.AssignExplosionSound(this.gameObject));
}
}
}

View file

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