コード例 #1
0
        public static BomberSkyfaller SpawnSkyfaller(ThingDef skyfaller, Thing innerThing, IntVec3 start, IntVec3 end, List <IntVec3> bombCells, BombingType bombType, Map map, int idNumber, Thing original, Map originalMap, IntVec3 landingSpot)
        {
            BomberSkyfaller thing = BomberSkyfallerMaker.MakeSkyfaller(skyfaller, innerThing);

            thing.originalMap              = originalMap;
            thing.sourceLandingSpot        = landingSpot;
            thing.numberOfBombs            = SRTSMod.GetStatFor <int>(original.def.defName, StatName.numberBombs);
            thing.precisionBombingNumBombs = SRTSMod.GetStatFor <int>(original.def.defName, StatName.precisionBombingNumBombs);
            thing.speed    = SRTSMod.GetStatFor <float>(original.def.defName, StatName.bombingSpeed);
            thing.radius   = SRTSMod.GetStatFor <int>(original.def.defName, StatName.radiusDrop);
            thing.sound    = original.TryGetComp <CompBombFlyer>().Props.soundFlyBy;
            thing.bombType = bombType;

            double angle = start.AngleToPointRelative(end);

            thing.angle = (float)(angle + 90) * -1;
            IntVec3 exitPoint = SPTrig.ExitPointCustom(angle, start, map);

            BomberSkyfaller bomber = (BomberSkyfaller)GenSpawn.Spawn(thing, exitPoint, map, WipeMode.Vanish);

            bomber.bombCells = bombCells;
            return(bomber);
        }
コード例 #2
0
        public static IntVec3 ExitPointCustom(double angle, IntVec3 start, Map map)
        {
            if (angle < 0 || angle > 360)
            {
                return(IntVec3.Invalid);
            }


            Rot4 rayDir = Rot4.Invalid;

            if (angle <= start.AngleToPointRelative(map.Size) || angle > start.AngleToPointRelative(new IntVec3(map.Size.x, 0, 0)))
            {
                rayDir = Rot4.East;
            }
            else if (angle <= start.AngleToPointRelative(new IntVec3(0, 0, map.Size.z)) && angle >= start.AngleToPointRelative(map.Size))
            {
                rayDir = Rot4.North;
            }
            else if (angle <= start.AngleToPointRelative(IntVec3.Zero) && angle >= start.AngleToPointRelative(new IntVec3(0, 0, map.Size.z)))
            {
                rayDir = Rot4.West;
            }
            else if (angle <= start.AngleToPointRelative(new IntVec3(map.Size.x, 0, 0)) && angle >= start.AngleToPointRelative(IntVec3.Zero))
            {
                rayDir = Rot4.South;
            }

            switch (rayDir.AsInt)
            {
            case 0:     //North
                return(new IntVec3((int)((map.Size.z - start.z) / Math.Tan((angle > 90 ? (-(180 - angle)) : angle).DegreesToRadians())) + start.x, 0, map.Size.z - 1));

            case 1:     //East
                return(new IntVec3(map.Size.x - 1, 0, (int)((map.Size.x - start.x) * Math.Tan(angle.DegreesToRadians())) + start.z));

            case 2:     //South
                return(new IntVec3(start.x + (angle > 270 ? 1 : -1) * (int)(start.z * Math.Tan((angle > 270 ? angle - 270 : 270 - angle).DegreesToRadians())), 0, 0));

            case 3:     //West
                return(new IntVec3(0, 0, start.z + (angle > 180 ? -1 : 1) * (int)(start.x * Math.Tan((angle > 180 ? (angle - 180) : (180 - angle)).DegreesToRadians()))));
            }
            return(IntVec3.Invalid);
        }