public void Execute(Entity entity, int index,
                                [ReadOnly, ChangedFilter] DynamicBuffer <PhysicsTriggerResults> physicsTriggerResults,
                                [ReadOnly] ref ActorAttribute3Offset <_HP> hpOffset,
                                [ReadOnly] ref ActorOwner actorOwner, [ReadOnly] ref Actor actor)
            {
                for (var i = 0; i < physicsTriggerResults.Length; ++i)
                {
                    var targetEntity = physicsTriggerResults[i].entity;

                    var hp = hpOffset.GetValue(random.NextFloat(0f, 1f));

                    if (hpModifyFromEntity.Exists(targetEntity))
                    {
                        hpModifyFromEntity[targetEntity].Add(new ActorAttribute3Modifys <_HP>
                        {
                            player = actorOwner.playerEntity,
                            type   = actor.actorType,
                            value  = hp,
                            attribute3ModifyType = Attribute3SubModifyType.ValueOffset
                        });
                    }

                    //
                    var translation = translationFromEntity[targetEntity];
                    AttributeModifyFxSpawner.createInServer(endCommandBuffer, index, actor.actorType, translation, hp, 0f, default);
                }
            }
Exemplo n.º 2
0
            public void Execute(Entity laserEntity, int index,
                                [ReadOnly, ChangedFilter] DynamicBuffer <PhysicsRaycastResults> raycastResults,
                                [ReadOnly] ref Laser laser, [ReadOnly] ref ActorAttribute3Offset <_HP> hpOffset, [ReadOnly] ref Translation laserTranslation,
                                [ReadOnly] ref ActorOwner actorOwner, [ReadOnly] ref Actor actor)
            {
                for (var i = 0; i < raycastResults.Length; ++i)
                {
                    var raycastResult = raycastResults[i];

                    var distance = math.distance(laserTranslation.Value, raycastResult.point);
                    var percent  = 1f - distance / laser.distance;
                    var hp       = hpOffset.GetValue(percent);


                    var targetEntity = raycastResult.entity;

                    if (hpModifyFromEntity.Exists(targetEntity))
                    {
                        hpModifyFromEntity[targetEntity].Add(new ActorAttribute3Modifys <_HP>
                        {
                            player = actorOwner.playerEntity,
                            type   = actor.actorType,
                            value  = hp,
                            attribute3ModifyType = Attribute3SubModifyType.ValueOffset
                        });
                    }

                    //
                    var translation = new Translation {
                        Value = raycastResult.point
                    };
                    AttributeModifyFxSpawner.createInServer(endCommandBuffer, index, actor.actorType, translation, hp, 0f, default);
                }
            }
Exemplo n.º 3
0
            public void Execute(Entity explosionEntity, int index,
                                [ReadOnly, ChangedFilter] DynamicBuffer <PhysicsResults> rigidbodyResults,
                                [ReadOnly] DynamicBuffer <PhysicsOverlapHitPoints> overlapHitPoints,
                                [ReadOnly] ref Explosion explosion, [ReadOnly] ref ActorAttribute3Offset <_HP> hpOffset,
                                [ReadOnly] ref ActorOwner actorOwner, [ReadOnly] ref Actor actor)
            {
                for (var i = 0; i < rigidbodyResults.Length; ++i)
                {
                    var targetEntity = rigidbodyResults[i].entity;

                    var targetTranslation    = translationFromEntity[targetEntity];
                    var explosionTranslation = translationFromEntity[explosionEntity];


                    var distance = math.distance(explosionTranslation.Value, targetTranslation.Value);
                    var percent  = 0f;
                    if (distance < explosion.radius)
                    {
                        percent = 1f - distance / explosion.radius;
                    }

                    var hp = hpOffset.GetValue(percent);

                    if (hpModifyFromEntity.Exists(targetEntity))
                    {
                        hpModifyFromEntity[targetEntity].Add(new ActorAttribute3Modifys <_HP>
                        {
                            player = actorOwner.playerEntity,
                            type   = actor.actorType,
                            value  = hp,
                            attribute3ModifyType = Attribute3SubModifyType.ValueOffset
                        });
                    }

                    //
                    var translation = new Translation {
                        Value = overlapHitPoints[i].value
                    };
                    AttributeModifyFxSpawner.createInServer(endCommandBuffer, index, actor.actorType, translation, hp, 0f, default);
                }
            }
            public void Execute(Entity entity, int index, [ReadOnly, ChangedFilter] DynamicBuffer <PhysicsTriggerResults> physicsTriggerResults, [ReadOnly] ref PhysicsTriggerFx physicsTriggerFx, [ReadOnly] ref Actor actor)
            {
                for (var i = 0; i < physicsTriggerResults.Length; ++i)
                {
                    if (physicsTriggerResults[i].state != physicsTriggerFx.includeResultState)
                    {
                        continue;
                    }

                    var targetEntity = physicsTriggerResults[i].entity;

                    if (withoutBullet && bulletFromEntity.Exists(targetEntity))
                    {
                        continue;
                    }

                    var translation = translationFromEntity[targetEntity];

                    AttributeModifyFxSpawner.createInServer(endCommandBuffer, index, actor.actorType, translation, half.zero, half.zero, targetEntity);
                }
            }
Exemplo n.º 5
0
            public void Execute(Entity bulletEntity, int index,
                                [ReadOnly, ChangedFilter] DynamicBuffer <PhysicsRaycastResults> raycastResults,
                                [ReadOnly] ref ActorAttribute3Offset <_HP> hpOffset, [ReadOnly] ref ActorLifetime actorLifetime,
                                [ReadOnly] ref ActorOwner actorOwner, [ReadOnly] ref Actor actor)
            {
                if (raycastResults.Length <= 0)
                {
                    return;
                }

                var hp = hpOffset.GetValue(actorLifetime.percent);

                for (var i = 0; i < raycastResults.Length; ++i)
                {
                    var targetEntity = raycastResults[i].entity;

                    if (hpModifyFromEntity.Exists(targetEntity))
                    {
                        hpModifyFromEntity[targetEntity].Add(new ActorAttribute3Modifys <_HP>
                        {
                            player = actorOwner.playerEntity,
                            type   = actor.actorType,
                            value  = hp,
                            attribute3ModifyType = Attribute3SubModifyType.ValueOffset
                        });
                    }


                    //
                    var translation = new Translation {
                        Value = raycastResults[i].point
                    };
                    AttributeModifyFxSpawner.createInServer(endCommandBuffer, index, actor.actorType, translation, hp, 0f, default);
                }


                endCommandBuffer.AddComponent(index, bulletEntity, new OnDestroyMessage {
                });
            }