/// --------------------------------------------- /// Behavior Designer /// Copyright (c) Opsive. All Rights Reserved. /// https://www.opsive.com /// --------------------------------------------- namespace Opsive.BehaviorDesigner.Samples { using Unity.Entities; using UnityEngine; /// /// Authoring component for the entity that is the part of the turret. /// public class TurretIdentifier : MonoBehaviour { /// /// Specifies the section of the turret. /// protected enum TurretObjectType { Base, // The base of the turret. Mid, // The mid-section of the turret. Weapon // The turret weapon. } [Tooltip("Specifies the section of the turret.")] [SerializeField] protected TurretObjectType m_ObjectType; [Tooltip("The speed of the recoil pullback.")] [SerializeField] protected float m_TurretRecoilSpeed = 12f; [Tooltip("The target z position of the recoil pullback.")] [SerializeField] protected float m_TurretRecoilPosition = -0.7f; /// /// Bakes the turret base data. /// private class Baker : Baker { /// /// Bakes the data. /// /// The parent authoring component. public override void Bake(TurretIdentifier authoring) { var entity = GetEntity(TransformUsageFlags.Dynamic); if (authoring.m_ObjectType == TurretObjectType.Base) { AddComponent(entity, new TurretBaseTag() { }); } else if (authoring.m_ObjectType == TurretObjectType.Mid) { AddComponent(entity, new TurretTag() { }); } else { // Weapon. AddComponent(entity, new TurretRecoil() { Pullback = true, PullbackSpeed = authoring.m_TurretRecoilSpeed, PullbackPosition = authoring.m_TurretRecoilPosition }); SetComponentEnabled(entity, false); } } } } }