DragonECS/test/TestSystem.cs

55 lines
1.9 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-13 04:32:24 +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();
//
//Debug.Log("1 " + has1);
//Debug.Log("2 " + has2);
//Debug.Log("3 " + has3);
//Debug.Log("4 " + has4);
//Debug.Log("5 " + has5);
2023-03-12 20:45:18 +08:00
var e = _world.NewEntity();
e.Write<TransfromCom>().position = Vector3.zero;
2023-03-13 04:32:24 +08:00
e.Write<Velocity>().value = Vector3.one;
2023-03-12 20:45:18 +08:00
e.Write<View>().Ref = _sharedData.view1;
e.Write<EnemyTag>();
2023-03-13 04:32:24 +08:00
var e2 = _world.NewEntity();
e2.Write<TransfromCom>().position = Vector3.zero;
e2.Write<Velocity>().value = Vector3.zero;
e2.Write<View>().Ref = _sharedData.view2;
e2.Write<PlayerTag>();
var x1 = _world.GetFilter<Inc<TransfromCom, Velocity>>();
bool bb = _world.IsMaskCompatible(x1.Mask, e.id);
//has1 = x1.GetHashCode();
2023-02-05 19:59:45 +08:00
}
}
}