예제 #1
0
 private void OnTriggerEnter(Collider other)
 {
     if (Entity.IsNull())
     {
         Debug.LogError("Entity is null on coin");
         return;
     }
     Entity.Get <CollisionEvent>().Type = CollisionType.Obstacle;
 }
예제 #2
0
        public void Erode()
        {
            if (map.IsNull() || !map.IsAlive())
            {
                return;
            }

            FillParameters(map, true);
            map.Get <ErodeEvent>() = new ErodeEvent()
            {
                PrintTimers = PrintTimers
            };
        }
예제 #3
0
        private bool ValidateTarget()
        {
            if (target.IsNull() || !target.IsAlive())
            {
                return(false);
            }
            var ce = target.Get <CombatEntity>();

            if (!ce.IsValidTarget(CombatEntity))
            {
                return(false);
            }
            return(true);
        }
예제 #4
0
        protected virtual EcsEntity CreateEntity()
        {
                        #if DEBUG
            startup = GetStartup();
            if (!startup)
            {
                throw new Exception($"There is no {nameof(BaseStartup)} on parents!");
            }
            else if (!startup.worldIsAlive)
            {
                throw new Exception($"{startup.GetType().Name} is not init!");
            }
            else if (!entityValue.IsNull())
            {
                throw new Exception("Entity already created!");
            }
                        #endif

            var newEntity = startup.world.NewEntityWith(out UnityObject unityObject, out NewHybridEntityEvent _);
            unityObject.gameObject = gameObject;
            return(newEntity);
        }
예제 #5
0
        protected virtual EcsEntity CreateEntity()
        {
                        #if DEBUG
            if (!startup)
            {
                throw new Exception("Startup is not found!");
            }
            else if (!startup.worldIsAlive)
            {
                throw new Exception("Startup is not init!");
            }
            else if (!entityValue.IsNull())
            {
                throw new Exception("Entity already created!");
            }
                        #endif

            var newEntity = startup.world.NewEntityWith(out UnityObject unityObject, out NewHybridEntity _);
            unityObject.gameObject = gameObject;

            return(newEntity);
        }
예제 #6
0
    protected virtual void Start()
    {
        var filter = World.GetFilter(typeof(EcsFilter <ObjectComponent>));

        foreach (var i in filter)
        {
            if (filter.GetEntity(i).Get <ObjectComponent>().go == gameObject)
            {
                entity = filter.GetEntity(i);
            }
        }

        if (entity.IsNull())
        {
            entity = World.NewEntity();
            entity.Get <ObjectComponent>().go = gameObject;
            entity.Get <T>();
        }
        else
        {
            entity.Get <T>();
        }
    }
예제 #7
0
 public bool IsValidTarget(CombatEntity source)
 {
     if (this == source)
     {
         return(false);
     }
     if (Entity.IsNull() || !Entity.IsAlive())
     {
         return(false);
     }
     if (!Character.IsActive || Character.State == CharacterState.Dead)
     {
         return(false);
     }
     if (Character.Map == null)
     {
         return(false);
     }
     if (source.Character.Map != Character.Map)
     {
         return(false);
     }
     if (Character.SpawnImmunity > 0f)
     {
         return(false);
     }
     if (source.Character.ClassId == Character.ClassId)
     {
         return(false);
     }
     if (Character.ClassId == 1000)
     {
         return(false);                //hack
     }
     return(true);
 }
 public static bool IsNotNullAndAlive(this EcsEntity entity)
 {
     return !entity.IsNull() && entity.IsAlive();
 }