当前位置: 首页>>代码示例>>C#>>正文


C# IntVec3.ToVector3Shifted方法代码示例

本文整理汇总了C#中IntVec3.ToVector3Shifted方法的典型用法代码示例。如果您正苦于以下问题:C# IntVec3.ToVector3Shifted方法的具体用法?C# IntVec3.ToVector3Shifted怎么用?C# IntVec3.ToVector3Shifted使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IntVec3的用法示例。


在下文中一共展示了IntVec3.ToVector3Shifted方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AllowsPlacing

        /// <summary>
        /// Display the scan range of built mobile mineral sonar and the max scan range at the tested position.
        /// Allow placement nearly anywhere.
        /// </summary>
        public override AcceptanceReport AllowsPlacing(BuildableDef checkingDef, IntVec3 loc, Rot4 rot)
        {
            IEnumerable<Building> mobileMineralSonarList = Find.ListerBuildings.AllBuildingsColonistOfDef(ThingDef.Named("MobileMineralSonar"));

            if (mobileMineralSonarList != null)
            {
                foreach (Building mobileMineralSonar in mobileMineralSonarList)
                {
                    (mobileMineralSonar as Building_MobileMineralSonar).DrawMaxScanRange();
                }
            }

            ResearchProjectDef mmsResearch = ResearchProjectDef.Named("ResearchMobileMineralSonarEnhancedScan");
            if (Find.ResearchManager.GetProgress(mmsResearch) >= mmsResearch.CostApparent)
            {
                Material scanRange30 = MaterialPool.MatFrom("Effects/ScanRange30");
                Vector3 scanRangeScale30 = new Vector3(60f, 1f, 60f);
                Matrix4x4 scanRangeMatrix30 = default(Matrix4x4);
                // The 10f offset on Y axis is mandatory to be over the fog of war.
                scanRangeMatrix30.SetTRS(loc.ToVector3Shifted() + new Vector3(0f, 10f, 0f) + Altitudes.AltIncVect, (0f).ToQuat(), scanRangeScale30);
                Graphics.DrawMesh(MeshPool.plane10, scanRangeMatrix30, scanRange30, 0);
            }
            else
            {
                Material scanRange50 = MaterialPool.MatFrom("Effects/ScanRange50");
                Vector3 scanRangeScale50 = new Vector3(100f, 1f, 100f);
                Matrix4x4 scanRangeMatrix50 = default(Matrix4x4);
                // The 10f offset on Y axis is mandatory to be over the fog of war.
                scanRangeMatrix50.SetTRS(loc.ToVector3Shifted() + new Vector3(0f, 10f, 0f) + Altitudes.AltIncVect, (0f).ToQuat(), scanRangeScale50);
                Graphics.DrawMesh(MeshPool.plane10, scanRangeMatrix50, scanRange50, 0);
            }

            return true;
        }
开发者ID:Rikiki123456789,项目名称:Rimworld,代码行数:38,代码来源:PlaceWorker_MobileMineralSonar.cs

示例2: CheckForFreeIntercept

        //Added collision detection for cover objects, changed pawn collateral chances
        private bool CheckForFreeIntercept(IntVec3 cell)
        {
            //Check for minimum collision distance
            float distFromOrigin = (cell.ToVector3Shifted() - this.origin).MagnitudeHorizontal();
            float distToTarget = this.assignedTarget != null ? (this.assignedTarget.DrawPos - this.origin).MagnitudeHorizontal() : (this.destination - this.origin).MagnitudeHorizontal();
            if (!this.def.projectile.alwaysFreeIntercept
                && distToTarget <= 1f ? distFromOrigin < 1f : distFromOrigin < Mathf.Min(12f, distToTarget / 2))
            {
                return false;
            }
            List<Thing> mainThingList = new List<Thing>(Find.ThingGrid.ThingsListAt(cell));

            //Find pawns in adjacent cells and append them to main list
            List<IntVec3> adjList = new List<IntVec3>();
            Vector3 shotVec = (this.destination - this.origin).normalized;

            //Check if bullet is going north-south or west-east
            if (Math.Abs(shotVec.x) < Math.Abs(shotVec.z))
            {
                adjList = GenAdj.CellsAdjacentCardinal(cell, this.Rotation, new IntVec2(0,1)).ToList<IntVec3>();
            }
            else
            {
                adjList = GenAdj.CellsAdjacentCardinal(cell, this.Rotation, new IntVec2(1, 0)).ToList<IntVec3>();
            }

            //Iterate through adjacent cells and find all the pawns
            for (int i = 0; i < adjList.Count; i++)
            {
                if (adjList[i].InBounds() && !adjList[i].Equals(cell))
                {
                    List<Thing> thingList = new List<Thing>(Find.ThingGrid.ThingsListAt(adjList[i]));
                    var pawns = thingList.Where(thing => thing.def.category == ThingCategory.Pawn && !mainThingList.Contains(thing)).ToList();
                    mainThingList.AddRange(pawns);
                }
            }

            //Check for entries first so we avoid doing costly height calculations
            if (mainThingList.Count > 0)
            {
                float height = GetProjectileHeight(this.shotHeight, this.distanceFromOrigin, this.shotAngle, this.shotSpeed);
                for (int i = 0; i < mainThingList.Count; i++)
                {
                    Thing thing = mainThingList[i];
                    if (thing.def.Fillage == FillCategory.Full)	//ignore height
                    {
                        this.Impact(thing);
                        return true;
                    }
                    //Check for trees		--		HARDCODED RNG IN HERE
                    if (thing.def.category == ThingCategory.Plant && thing.def.altitudeLayer == AltitudeLayer.BuildingTall && Rand.Value < thing.def.fillPercent * Mathf.Clamp(distFromOrigin / 40, 0f, 1f))
                    {
                        this.Impact(thing);
                        return true;
                    }
                    //Checking for pawns/cover
                    else if (thing.def.category == ThingCategory.Pawn || (this.ticksToImpact < this.StartingTicksToImpact / 2 && thing.def.fillPercent > 0)) //Need to check for fillPercent here or else will be impacting things like motes, etc.
                    {
                        return this.ImpactThroughBodySize(thing, height);
                    }
                }
            }
            return false;
        }
开发者ID:RimWorldMod,项目名称:CombatRealism,代码行数:65,代码来源:ProjectileCR.cs

示例3: CanHitTargetFrom

 /// <summary>
 /// Checks if the shooter can hit the target from a certain position with regards to cover height
 /// </summary>
 public override bool CanHitTargetFrom(IntVec3 root, TargetInfo targ)
 {
     if (base.CanHitTargetFrom(root, targ))
     {
         //Check if target is obstructed behind cover
         Thing coverTarg;
         if (this.GetPartialCoverBetween(root.ToVector3Shifted(), targ.Cell.ToVector3Shifted(), out coverTarg))
         {
             float targetHeight = Utility.GetCollisionHeight(targ.Thing);
             if (targetHeight <= Utility.GetCollisionHeight(coverTarg))
             {
                 return false;
             }
         }
         //Check if shooter is obstructed by cover
         Thing coverShoot;
         if (this.GetPartialCoverBetween(targ.Cell.ToVector3Shifted(), root.ToVector3Shifted(), out coverShoot))
         {
             float shotHeight = Utility.GetCollisionHeight(this.caster);
             Pawn casterPawn = this.caster as Pawn;
             if (casterPawn != null)
             {
                 shotHeight *= shotHeightFactor;
             }
             if (shotHeight <= Utility.GetCollisionHeight(coverShoot))
             {
                 return false;
             }
         }
         return true;
     }
     return false;
 }
开发者ID:RimWorldMod,项目名称:CombatRealism,代码行数:36,代码来源:Verb_ShootCR.cs

示例4: ThrowBubble

 /// <summary>
 /// Throw a bubble.
 /// </summary>
 public static Mote ThrowBubble(IntVec3 cell)
 {
     if (!cell.ShouldSpawnMotesAt())
     {
         return null;
     }
     MoteThrown moteThrown = (MoteThrown)ThingMaker.MakeThing(Util_FishIndustry.MoteBubbleDef, null);
     moteThrown.Scale = 0.3f;
     moteThrown.rotationRate = Rand.Range(-0.15f, 0.15f);
     moteThrown.exactPosition = cell.ToVector3Shifted();
     moteThrown.SetVelocity((float)Rand.Range(-30, 30), 0.33f);
     GenSpawn.Spawn(moteThrown, cell);
     return moteThrown;
 }
开发者ID:Rikiki123456789,项目名称:Rimworld,代码行数:17,代码来源:Building_AquacultureBasin.cs


注:本文中的IntVec3.ToVector3Shifted方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。