Exemplo n.º 1
0
 private void OnDestroy()
 {
     if (!destroyObject && worldProvider.world.IsAlive())
     {
         entity.Destroy();
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// simple clear filter
 /// </summary>
 /// <param name="filter"></param>
 public static void ClearSimple(this EcsFilter filter)
 {
     foreach (int i in filter)
     {
         ref EcsEntity entity = ref filter.GetEntity(i);
         entity.Destroy();
     }
Exemplo n.º 3
0
 protected virtual void OnDestroy()
 {
     if (Service <EcsWorld> .Get().IsAlive())
     {
         entity.Destroy();
     }
 }
Exemplo n.º 4
0
        protected virtual void DestroyEntity()
        {
            if (worldIsAlive && entityIsAlive)
            {
                entityValue.Destroy();
            }

            entityValue = EcsEntity.Null;
        }
Exemplo n.º 5
0
        protected virtual void DestroyEntity()
        {
            if (startup.world != null && entityValue.IsAlive())
            {
                entityValue.Destroy();
            }

            entityValue = EcsEntity.Null;
        }
        public static void RLDestoryGO(this EcsEntity entity, float time = 0)
        {
            var c = entity.Get <GameObjectComponent>();

            if (c != null)
            {
                UnityEngine.Object.Destroy(c.Transform.gameObject, time);
            }
            entity.Destroy();
        }
Exemplo n.º 7
0
        private void OnTriggerEnter2D(Collider2D other)
        {
            if (initialized)
            {
                var     newEntity = world.NewEntity();
                ref var resourceAmountChangedEventComponent = ref newEntity.Get <ResourceAmountChangedEventComponent>();
                resourceAmountChangedEventComponent.uid    = resourceItemComponent.uid;
                resourceAmountChangedEventComponent.amount = resourceItemComponent.amount;

                entity.Destroy();

                Destroy(gameObject);
            }
Exemplo n.º 8
0
 public void removeDesignation(EcsEntity designation)
 {
     if (designation.Has <DesignationVisualComponent>())
     {
         Destroy(designation.Get <DesignationVisualComponent>().spriteRenderer.gameObject);
         designation.Del <DesignationVisualComponent>();
     }
     else
     {
         Debug.LogWarning("deleting designation without DesignationVisualComponent");
     }
     designation.Destroy();
 }
Exemplo n.º 9
0
        /// <summary>
        /// Custom user's code should be here. Invoke also base.Dispose().
        /// For unloading scene use World.UnloadScene(s).
        /// </summary>
        public virtual void Dispose()
        {
            if (IsDisposed)
            {
                log.Warn(
                    $"SceneController.Destroy. Controller with scene '{SceneName.FullName}' is already destroyed!");
                return;
            }

            if (HasEntity)
            {
                _entity.Destroy();
            }

            IsDisposed = true;
        }
Exemplo n.º 10
0
 public void Run()
 {
     //destroy wrap conent child system by id
     foreach (int d in _wrap_destroy_filter)
     {
         ref BaseWrapDestroyComponent del_cmp = ref _wrap_destroy_filter.Get1(d);
         uint del_id = del_cmp.id;
         foreach (int i in _wrap_create_filter)
         {
             ref BaseWrapCreateComponent cmp = ref _wrap_create_filter.Get1(i);
             if (cmp.base_cild_system.id == del_id)
             {
                 cmp.base_cild_system.OnDestroy();
                 ref EcsEntity entity = ref _wrap_create_filter.GetEntity(i);
                 entity.Destroy();
             }
Exemplo n.º 11
0
    private void OnTriggerEnter(Collider other)
    {
        int triggerGoLayer = 1 << other.gameObject.layer;

        if (triggerGoLayer == _triggerLayer.value)
        {
            var triggerColor = other.gameObject.GetComponent <Character>().Material.color;
            if (triggerColor == _material.color)
            {
                var entity = GameManager.Instance.World.NewEntity();
                entity.Replace(new IncomeEvent()
                {
                    Value = _entity.Get <GemComponent>().Value
                });
                _entity.Destroy();
                Destroy(gameObject);
            }
        }
    }
Exemplo n.º 12
0
        private void OnDestroy()
        {
            if (IsDisposed)
            {
                log.Warn($"SceneController.Destroy. Controller with scene '{SceneName.FullName}' is already destroyed!");
                return;
            }

            _Hide();

            Dispose();

            if (HasEntity)
            {
                _entity.Destroy();
            }

            // sends destroy event
            World.NewEntity().Get <SceneDestroyedEvent>().SceneName = SceneName;

            IsDisposed = true;
        }
Exemplo n.º 13
0
        public void Run()
        {
            foreach (int i in _createEvents)
            {
                Transform newObject = _createEvents.Get1[i].Transform;
                EcsEntity entity    = _createEvents.Entities[i];

                Vector2Int position = newObject.position.ToVector2Int();
                _worldService.WorldField[position.x][position.y].Add(entity);
                entity.Set <PositionComponent>().Position     = position;
                entity.Set <WorldObjectComponent>().Transform = newObject;
            }

            foreach (int i in _movedObjects)
            {
                PositionComponent positionComponent = _movedObjects.Get1[i];
                Vector2Int        oldPosition       = positionComponent.Position;
                Vector2Int        newPosition       = _movedObjects.Get2[i].NewPosition;
                EcsEntity         entity            = _movedObjects.Entities[i];

                _worldService.WorldField[oldPosition.x][oldPosition.y].Remove(entity);
                _worldService.WorldField[newPosition.x][newPosition.y].Add(entity);

                positionComponent.Position = newPosition;
            }

            foreach (int i in _destroyedObjects)
            {
                Transform  objectToDestroy = _destroyedObjects.Get1[i].Transform;
                Vector2Int position        = _destroyedObjects.Get2[i].Position;
                EcsEntity  entity          = _destroyedObjects.Entities[i];

                _worldService.WorldField[position.x][position.y].Remove(entity);
                objectToDestroy.gameObject.SetActive(false);
                entity.Destroy();
            }
        }
Exemplo n.º 14
0
 protected virtual void OnDestroy()
 {
     entity.Destroy();
 }