DragonECS/test/TestSystem.cs

42 lines
1.5 KiB
C#
Raw Normal View History

2023-02-05 19:59:45 +08:00
using System;
using System.Collections.Generic;
using System.Linq;
2023-03-12 02:48:51 +08:00
using UnityEngine;
2023-02-05 19:59:45 +08:00
namespace DCFApixels.DragonECS
{
2023-03-12 20:45:18 +08:00
public class TestSystem : IEcsInject<SharedData>, IEcsInject<EcsWorldMap>, IEcsInitSystem
2023-02-05 19:59:45 +08:00
{
private SharedData _sharedData;
2023-03-12 20:45:18 +08:00
private EcsWorld<DefaultWorld> _world;
2023-03-12 02:02:39 +08:00
public void Inject(SharedData obj) => _sharedData = obj;
2023-03-12 20:45:18 +08:00
public void Inject(EcsWorldMap obj) { _world = obj.Get<DefaultWorld>(); }
2023-03-12 02:02:39 +08:00
public void Init(EcsSession session)
2023-02-05 19:59:45 +08:00
{
2023-03-12 20:45:18 +08:00
var x1 = _world.GetFilter<Inc<TransfromCom, Velocity>>();
var x2 = _world.GetFilter<Inc<TransfromCom, View>>();
var x3 = _world.GetFilter<Inc<TransfromCom, Velocity>>();
var x4 = _world.GetFilter<Inc<TransfromCom, Velocity>>();
var x5 = _world.GetFilter<Inc<Velocity, TransfromCom>>();
int has1 = x1.GetHashCode();
int has2 = x2.GetHashCode();
int has3 = x3.GetHashCode();
int has4 = x4.GetHashCode();
int has5 = x5.GetHashCode();
var e = _world.NewEntity();
e.Write<TransfromCom>().position = Vector3.zero;
e.Write<View>().Ref = _sharedData.view1;
e.Write<EnemyTag>();
e = _world.NewEntity();
e.Write<TransfromCom>().position = Vector3.zero;
e.Write<Velocity>().value = Vector3.one;
e.Write<View>().Ref = _sharedData.view2;
e.Write<PlayerTag>();
2023-02-05 19:59:45 +08:00
}
}
}