Exemple #1
0
 public void OnHitEnvrionment(Contexts contexts, PlayerEntity src, RaycastHit hit, MeleeAttackInfo attackInfo, MeleeFireLogicConfig config)
 {
     if (!src.WeaponController().IsHeldSlotEmpty)
     {
         RaycastHit effectHit;
         if (TryGetEffectShowHit(src, out effectHit, config.Range))
         {
             ClientEffectFactory.AdHitEnvironmentEffectEvent(src, effectHit.point, effectHit.normal, EEnvironmentType.Wood);
         }
     }
 }
Exemple #2
0
 public void OnHitEnvrionment(PlayerEntity src, RaycastHit hit, MeleeAttackInfo attackInfo, MeleeFireLogicConfig config)
 {
     if (!src.weaponLogic.Weapon.EmptyHand)
     {
         RaycastHit effectHit;
         if (TryGetEffectShowHit(src, out effectHit, config.Range))
         {
             ClientEffectFactory.AdHitEnvironmentEffectEvent(src, effectHit.point,
                                                             effectHit.normal,
                                                             EEnvironmentType.Wood);
         }
     }
 }
        public void OnHitEnvrionment(Contexts contexts, PlayerEntity src, RaycastHit hit, MeleeAttackInfo attackInfo,
                                     MeleeFireLogicConfig config)
        {
            var                    heldConfigId = src.WeaponController().HeldConfigId;
            RaycastHit             effectHit;
            bool                   showAttackEffect  = (MeleeHitUtil.CanMeleeAttackShowHit(src, out effectHit, config.Range));
            var                    collider          = effectHit.collider != null ? effectHit.collider : hit.collider;
            FracturedHittable      fracturedHittable = collider.GetComponent <FracturedHittable>();
            FracturedAbstractChunk fracturedChunk    = HitFracturedHandler.HitFracturedObj(src, effectHit, fracturedHittable);
            var                    hasHole           = fracturedChunk == null || (fracturedChunk.HasBulletHole && !fracturedChunk.IsBroken());

            if (showAttackEffect && hasHole)
            {
                int audioId = SingletonManager.Get <AudioWeaponManager>().FindById(heldConfigId).HitList.Body;
                ClientEffectFactory.AdHitEnvironmentEffectEvent(src, effectHit.point, effectHit.normal,
                                                                EEnvironmentType.Wood, audioId, 0, heldConfigId != WeaponUtil.EmptyHandId);
            }
        }
Exemple #4
0
        private void OnHitEnvironment(PlayerEntity srcPlayer, IBulletEntity bulletEntity, RaycastHit hit)
        {
            if (srcPlayer.gamePlay.IsDead())
            {
                _logger.InfoFormat("[hit] environment dead");
                return;
            }

            ThicknessInfo   thicknessInfo;
            EnvironmentInfo info = BulletEnvironmentUtility.GetEnvironmentInfoByHitBoxName(hit, bulletEntity.Velocity, out thicknessInfo);
            float           damageDecayFactor = _environmentTypeConfigManager.GetDamageDecayFactorByEnvironmentType(info.Type);
            float           energyDecayFactor = _environmentTypeConfigManager.GetEnergyDecayFactorByEnvironmentType(info.Type);
            float           oldThickNess      = bulletEntity.PenetrableThickness;
            float           oldDamage         = bulletEntity.BaseDamage;

            bulletEntity.BaseDamage           *= damageDecayFactor;
            bulletEntity.PenetrableThickness   = bulletEntity.PenetrableThickness * energyDecayFactor - info.Thickness;
            bulletEntity.PenetrableLayerCount -= info.LayerCount;

            if (bulletEntity.PenetrableLayerCount <= 0 || bulletEntity.PenetrableThickness <= 0)
            {
                bulletEntity.IsValid = false;
            }
            else
            {
                bulletEntity.AddPenetrateInfo(info.Type);
            }

            EBulletCaliber caliber = bulletEntity.Caliber; //根据口径

            var collider          = hit.collider;
            var fracturedHittable = collider.GetComponent <FracturedHittable>();

            if (fracturedHittable != null)
            {
                EntityKey?hittedObjectKey = null;

                var script = fracturedHittable.gameObject.GetComponent <FracturedHittable>();
                if (script == null)
                {
                    return;
                }

                var objtype = MapObjectUtility.GetGameObjType(script.Owner);
                if (objtype < 0)
                {
                    return;
                }

                var rawObjKey = MapObjectUtility.GetGameObjId(script.Owner);

                if (rawObjKey != Int32.MinValue && !SharedConfig.IsServer &&
                    MapObjectUtility.GetMapObjectByGameObject(script.Owner) == null)
                {
                    MapObjectUtility.SendCreateMapObjMsg(objtype, rawObjKey);
                    _logger.InfoFormat("CreateMapObjEvent: type:{0}, obj:{1}, num:{2}", (ETriggerObjectType)objtype,
                                       fracturedHittable.gameObject,
                                       srcPlayer.uploadEvents.Events.Events[EEventType.CreateMapObj].Count);
                }

                FracturedAbstractChunk fracturedChunk = null;

                fracturedChunk = fracturedHittable.Hit(hit.point, hit.normal);
                if (fracturedHittable.HasBulletHole && fracturedChunk != null)
                {
                    ClientEffectFactory.CreateHitFracturedChunkEffect(_contexts.clientEffect, _entityIdGenerator, hit.point,
                                                                      srcPlayer.entityKey.Value, hittedObjectKey.Value, fracturedChunk.ChunkId,
                                                                      hit.point - fracturedChunk.transform.position, hit.normal);
                }

                srcPlayer.statisticsData.Statistics.ShootingSuccCount++;

                if (fracturedHittable.HasBulletHole && fracturedChunk != null && bulletEntity.IsValid && thicknessInfo.Thickness > 0)
                {
                    ClientEffectFactory.CreateHitFracturedChunkEffect(_contexts.clientEffect, _entityIdGenerator, thicknessInfo.OutPoint, srcPlayer.entityKey.Value,
                                                                      hittedObjectKey.Value, fracturedChunk.ChunkId, thicknessInfo.OutPoint - fracturedChunk.transform.position, thicknessInfo.Normal);
                }
            }
            else
            {
                ClientEffectFactory.AdHitEnvironmentEffectEvent(srcPlayer, hit.point, hit.normal, info.Type);

                if (bulletEntity.IsValid && thicknessInfo.Thickness > 0)
                {
                    ClientEffectFactory.AdHitEnvironmentEffectEvent(srcPlayer, thicknessInfo.OutPoint, thicknessInfo.Normal, info.Type);
                }
            }

            _logger.InfoFormat("[hit]bullet from {0} hit environment {1}, collier {2}, base damage {3}->{4}, penetrable thick {5}->{6}, env ({7}), remain layer {8}",
                               bulletEntity.OwnerEntityKey, hit.point, hit.collider.name, oldDamage, bulletEntity.BaseDamage, oldThickNess, bulletEntity.PenetrableThickness,
                               info, bulletEntity.PenetrableLayerCount);
        }
Exemple #5
0
        private void DoHitEnvironment(PlayerEntity srcPlayer, IBulletEntityAgent bulletEntityAgent, RaycastHit hit)
        {
            if (srcPlayer.gamePlay.IsDead())
            {
                BulletHitHandler._logger.InfoFormat("hit environment dead");
                return;
            }
            subProfilerInfo.BeginProfileOnlyEnableProfile();
            // BulletHitHandler._logger.InfoFormat("[Hit{0}] OwnerEntityKey {1}, point {2},collider:{3}", cmdSeq,
            //     bulletEntityAgent.OwnerEntityKey, hit.point, hit.collider.name);
            ThicknessInfo thicknessInfo;

            /*profiler:热点项 考虑材质检测方式调整
             * --GetColliderThickness
             * -- GetMaterialByHit
             * --GetEnvironmentTypeByMatName
             */
            EnvironmentInfo info =
                BulletEnvironmentUtil.GetEnvironmentInfoByHitBoxName(hit, bulletEntityAgent.Velocity,
                                                                     out thicknessInfo);
            float damageDecayFactor = SingletonManager.Get <EnvironmentTypeConfigManager>().GetDamageDecayFactorByEnvironmentType(info.Type);
            float energyDecayFactor = SingletonManager.Get <EnvironmentTypeConfigManager>().GetEnergyDecayFactorByEnvironmentType(info.Type);

            // float oldThickNess      = bulletEntityAgent.PenetrableThickness;
            // float oldDamage         = bulletEntityAgent.BaseDamage;
            bulletEntityAgent.BaseDamage         *= damageDecayFactor;
            bulletEntityAgent.PenetrableThickness =
                bulletEntityAgent.PenetrableThickness * energyDecayFactor - info.Thickness;
            bulletEntityAgent.PenetrableLayerCount -= info.LayerCount;

            if (bulletEntityAgent.PenetrableLayerCount <= 0 || bulletEntityAgent.PenetrableThickness <= 0)
            {
                //profiler:editor下热点项 -- Entity.AddComponent
                bulletEntityAgent.IsValid = false;
            }
            else
            {
                bulletEntityAgent.AddPenetrateInfo(info.Type);
            }
            subProfilerInfo.EndProfileOnlyEnableProfile();
            var collider          = hit.collider;
            var fracturedHittable = collider.GetComponent <FracturedHittable>();

            if (fracturedHittable != null)
            {
                var fracturedChunk = HitFracturedHandler.HitFracturedObj(srcPlayer, hit, fracturedHittable);

                if (fracturedHittable.HasBulletHole && fracturedChunk != null)
                {
                    // ClientEffectFactory.CreateHitFracturedChunkEffect( hit.point, srcPlayer.entityKey.Value, fracturedHittable.transform, fracturedChunk.ChunkId,hit.point - fracturedChunk.transform.position, hit.normal,info.Type);
                    if (fracturedChunk.IsBroken())
                    {
                        ChunkEffectBehavior.CleanupChunkEffectBehaviors(fracturedChunk.ChunkId);
                    }
                    else
                    {
                        ClientEffectFactory.CreateHitEnvironmentEffect(hit.point, hit.normal, info.Type,
                                                                       (int)EAudioUniqueId.BulletHit, true, fracturedChunk.ChunkId, fracturedChunk.transform);
                    }
                }


                srcPlayer.statisticsData.Statistics.ShootingSuccCount++;

                if (fracturedHittable.HasBulletHole && fracturedChunk != null && bulletEntityAgent.IsValid &&
                    thicknessInfo.Thickness > 0)
                {
                    ClientEffectFactory.CreateHitEnvironmentEffect(hit.point, hit.normal, info.Type,
                                                                   (int)EAudioUniqueId.BulletHit, true, fracturedChunk.ChunkId, fracturedChunk.transform);
                    // ClientEffectFactory.CreateHitFracturedChunkEffect(_contexts.clientEffect, _entityIdGenerator,
                    // thicknessInfo.OutPoint, srcPlayer.entityKey.Value, hittedObjectKey, fracturedChunk.ChunkId,
                    // thicknessInfo.OutPoint - fracturedChunk.transform.position, thicknessInfo.Normal);
                }
            }
            else
            {
                //profiler:热点项   -- EventInfos.Instance.Allocate(EEventType.HitEnvironment, false);
                ClientEffectFactory.AdHitEnvironmentEffectEvent(srcPlayer, hit.point, hit.normal, info.Type,
                                                                (int)EAudioUniqueId.BulletHit);

                if (bulletEntityAgent.IsValid && thicknessInfo.Thickness > 0)
                {
                    ClientEffectFactory.AdHitEnvironmentEffectEvent(srcPlayer, thicknessInfo.OutPoint,
                                                                    thicknessInfo.Normal, info.Type, (int)EAudioUniqueId.BulletHit);
                }
            }

            // BulletHitHandler._logger.InfoFormat(
            // "bullet from {0} hit environment {1}, collier {2}, base damage {3}->{4}, penetrable thick {5}->{6}, env ({7}), remain layer {8}",
            // bulletEntityAgent.OwnerEntityKey, hit.point, hit.collider.name, oldDamage, bulletEntityAgent.BaseDamage,
            // oldThickNess, bulletEntityAgent.PenetrableThickness, info, bulletEntityAgent.PenetrableLayerCount);
        }
Exemple #6
0
        private void OnHitEnvironment(PlayerEntity srcPlayer, IBulletEntity bulletEntity, RaycastHit hit)
        {
            ThicknessInfo   thicknessInfo;
            EnvironmentInfo info = BulletEnvironmentUtility.GetEnvironmentInfoByHitBoxName(hit, bulletEntity.Velocity, out thicknessInfo);
            float           damageDecayFactor = _environmentTypeConfigManager.GetDamageDecayFactorByEnvironmentType(info.Type);
            float           energyDecayFactor = _environmentTypeConfigManager.GetEnergyDecayFactorByEnvironmentType(info.Type);
            float           oldThickNess      = bulletEntity.PenetrableThickness;
            float           oldDamage         = bulletEntity.BaseDamage;

            bulletEntity.BaseDamage           *= damageDecayFactor;
            bulletEntity.PenetrableThickness   = bulletEntity.PenetrableThickness * energyDecayFactor - info.Thickness;
            bulletEntity.PenetrableLayerCount -= info.LayerCount;

            if (bulletEntity.PenetrableLayerCount <= 0 || bulletEntity.PenetrableThickness <= 0)
            {
                bulletEntity.IsValid = false;
            }
            else
            {
                bulletEntity.AddPenetrateInfo(info.Type);
            }

            EBulletCaliber caliber = bulletEntity.Caliber; //根据口径

            var collider          = hit.collider;
            var fracturedHittable = collider.GetComponent <FracturedHittable>();

            if (fracturedHittable != null)
            {
                EntityKey?hittedObjectKey = null;

                var sceneObjectEntity = MapObjectUtility.GetMapObjectOfFracturedHittable(fracturedHittable);
                if (sceneObjectEntity != null)
                {
                    hittedObjectKey = sceneObjectEntity.entityKey.Value;
                }
                else
                {
                    var mapObjectEntity = MapObjectUtility.GetMapObjectOfFracturedHittable(fracturedHittable);
                    if (mapObjectEntity != null)
                    {
                        hittedObjectKey = mapObjectEntity.entityKey.Value;
                    }
                }

                FracturedAbstractChunk fracturedChunk = null;

                if (null != hittedObjectKey)
                {
                    fracturedChunk = fracturedHittable.Hit(hit.point, hit.normal);
                    if (fracturedHittable.HasBulletHole && fracturedChunk != null)
                    {
                        ClientEffectFactory.CreateHitFracturedChunkEffect(
                            _contexts.clientEffect,
                            _entityIdGenerator,
                            hit.point,
                            srcPlayer.entityKey.Value,
                            hittedObjectKey.Value,
                            fracturedChunk.ChunkId,
                            hit.point - fracturedChunk.transform.position,
                            hit.normal);
                    }

                    srcPlayer.statisticsData.Statistics.ShootingSuccCount++;
                }
                else
                {
                    _logger.ErrorFormat("no entity reference attached to {0}", fracturedHittable.name);
                }
                if (fracturedHittable.HasBulletHole && fracturedChunk != null &&
                    bulletEntity.IsValid && thicknessInfo.Thickness > 0)
                {
                    ClientEffectFactory.CreateHitFracturedChunkEffect(_contexts.clientEffect,
                                                                      _entityIdGenerator,
                                                                      thicknessInfo.OutPoint,
                                                                      srcPlayer.entityKey.Value,
                                                                      hittedObjectKey.Value,
                                                                      fracturedChunk.ChunkId,
                                                                      thicknessInfo.OutPoint - fracturedChunk.transform.position,
                                                                      thicknessInfo.Normal);
                }
            }
            else
            {
                ClientEffectFactory.AdHitEnvironmentEffectEvent(srcPlayer, hit.point,
                                                                hit.normal, info.Type);

                if (bulletEntity.IsValid && thicknessInfo.Thickness > 0)
                {
                    ClientEffectFactory.AdHitEnvironmentEffectEvent(srcPlayer, thicknessInfo.OutPoint, thicknessInfo.Normal, info.Type);
                }
            }


            _logger.DebugFormat(
                "bullet from {0} hit environment {1}, collier {2}, base damage {3}->{4}, penetrable thick {5}->{6}, env ({7}), remain layer {8}",
                bulletEntity.OwnerEntityKey,
                hit.point, hit.collider.name,
                oldDamage, bulletEntity.BaseDamage,
                oldThickNess, bulletEntity.PenetrableThickness,
                info,
                bulletEntity.PenetrableLayerCount);

            DamageInfoDebuger.OnEnvironmentHit(_contexts.player, _damager, _damageInfoCollector);
        }