예제 #1
0
 private void AreaEffects(AmmoDef ammoDef, out AreaEffectType areaEffect, out float areaEffectDamage, out double areaEffectSize, out float detonationDamage, out bool ammoAreaEffect, out double areaRadiusSmall, out double areaRadiusLarge, out double detonateRadiusSmall, out double detonateRadiusLarge, out bool eWar, out bool eWarEffect, out double eWarTriggerRange)
 {
     areaEffect          = ammoDef.AreaEffect.AreaEffect;
     areaEffectDamage    = ammoDef.AreaEffect.AreaEffectDamage;
     areaEffectSize      = ammoDef.AreaEffect.AreaEffectRadius;
     detonationDamage    = ammoDef.AreaEffect.Detonation.DetonationDamage;
     ammoAreaEffect      = ammoDef.AreaEffect.AreaEffect != AreaEffectType.Disabled;
     areaRadiusSmall     = Session.ModRadius(ammoDef.AreaEffect.AreaEffectRadius, false);
     areaRadiusLarge     = Session.ModRadius(ammoDef.AreaEffect.AreaEffectRadius, true);
     detonateRadiusSmall = Session.ModRadius(ammoDef.AreaEffect.Detonation.DetonationRadius, false);
     detonateRadiusLarge = Session.ModRadius(ammoDef.AreaEffect.Detonation.DetonationRadius, true);
     eWar             = areaEffect > (AreaEffectType)2;
     eWarEffect       = areaEffect > (AreaEffectType)3;
     eWarTriggerRange = eWar && Pulse && ammoDef.AreaEffect.EwarFields.TriggerRange > 0 ? ammoDef.AreaEffect.EwarFields.TriggerRange : 0;
 }
예제 #2
0
        private static ConcurrentCachingList <MyCubeBlock> QueryBlockCaches(GridAi ai, MyCubeGrid targetGrid, AreaEffectType effectType)
        {
            ConcurrentDictionary <TargetingDef.BlockTypes, ConcurrentCachingList <MyCubeBlock> > blockTypeMap;

            if (!ai.Session.GridToBlockTypeMap.TryGetValue(targetGrid, out blockTypeMap))
            {
                return(null);
            }

            ConcurrentCachingList <MyCubeBlock> cubes;

            switch (effectType)
            {
            case JumpNullField:
                if (blockTypeMap.TryGetValue(TargetingDef.BlockTypes.Jumping, out cubes))
                {
                    return(cubes);
                }
                break;

            case EnergySinkField:
                if (blockTypeMap.TryGetValue(TargetingDef.BlockTypes.Power, out cubes))
                {
                    return(cubes);
                }
                break;

            case AnchorField:
                if (blockTypeMap.TryGetValue(TargetingDef.BlockTypes.Thrust, out cubes))
                {
                    return(cubes);
                }
                break;

            case NavField:
                if (blockTypeMap.TryGetValue(TargetingDef.BlockTypes.Steering, out cubes))
                {
                    return(cubes);
                }
                break;

            case OffenseField:
                if (blockTypeMap.TryGetValue(TargetingDef.BlockTypes.Offense, out cubes))
                {
                    return(cubes);
                }
                break;

            case EmpField:
            case DotField:
                GridMap gridMap;
                if (ai.Session.GridToInfoMap.TryGetValue(targetGrid, out gridMap))
                {
                    return(gridMap.MyCubeBocks);
                }
                break;
            }

            return(null);
        }
예제 #3
0
        internal static void GetCubesForEffect(GridAi ai, MyCubeGrid grid, Vector3D hitPos, AreaEffectType effectType, List <IMySlimBlock> cubes)
        {
            var fats = QueryBlockCaches(ai, grid, effectType);

            if (fats == null)
            {
                return;
            }

            for (int i = 0; i < fats.Count; i++)
            {
                cubes.Add(fats[i].SlimBlock);
            }

            cubes.Sort((a, b) =>
            {
                var aPos = grid.GridIntegerToWorld(a.Position);
                var bPos = grid.GridIntegerToWorld(b.Position);
                return(Vector3D.DistanceSquared(aPos, hitPos).CompareTo(Vector3D.DistanceSquared(bPos, hitPos)));
            });
        }