protected override void OnUpdate()
        {
            // To-do: Refactor
            // var ecbParallel = endSimulationECBSystem.CreateCommandBuffer().AsParallelWriter();

            // UI Text Update

            Entities
            .WithoutBurst()
            .ForEach(
                (in DynamicBuffer <PlayerResourceData> resourcesData) =>
            {
                for (int i = 0; i < resourcesData.Length; i++)
                {
                    // If it's resource None type
                    if (resourcesData[i].resource.type == ResourceTypes.None)
                    {
                        continue;
                    }

                    // If there is no UI text field for our resource type
                    if (!resources.ContainsKey(resourcesData[i].resource.type))
                    {
                        continue;
                    }

                    SetResourceText(resourcesData[i].resource.type, resourcesData[i].resource.value);
                }
            }
Beispiel #2
0
        protected override void OnUpdate()
        {
            EntityCommandBuffer ecb = barrier.CreateCommandBuffer();

            EntityArchetype archetypeCreateHighlight = HighlightArchetype.GetCommandCreate();
            EntityArchetype archetypeRemoveHighlight = HighlightArchetype.GetCommandRemove();

            Entities
            .WithoutBurst()
            .ForEach((
                         Entity entity,
                         in CommandSelectCell commandSelectCell,
                         in HexCoordinates hexCoordinates
                         ) => {
                Entity selectedCell = HexCellService.FindBy(hexCoordinates);

                if (commandSelectCell.select)
                {
                    CommandHighlight.Create(ecb, hexCoordinates, archetypeCreateHighlight);
                    ecb.AddComponent <Selected>(selectedCell, new Selected {
                    });
                }
                else
                {
                    CommandHighlight.Remove(ecb, hexCoordinates, archetypeRemoveHighlight);
                    ecb.RemoveComponent <Selected>(selectedCell);
                }

                ecb.DestroyEntity(entity);
            }).Run();
        protected override void OnUpdate()
        {
            HighlightCellPrefab  highlightPrefab  = GetSingleton <HighlightCellPrefab>();
            EntityCommandBuffer  ecb              = barrier.CreateCommandBuffer();
            NativeArray <Entity> highlightedCells = HighlightCell.List();

            Entities
            .WithoutBurst()
            .ForEach((
                         Entity entity,
                         in HexCoordinates coordinates,
                         in CommandRemoveHighlight commandRemoveHighlight
                         ) => {
                foreach (var highlightedCell in highlightedCells)
                {
                    HexCoordinates highlightedCoordinates = EntityManager.GetComponentData <HexCoordinates>(highlightedCell);

                    if (coordinates == highlightedCoordinates)
                    {
                        ecb.DestroyEntity(highlightedCell);
                    }
                }

                ecb.DestroyEntity(entity);
            }).Run();
        protected override void OnUpdate()
        {
            HighlightCellPrefab highlightPrefab = GetSingleton <HighlightCellPrefab>();
            EntityCommandBuffer ecb             = barrier.CreateCommandBuffer();

            Entities
            .WithoutBurst()
            .ForEach((
                         Entity entity,
                         in CommandCreateHighlight commandCreateHighlight,
                         in HexCoordinates coordinates
                         ) => {
                HighlightCell.Create(ecb, highlightPrefab, coordinates);

                ecb.DestroyEntity(entity);
            }).Run();
Beispiel #5
0
        protected override void OnUpdate()
        {
            EntityCommandBuffer ecb           = barrier.CreateCommandBuffer();
            SettlerPrefab       settlerPrefab = GetSingleton <SettlerPrefab>();

            Entities
            .WithoutBurst()
            .ForEach((
                         Entity entity,
                         int entityInQueryIndex,
                         in CommandCreateSettler createUnitCommand,
                         in HexCoordinates coordinates
                         ) => {
                Settler.Create(ecb, settlerPrefab, coordinates);

                ecb.DestroyEntity(entity);
            })
        protected override void OnUpdate()
        {
            CityPrefab cityPrefab = GetSingleton <CityPrefab>();
            var        ecb        = barrier.CreateCommandBuffer();
            var        archetype  = UICityLabel.GetCreateArchetype();

            Entities
            .WithoutBurst()
            .ForEach((
                         Entity entity,
                         int entityInQueryIndex,
                         in SettlerTag settlerTag,
                         in CommandCreateCity cmdCreateCity,
                         in HexCoordinates hexCoordinates
                         ) => {
                Entity city = CityEntity.Create(ecb, cityPrefab, entity);

                UICityLabel.Create(ecb, archetype, hexCoordinates);
            }
        protected override void OnUpdate()
        {
            EntityCommandBuffer ecb       = barrier.CreateCommandBuffer();
            EntityArchetype     archetype = UISettlerPanel.GetArchetype();

            Entities
            .WithoutBurst()
            .ForEach((
                         Entity entity,
                         in CommandSelectUnit commandSelectUnit,
                         in HexCoordinates hexCoordinates
                         ) => {
                Entity selectedCell = HexCellService.FindBy(hexCoordinates);
                ecb.AddComponent <Selected>(commandSelectUnit.entity, new Selected {
                });

                UISettlerPanel.Show(ecb, archetype, hexCoordinates);

                ecb.DestroyEntity(entity);
            }).Run();
Beispiel #8
0
        private void ApplyTargetAbilities()
        {
            Entities
            .WithoutBurst()
            .ForEach(
                (in AbilityUsed ability, in AbilityTarget targetComponent) =>
            {
                if (ability.effect.effectType == AbilityEffectType.Target)
                {
                    float average = (ability.effect.baseValueMin + ability.effect.baseValueMax) / 2;

                    if (ability.effect.isHealing)
                    {
                        // I'm thinking about just pushing notify-like entity for this. So we can do it parallel
                        unitSystem.Repair(targetComponent.target, (uint)average);
                        return;
                    }

                    unitSystem.Damage(targetComponent.target, (uint)average);
                }
            }