public CollisionEvent(Entity source, CollidableNode origin, CollidableNode target, Vector3 hitPoint, Vector3 hitNormal, int hit = -1)
 {
     Source    = source;
     Origin    = origin;
     Target    = target;
     HitPoint  = hitPoint;
     HitNormal = hitNormal;
     Hit       = hit;
 }
 public PerformedCollisionEvent(CollidableNode origin, CollidableNode target, Vector3 hitPoint, Vector3 hitNormal, int
                                hit = -1)
 {
     Origin    = origin;
     Target    = target;
     HitPoint  = hitPoint;
     HitNormal = hitNormal;
     Hit       = hit;
 }
        public static bool IsValidCollision(Entity entity, bool limitEnemy, Entity hitEntity, Collider collider, out CollidableNode
                                            sourceNode, out CollidableNode targetNode)
        {
            sourceNode = targetNode = null;
            if (hitEntity == entity)
            {
                return(false);
            }
            var tr = collider.transform;

            if (tr.CompareTag(StringConst.TagInvalidCollider) ||
                tr.CompareTag(StringConst.TagSensor))
            {
                return(false);
            }
            if (!hitEntity.Tags.Contain(EntityTags.CanUnityCollide))
            {
                return(false);
            }
            if (AreEntitiesConnected(hitEntity, entity))
            {
                return(false);
            }
#if DEBUG
            DebugLog.Add(entity.DebugId + " hit actor " + tr.name);
#endif
            sourceNode = entity.FindNode <CollidableNode>();
            targetNode = hitEntity.FindNode <CollidableNode>();
            if (sourceNode == null || targetNode == null || sourceNode == targetNode)
            {
                return(false);
            }
            if (limitEnemy)
            {
                if (World.Get <FactionSystem>().AreEnemies(sourceNode.Entity, targetNode.Entity))
                {
                    if (entity.Tags.IsConfused)
                    {
                        return(false);
                    }
                }
                else
                {
                    if (!entity.Tags.IsConfused)
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }
Exemple #4
0
        public static void Setup()
        {
            IsSetup = true;
            if (Instance == null)
            {
                return;
            }
            NodeFilter <VisibleNode> .Setup(VisibleNode.GetTypes());

            NodeFilter <CharacterNode> .Setup(CharacterNode.GetTypes());

            NodeFilter <CollidableNode> .Setup(CollidableNode.GetTypes());

            Get <AnimatorSystem>();
            Get <CommandSystem>();
            Get <CollisionCheckSystem>();
            Get <DespawnEntitySystem>();
            Get <DistanceSystem>();
            Get <FactionSystem>();
            Get <ItemSceneSystem>();
            Get <ModifierSystem>();
            Get <MoverSystem>();
            Get <PhysicsMoverSystem>();
            Get <CharacterRectSystem>();
            Get <SensorSystem>();
            Get <EntityUIPoolSystem>();

            var assemblies = AppDomain.CurrentDomain.GetAssemblies();

            for (int a = 0; a < assemblies.Length; a++)
            {
                var types = assemblies[a].GetTypes();
                for (int t = 0; t < types.Length; t++)
                {
                    var type = types[t];
                    if (type.IsDefined(typeof(AutoRegisterAttribute), false))
                    {
                        CreateSystem(type);
                    }
                }
            }
        }