public void CreateAirplane(AirplaneInfo info) { Entity entity = _entityManager.CreateEntity(_airplaneEntityArchetype); _entityManager.SetComponentData(entity, new MoveSpeed() { Speed = info.MoveSpeed }); _entityManager.SetComponentData(entity, new Translation() { Value = info.BornPos }); var radian = math.PI / 180f * info.RotationY; _entityManager.SetComponentData(entity, new RotationEulerXYZ() { Value = new float3(0, radian, 0) }); _entityManager.SetComponentData(entity, new NonUniformScale() { Value = info.Scale }); _entityManager.SetSharedComponentData(entity, new RenderMesh { mesh = info.Mesh, material = info.Material, castShadows = info.ShadowCastingMode, receiveShadows = info.ReceiveShadows, layer = info.Layer, }); _entityManager.SetComponentData(entity, new Airplane() { //MeshBullet = info.MeshBullet, //MaterialBullet = info.MaterialBullet, BulletScale = info.BulletScale, BulletSpeed = info.BulletSpeed, BulletEuler = info.BulletEuler, BulletGap = info.BulletGap, BulletBlastDuration = info.BulletBlastDuration, ShootIntervalTime = info.ShootIntervalTime, ShootOffset = info.ShootOffset, PlayerSize = info.Size, BoxSize = info.BoxSize, Hp = info.MaxHp, MaxHp = info.MaxHp, Damage = info.Damage }); if (info.Layer == LayerMask.NameToLayer("Hero")) { _entityManager.AddComponent <Player>(entity); } else { _entityManager.AddComponent <Enemy>(entity); _entityManager.AddComponent <AABBCollider>(entity); _entityManager.SetComponentData(entity, new Enemy { BornTime = Time.time, LifeTime = info.LifeTime, SpeedScale = 1 }); } }
private void SetAttackableComponent(Entity entity, AttackableComponent c) => EntityManager.SetComponentData <AttackableComponent>(entity, c);