mirror of
https://github.com/hanzoai/ProjectTinySamples.git
synced 2026-09-24 00:01:34 +00:00
32 lines
1.0 KiB
C#
32 lines
1.0 KiB
C#
using System.Collections.Generic;
|
|
using Unity.Spaceship;
|
|
using Unity.Entities;
|
|
using UnityEngine;
|
|
|
|
public class PlayerComponent : MonoBehaviour, IConvertGameObjectToEntity, IDeclareReferencedPrefabs
|
|
{
|
|
public float RotationSpeed = 2f;
|
|
public float MoveSpeed = 4f;
|
|
public float FireRate = 3f;
|
|
public float FireSpeed = 5f;
|
|
public GameObject MissilePrefab = null;
|
|
|
|
public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem)
|
|
{
|
|
dstManager.AddComponentData(entity, new Player
|
|
{
|
|
RotationSpeed = RotationSpeed,
|
|
MoveSpeed = MoveSpeed,
|
|
FireRate = FireRate,
|
|
FireSpeed = FireSpeed,
|
|
MissilePrefab = MissilePrefab != null ? conversionSystem.GetPrimaryEntity(MissilePrefab) : Entity.Null
|
|
});
|
|
}
|
|
|
|
public void DeclareReferencedPrefabs(List<GameObject> referencedPrefabs)
|
|
{
|
|
if (MissilePrefab != null)
|
|
referencedPrefabs.Add(MissilePrefab);
|
|
}
|
|
}
|