Exemple #1
0
        public void ApplyGameplayEffect(int index, EntityCommandBuffer.Concurrent Ecb, AttributesComponent attributesComponent, float WorldTime)
        {
            var attributeModData = AttributeModData();
            // var gameplayEffectData = new GameplayEffectDurationComponent()
            // {
            //     WorldStartTime = WorldTime,
            //     Duration = 5,
            //     Effect = EGameplayEffect.HealRegen
            // };

            var attributeModEntity = Ecb.CreateEntity(index);

            Ecb.AddComponent(index, attributeModEntity, new HealthAttributeModifier());
            // Ecb.AddComponent(index, attributeModEntity, new TemporaryAttributeModification());
            Ecb.AddComponent(index, attributeModEntity, new PermanentAttributeModification());
            // Ecb.AddComponent(index, attributeModEntity, gameplayEffectData);

            Ecb.AddComponent(index, attributeModEntity, attributeModData);
        }
        public void Execute(Entity entity, int index, ref Translation translation)
        {
            float angle = RandomCache.GetAngle();
            float newX  = SpawnerSystem.SpawnerPos.x + Mathf.Sin(angle) * RandomCache.GetCenterDistance();
            float newZ  = SpawnerSystem.SpawnerPos.z + Mathf.Cos(angle) * RandomCache.GetCenterDistance();

            translation.Value = new float3(newX, SpawnerSystem.SpawnerPos.y, newZ);
            CommandBuffer.RemoveComponent <ResetCube>(index, entity);
            uint BlockType = RandomCache.GetCubeType();

            if (BlockType == 1)
            {
                CommandBuffer.AddComponent(index, entity, new MoveUp(RandomCache.GetLifeSpan()));
            }
            else
            {
                CommandBuffer.AddComponent(index, entity, new MoveRandom(RandomCache.GetLifeSpan(), SpawnerSystem.GetRandComponentfloat3()));
            }
        }
Exemple #3
0
        public void Execute(Entity ent, int idx, [ReadOnly] ref Translation trans,
                            [ReadOnly] ref BoundMarkerConvert convert)
        {
            if (!BoundUtil.IsOutOfBounds(bounds, trans.Value.x, trans.Value.y))
            {
                commandBuffer.RemoveComponent(idx, ent, typeof(BoundMarkerConvert));

                // add new marker
                switch (convert.newMarker)
                {
                case InteractionType.KeepIn:
                    commandBuffer.AddComponent(idx, ent, new BoundMarkerIn());
                    break;

                case InteractionType.DeleteOutside:
                    commandBuffer.AddComponent(idx, ent, new BoundMarkerDelete());
                    break;
                }
            }
        }
Exemple #4
0
 public void Execute(Entity entity, int index,
                     [ReadOnly] ref AttackInput attackInput)
 {
     if (attackInput.Attack == true)
     {
         float busyUntil = currentTime + attackInput.AttackLength;
         ECB.AddComponent <Busy>(index, entity, new Busy {
             Until = busyUntil
         });
     }
 }
Exemple #5
0
            public void Execute(Entity entity, int index, ref Translation translation)
            {
                var closestEntity = closestTargets[index];

                if (closestEntity != Entity.Null)
                {
                    commandBuffer.AddComponent(index, entity, new HasTarget {
                        target = closestEntity
                    });
                }
            }
        public void Execute(Entity soldierEntity, int index, ref Translation c0)
        {
            Entity closestEnemyEntity = closestEntityArray[index];

            if (closestEnemyEntity != Entity.Null)
            {
                entityCommandBuffer.AddComponent(index, soldierEntity, new HasEnemyComponent {
                    enemyEntity = closestEnemyEntity
                });
            }
        }
Exemple #7
0
        private static void ApplyRandomColor(ref EntityCommandBuffer.Concurrent commandBuffer,
                                             ref Random randomGenerator, int entityInQueryIndex, Entity spawnedEntity)
        {
            Color         color         = Color.HSVToRGB(randomGenerator.NextFloat(), 0.6f, 0.6f);
            float4        colorValue    = new float4(color.r, color.g, color.b, color.a);
            MaterialColor materialColor = new MaterialColor {
                Value = colorValue
            };

            commandBuffer.AddComponent(entityInQueryIndex, spawnedEntity, materialColor);
        }
Exemple #8
0
 public void Execute(Entity entity, int index, ref Attack Attack, ref Target Target)
 {
     if (Clicked)
     {
         Damage damage = new Damage()
         {
             Value = Attack.Value
         };
         cmd.AddComponent(index, Target.Entity, damage);
     }
 }
        public void Execute
            (Entity entity, int i, [ReadOnly] ref PlayerInput input, [ReadOnly] ref AABB aabb)
        {
            if (input.LeftClick)
            {
                //If selected component exists on our unit, unselect before we recalc selected
                if (Selected.Exists(entity))
                {
                    commandBuffer.RemoveComponent <PlayerUnitSelect>(i, entity);
                    commandBuffer.AddComponent(i, entity, new Deselecting());
                }

                //Add select component to unit
                if (RTSPhysics.Intersect(aabb, ray))
                {
                    commandBuffer.AddComponent(i, entity, new PlayerUnitSelect());
                    commandBuffer.AddComponent(i, entity, new Selecting());
                }
            }
        }
Exemple #10
0
            public void Execute(Entity actor, int index, [ReadOnly] ref ValidateUsageRequest c0)
            {
                EndEcb.RemoveComponent <ValidateUsageRequest>(index, actor);
                if (c0.ResultType != ResultType.Fail)
                {
                    return;
                }

                BeginEcb.AddComponent <OnActionInvalid>(index, actor);
                EndEcb.RemoveComponent <OnActionInvalid>(index, actor);
            }
            public void Execute(Entity entity, int index, DynamicBuffer <KillersOnActorDeath> actorDeathByKillers, [ChangedFilter, ReadOnly] DynamicBuffer <ActorAttribute3Modifys <T> > attribute3Modifys, ref ActorAttribute3Base <T> attribute3Base, ref ActorAttribute3 <T> attribute3)
            {
                //max
                attribute3.max = attribute3Base.max;
                for (var i = 0; i < attribute3Modifys.Length; ++i)
                {
                    if (attribute3Modifys[i].attribute3ModifyType == Attribute3SubModifyType.MaxOffset)
                    {
                        attribute3.max += attribute3Modifys[i].value;
                    }
                }

                //regain
                attribute3.regain = attribute3Base.regain;
                for (var i = 0; i < attribute3Modifys.Length; ++i)
                {
                    if (attribute3Modifys[i].attribute3ModifyType == Attribute3SubModifyType.RegainOffset)
                    {
                        attribute3.regain += attribute3Modifys[i].value;
                    }
                }
                if (attribute3.regain < 0f)
                {
                    attribute3.regain = 0f;
                }

                //value
                for (var i = 0; i < attribute3Modifys.Length; ++i)
                {
                    var attribute3Modify = attribute3Modifys[i];
                    if (attribute3Modify.attribute3ModifyType == Attribute3SubModifyType.ValueOffset)
                    {
                        attribute3.value += attribute3Modify.value;

                        //
                        if (attribute3Modify.value < 0f)
                        {
                            actorDeathByKillers.Add(new KillersOnActorDeath {
                                playerEntity = attribute3Modify.player, type = attribute3Modify.type
                            });
                        }
                    }
                }
                if (attribute3.value > attribute3.max)
                {
                    attribute3.value = attribute3.max;
                }

                //dead
                if (attribute3.value <= 0f)
                {
                    endCommandBuffer.AddComponent(index, entity, OnDestroyMessage);
                }
            }
Exemple #12
0
        public void Execute(Entity e, int index, ref Translation translation, ref RigidBodyComponent rigidBody, [ReadOnly] ref ConveyorComponent conveyor)
        {
            rigidBody.Velocity = conveyor.Direction * conveyor.Speed;
            translation.Value += rigidBody.Velocity * DeltaTime;

            if (translation.Value.x * conveyor.Direction.x > conveyor.MaxX)
            {
                CommandBuffer.RemoveComponent <ConveyorComponent>(index, e);
                CommandBuffer.AddComponent(index, e, new ResetTag());
            }
        }
 public void Execute(Entity entity, int index, [ReadOnly] ref LevelLoadRequest request, [ReadOnly] ref ReceiveRpcCommandRequestComponent requestSource)
 {
     commandBuffer.DestroyEntity(index, entity);
     // Check for disconnects
     if (!rpcFromEntity.Exists(requestSource.SourceConnection))
     {
         return;
     }
     // set the level size - fake loading of level
     levelFromEntity[levelSingleton] = new LevelComponent
     {
         width          = request.width,
         height         = request.height,
         playerForce    = request.playerForce,
         bulletVelocity = request.bulletVelocity
     };
     commandBuffer.AddComponent(index, requestSource.SourceConnection, new PlayerStateComponentData());
     commandBuffer.AddComponent(index, requestSource.SourceConnection, default(NetworkStreamInGame));
     rpcQueue.Schedule(rpcFromEntity[requestSource.SourceConnection], new RpcLevelLoaded());
 }
 public void Execute(int index)
 {
     if (AddArray[index])
     {
         CommandBuffer.AddComponent(m_ThreadIndex, EntityArray[index], new FacingTarget());
     }
     else if (RemoveArray[index])
     {
         CommandBuffer.RemoveComponent <FacingTarget>(m_ThreadIndex, EntityArray[index]);
     }
 }
Exemple #15
0
            public void Execute(Entity weaponEntity, int index, ref WeaponControlInFireState fireState)
            {
                fireState.duration -= fixedDeltaTime;
                if (fireState.duration <= 0)
                {
                    commandBuffer.RemoveComponent(index, weaponEntity, WeaponControlInFireState);

                    commandBuffer.AddComponent(index, weaponEntity, OnWeaponControlFireOffMessage);
                    endCommandBuffer.RemoveComponent(index, weaponEntity, OnWeaponControlFireOffMessage);
                }
            }
        public void Execute(Entity entity, int index, [ReadOnly] ref LbPlayer player, ref Translation translation,
                            [ReadOnly] ref LbMovementSpeed speed, [ReadOnly] ref LbArrowPosition position)
        {
            translation.Value += speed.Value * DeltaTime * (position.Value - translation.Value);

            if (math.distancesq(translation.Value, position.Value) < 0.05f)
            {
                translation.Value = position.Value;
                CommandBuffer.AddComponent(index, entity, new LbArrow());
            }
        }
            public void Execute(Entity _ /*playerEntity*/, int index, ref PlayerActorArray playerActorArray)
            {
                if (playerActorArray.mainActorEntity != Entity.Null)
                {
                    endCommandBuffer.AddComponent(index, playerActorArray.mainActorEntity, OnDestroyMessage);

                    playerActorArray.mainActorEntity = Entity.Null;
                }

                //commandBuffer.RemoveComponent(index, playerEntity, PlayerActorArray);
            }
Exemple #18
0
 public void Execute(Entity entity, int index, ref FindTarget findTarget)
 {
     if (findTarget.FoundEntity != Entity.Null)
     {
         Debug.Log("Add target");
         CommandBuffer.AddComponent(index, entity, new Target()
         {
             TargetEntity = findTarget.FoundEntity
         });
         CommandBuffer.RemoveComponent(index, entity, typeof(FindTarget));
     }
 }
        public void Execute(Entity entity, int index, ref Translation translation)
        {
            QuadrantData quadrantData;

            if (entityTargetHashMap.TryGetValue(entity, out quadrantData))
            {
                entityCommandBuffer.RemoveComponent(index, entity, typeof(HasTarget));
                entityCommandBuffer.AddComponent(index, entity, new HasTarget {
                    targetEntity = quadrantData.entity, targetPosition = quadrantData.position
                });
            }
        }
        // The [ReadOnly] attribute tells the job scheduler that this job will not write to rotSpeedSpawnAndRemove
        public void Execute(Entity entity, int index, ref Translation translation, ref MoveRandom moving)
        {
            // Rotate something about its up vector at the speed given by RotationSpeed_SpawnAndRemove.
            translation.Value = new float3(translation.Value.x + moving.Direction.x * DeltaTime, translation.Value.y + DeltaTime * moving.Direction.y, translation.Value.z);// + moving.Direction.z * DeltaTime);
            moving.LifeSpan  -= DeltaTime;

            if (translation.Value.y > 7.0f || moving.LifeSpan <= 0f || translation.Value.x > 20f)
            {
                CommandBuffer.RemoveComponent <MoveRandom>(index, entity);
                CommandBuffer.AddComponent <ResetCube>(index, entity);
            }
        }
Exemple #21
0
            public void Execute(Entity entity, int index, [Unity.Collections.ReadOnly] ref ResolveAbilityTradeData c0)
            {
                EntityCommandBuffer.RemoveComponent <ResolveAbilityTradeData>(index, entity);
                var e = EntityCommandBuffer.CreateEntity(index);

                EntityCommandBuffer.AddComponent(index, e, new LootCoinsData
                {
                    Amount = 10,
                });

                EntityCommandBuffer.CreateEntity(index, PostResolveCardArchetype);
            }
            public void Execute(ArchetypeChunk chunk, int chunkIndex, int firstEntityIndex)
            {
                var instanceCount = chunk.Count;
                var entities      = chunk.GetNativeArray(entityType);

                for (var i = 0; i < instanceCount; i++)
                {
                    commandBuffer.AddComponent(chunkIndex, entities[i], new LocalToWorld {
                        Value = float4x4.identity
                    });
                }
            }
    protected override JobHandle OnUpdate(JobHandle inputDeps)
    {
        EntityCommandBuffer.Concurrent commandBuffer = m_EntityCommandBuffer.CreateCommandBuffer().ToConcurrent();

        JobHandle savePos = Entities.ForEach((Entity entity, int entityInQueryIndex, in Translation translation, in C_HoldComponentData holdData) =>
        {
            commandBuffer.AddComponent <C_SetPositionComponentData>(entityInQueryIndex, holdData.Item);
            commandBuffer.SetComponent(entityInQueryIndex, holdData.Item, new C_SetPositionComponentData
            {
                Position = translation.Value,
            });
        }).Schedule(inputDeps);
Exemple #24
0
        public void Execute(Entity entity, int index, [ReadOnly] ref ServerStateCommand c0)
        {
            EndCommandBuffer.DestroyEntity(index, entity);
            var buffer     = ServerStates[entity].Reinterpret <byte>().AsNativeArray().ToArray();
            var worldState = MessagePackSerializer.Deserialize <WorldState>(buffer);

            foreach (var pState in worldState.playerState)
            {
                var e = CommandBuffer.CreateEntity(index);
                CommandBuffer.AddComponent(index, e, pState);
            }
        }
Exemple #25
0
    protected override JobHandle OnUpdate(JobHandle inputDeps)
    {
        EntityCommandBuffer.Concurrent commandBuffer = m_EntityCommandBuffer.CreateCommandBuffer().ToConcurrent();

        JobHandle jobHandle = Entities
                              .WithAll <TC_PickHoldAction>()
                              .WithNone <C_CanPick>()
                              .ForEach((Entity entity, int entityInQueryIndex, in Translation translation, in C_HoldComponentData holdComponent, in DirectionData directionData) =>
        {
            int2 i2Direction     = directionData.directionLook;
            float fXDropPosition = translation.Value.x + (float)i2Direction.x / 2;

            commandBuffer.AddComponent <MC_RemoveInHold>(entityInQueryIndex, holdComponent.Item);
            commandBuffer.SetComponent(entityInQueryIndex, holdComponent.Item, new MC_RemoveInHold
            {
                Position = new float3(fXDropPosition, translation.Value.y, 0)
            });
            commandBuffer.RemoveComponent <TC_PickHoldAction>(entityInQueryIndex, entity);
            commandBuffer.RemoveComponent <C_HoldComponentData>(entityInQueryIndex, entity);
            commandBuffer.AddComponent <C_CanPick>(entityInQueryIndex, entity);
        }).Schedule(inputDeps);
        public void Execute(Entity entity, int index, ref Translation translation)
        {
            float3 entityPosition = translation.Value;

            if (entityPosition.x >= lowerLeftPosition.x &&
                entityPosition.y >= lowerLeftPosition.y &&
                entityPosition.x <= upperRightPosition.x &&
                entityPosition.y <= upperRightPosition.y)
            {
                entityCommandBuffer.AddComponent(index, entity, new SelectedTag());
            }
        }
 protected override void OnStateEnter(EntityCommandBuffer.Concurrent ecbConcurrent)
 {
     Entities
     .WithNone <TestPlayStateSystemState>()
     .ForEach((Entity entity,
               int entityInQueryIndex,
               in TestPlayState state) =>
     {
         ecbConcurrent.AddComponent <TestPlayStateSystemState>(entityInQueryIndex, entity);
     })
     .Schedule();
 }
Exemple #28
0
        public void Execute(Entity e, int index, [ReadOnly] ref Position antPos, ref FacingAngle facingAngle)
        {
            Vector2 distance = antPos.Value - ColonyPos[0].Value;

            if (distance.sqrMagnitude < 4f * 4f)
            {
                //ant.holdingResource = !ant.holdingResource;
                ecb.RemoveComponent <TagAntHasFood>(index, e);
                ecb.AddComponent <TagAntHasDirtyMesh>(index, e);
                facingAngle.Value += Mathf.PI;
            }
        }
Exemple #29
0
            public void Execute(Entity npc, int index, [ReadOnly] ref Translation translation)
            {
                var target = TargetArray[index];

                if (target != Entity.Null)
                {
                    EntityCommandBuffer.AddComponent(index, npc, new HasTarget
                    {
                        Target = target
                    });
                }
            }
Exemple #30
0
 public void Execute(Entity entity, int jobIndex, ref AttackTargetComponent attackTarget, ref AttackStatusComponent attackStatus)
 {
     if (time - attackStatus.LastAttack >= attackRate)
     {
         attackStatus.LastAttack = time;
         Entity e = commandBuffer.CreateEntity(jobIndex);
         commandBuffer.AddComponent(jobIndex, e,
                                    new DamageComponent {
             Source = entity, Target = attackTarget.Target, Amount = damage
         });
     }
 }