Ejemplo n.º 1
0
        public static void InitCoordinates(this ShadowMote SM, Vector3 DestinationCell)
        {
            if (SM.HasTargetingGameParent)
            {
                SM.flatOrigin = SM.throwerOrigin = SM.TG_parent.pawn.DrawPos;
            }
            else if (SM.HasThrowRockParent)
            {
                SM.flatOrigin = SM.throwerOrigin = SM.JDTR_parent.pawn.DrawPos;
            }

            SM.destination  = DestinationCell;
            SM.flatOrigin.y = DestinationCell.y = 0;

            SM.BaseDistance = Vector3.Distance(SM.flatOrigin, DestinationCell);

            if (SM.HasTargetingGameParent)
            {
                SM.targetBuildingCoordinates = SM.TG_parent.PetanqueSpotCell.ToVector3Shifted();
            }
            else if (SM.HasThrowRockParent)
            {
                SM.targetBuildingCoordinates = SM.JDTR_parent.TargetCell.ToVector3Shifted();
            }
        }
Ejemplo n.º 2
0
        public static Thing ShadowMoteSpawner_ThrowObjectAt(this JobDriver_PlayGenericTargetingGame PGTG)
        {
            Pawn     thrower    = PGTG.pawn;
            IntVec3  targetCell = PGTG.PetanqueSpotCell;
            SkillDef skillDef   = PGTG.SkillDefScaling;

            ThingDef moteDef = PGTG.MoteDef;

            if (!thrower.AllowedMoteSpawn())
            {
                return(null);
            }

            float   randomSpeed     = PGTG.Speed.RandomInRange;
            Vector3 destinationCell =
                targetCell.ToVector3Shifted() +
                Vector3Utility.RandomHorizontalOffset((1f - (float)thrower.skills.GetSkill(skillDef).Level / 20f) * 1.8f);

            destinationCell.y = thrower.DrawPos.y;
            ShadowMote moteThrown = (ShadowMote)ThingMaker.MakeThing(moteDef);

            //moteThrown.Initialization(thrower.DrawPos, destinationCell, PGTG.PetanqueSpotCell.ToVector3Shifted(), thrower);
            moteThrown.Initialization(PGTG, destinationCell);

            moteThrown.Scale         = 1f;
            moteThrown.rotationRate  = PGTG.Rotation.RandomInRange;
            moteThrown.exactPosition = thrower.DrawPos;
            moteThrown.SetVelocity((destinationCell - moteThrown.exactPosition).AngleFlat(), randomSpeed);

            moteThrown.airTimeLeft = Mathf.RoundToInt((moteThrown.exactPosition - destinationCell).MagnitudeHorizontal() / randomSpeed);

            return(GenSpawn.Spawn(moteThrown, thrower.Position, thrower.Map));
        }
Ejemplo n.º 3
0
        public static void Initialization(this ShadowMote SM, JobDriver_ThrowRocks JDTR, Vector3 DestinationCell)
        {
            SM.JDTR_parent = JDTR;

            SM.InitCoordinates(DestinationCell);
            //SM.InitGroundShadowGraphic();
        }
Ejemplo n.º 4
0
        public static void Initialization(this ShadowMote SM, JobDriver_PlayGenericTargetingGame TG, Vector3 DestinationCell)
        {
            SM.TG_parent = TG;

            SM.InitCoordinates(DestinationCell);
            SM.InitGroundShadowGraphic();
        }
Ejemplo n.º 5
0
        public static void ThrowImpactMote(this ShadowMote shadowMote)
        {
            if (!shadowMote.HasMSE || !shadowMote.MSE.HasImpactMote)
            {
                return;
            }

            Vector3 loc = shadowMote.exactPosition;
            Map     map = shadowMote.Map;

            MoteSubEffect MSE = shadowMote.MSE;

            //Tools.Warn("ThrowImpactMote ; has MSE; has impactMote", MSE.debug);

            if (!loc.AllowedMoteSpawn(map))
            {
                return;
            }
            //Tools.Warn("ThrowImpactMote ; AllowedMoteSpawn", MSE.debug);

            if (!MSE.NewBaseImpactMote(out MoteThrown moteThrown))
            {
                Tools.Warn("ThrowImpactMote ; NewBaseImpactMote ko; giving up", MSE.debug);
                return;
            }


            moteThrown.exactPosition = loc;
            //Tools.Warn("ThrowImpactMote ; what", MSE.debug);
            moteThrown.exactPosition += new Vector3(Rand.Range(-0.02f, 0.02f), 0f, Rand.Range(-0.02f, 0.02f));

            //Tools.Warn("ThrowImpactMote ; exactPosition ok", MSE.debug);

            moteThrown.SetVelocity(
                MSE.impactMote.angle.RandomInRange,
                MSE.impactMote.speed.RandomInRange
                );

            //Tools.Warn("ThrowImpactMote ; SetVelocity ok", MSE.debug);

            GenSpawn.Spawn(moteThrown, loc.ToIntVec3(), map);
            Tools.Warn("ThrowImpactMote ; GenSpawn.Spawn ok", MSE.debug);
        }
Ejemplo n.º 6
0
        public static Thing ShadowMoteSpawner_ThrowObjectAt(this JobDriver_ThrowRocks JDTR)
        {
            bool   MyDebug  = JDTR.gameSettings.debug;
            string debugStr = MyDebug ? JDTR.PawnLabel + "ShadowMoteSpawner_ThrowObjectAt - " : "";

            Pawn     thrower    = JDTR.pawn;
            IntVec3  targetCell = JDTR.TargetCell;
            SkillDef skillDef   = JDTR.SkillDefScaling;

            ThingDef moteDef = JDTR.MoteDef;

            if (!thrower.AllowedMoteSpawn())
            {
                return(null);
            }

            float   randomSpeed     = JDTR.Speed.RandomInRange;
            Vector3 destinationCell =
                targetCell.ToVector3Shifted() +
                Vector3Utility.RandomHorizontalOffset((1f - (float)thrower.skills.GetSkill(skillDef).Level / 20f) * 1.8f);

            destinationCell.y = thrower.DrawPos.y;
            if (moteDef == null)
            {
                Tools.Warn(debugStr + "found no moteDef", MyDebug);
                return(null);
            }

            ShadowMote moteThrown = (ShadowMote)ThingMaker.MakeThing(moteDef);

            //moteThrown.Initialization(thrower.DrawPos, destinationCell, PGTG.PetanqueSpotCell.ToVector3Shifted(), thrower);
            moteThrown.Initialization(JDTR, destinationCell);

            moteThrown.Scale         = 1f;
            moteThrown.rotationRate  = JDTR.Rotation.RandomInRange;
            moteThrown.exactPosition = thrower.DrawPos;
            moteThrown.SetVelocity((destinationCell - moteThrown.exactPosition).AngleFlat(), randomSpeed);

            moteThrown.airTimeLeft = Mathf.RoundToInt((moteThrown.exactPosition - destinationCell).MagnitudeHorizontal() / randomSpeed);

            return(GenSpawn.Spawn(moteThrown, thrower.Position, thrower.Map));
        }
Ejemplo n.º 7
0
        public static void InitGroundShadowGraphic(this ShadowMote SM)
        {
            bool   MyDebug  = SM.MoteSubEffectDebug;
            string debugStr = MyDebug ? "InitGroundShadowGraphic - " : "";

            Tools.Warn("Entering", MyDebug);

            if (SM.HasGroundShadowGraphic)
            {
                Tools.Warn(" already found ground shadow graphic, exiting KO", MyDebug);
                return;
            }

            if (!SM.HasGroundShadowData)
            {
                Tools.Warn(" found no ground shadow data, exiting KO", MyDebug);
                return;
            }

            Tools.Warn(" creating new ground shadow graphic ok", MyDebug);
            SM.GroundShadowGraphic = new Graphic_Shadow(SM.GroundShadowData);
        }