예제 #1
0
        protected virtual void DestroyEntity()
        {
            if (startup.world != null && entityValue.IsAlive())
            {
                entityValue.Destroy();
            }

            entityValue = EcsEntity.Null;
        }
예제 #2
0
        public static void AddRecipient(EcsEntity e)
        {
            if (!e.IsAlive())
            {
                return;
            }

            var player = e.Get <Player>();

            recipients.Add(player.Connection.ClientConnection);
        }
예제 #3
0
        public void Add(EcsEntity entity)
        {
            if (!entity.IsAlive())
            {
                throw new Exception("Can't add entity to EntityList as it's not active.");
            }

            ResizeIfNeeded();

            entities[count] = entity;
            count++;
        }
예제 #4
0
        public void Erode()
        {
            if (map.IsNull() || !map.IsAlive())
            {
                return;
            }

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

            if (!ce.IsValidTarget(CombatEntity))
            {
                return(false);
            }
            return(true);
        }
예제 #6
0
        void UpdateEntityName(EcsEntity entity, bool requestComponents)
        {
            var entityId   = entity.GetInternalId();
            var entityName = entityId.ToString("D8");

            if (entity.IsAlive() && requestComponents)
            {
                var count = entity.GetComponentTypes(ref _componentTypesCache);
                for (var i = 0; i < count; i++)
                {
                    entityName = $"{entityName}:{EditorHelpers.GetCleanGenericTypeName (_componentTypesCache[i])}";
                    _componentTypesCache[i] = null;
                }
            }
            EntityGameObjects[entityId].name = entityName;
        }
예제 #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();
 }