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)); }
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)); }