public void OnBackendSet() { if (!Backend.DstEntityManager.HasComponent <ShooterProjectileVisualTarget>(Backend.DstEntity)) { Backend.DstEntityManager.AddComponentData(Backend.DstEntity, new ShooterProjectileVisualTarget()); } m_Root = null; }
public void OnPresentationSystemUpdate() { var entityMgr = Backend.DstEntityManager; var dstEntity = Backend.DstEntity; if (targetRoot < 0 || targetRoot >= availableRoots.Length) { return; } if (canPredict) { var matrix = availableRoots[targetRoot].localToWorldMatrix; entityMgr.SetOrAddComponentData(dstEntity, new ShooterProjectilePrediction { Transform = new RigidTransform(matrix) }); } else if (entityMgr.HasComponent <ShooterProjectilePrediction>(dstEntity)) { entityMgr.RemoveComponent <ShooterProjectilePrediction>(dstEntity); } if (!TryGetComponent(out IEquipmentRoot equipRoot) && (equipRoot = GetComponentInParent <IEquipmentRoot>()) == null) { return; } var previousRoot = m_Root; m_Root = equipRoot.GetRoot(availableRoots[targetRoot]); if (m_Root != null && m_Root.UnitEquipmentBackend == null) { m_Root = null; } ThrowableProjectileComponent throwable; if (previousRoot == m_Root || (throwable = m_Root.UnitEquipmentBackend.GetComponentInChildren <ThrowableProjectileComponent>()) == null) { return; } EntityVisualDefinition visualDefinition = default; if (throwable.assetReference != null) { visualDefinition = entityMgr.World.GetExistingSystem <EntityVisualManager>() .Register(throwable.assetReference); entityMgr.SetComponentData(dstEntity, new ShooterProjectileVisualTarget { Definition = visualDefinition }); } }