protected override void TimeInterval(float deltaTime) { base.TimeInterval(deltaTime); if (base.Destroyed || (!Flying && !Skidding)) { return; } Vector3 vector = NextExactPosition(deltaTime); IntVec3 intVec = new IntVec3(vector); if (intVec != base.Position) { if (!intVec.InBounds(base.Map)) { Destroy(); return; } if (def.mote.collide && intVec.Filled(base.Map)) { WallHit(); return; } } base.Position = intVec; exactPosition = vector; if (def.mote.rotateTowardsMoveDirection && velocity != default(Vector3)) { exactRotation = velocity.AngleFlat(); } else { exactRotation += rotationRate * deltaTime; } velocity += def.mote.acceleration * deltaTime; if (def.mote.speedPerTime != 0f) { Speed = Mathf.Max(Speed + def.mote.speedPerTime * deltaTime, 0f); } if (airTimeLeft > 0f) { airTimeLeft -= deltaTime; if (airTimeLeft < 0f) { airTimeLeft = 0f; } if (airTimeLeft <= 0f && !def.mote.landSound.NullOrUndefined()) { def.mote.landSound.PlayOneShot(new TargetInfo(base.Position, base.Map)); } } if (Skidding) { Speed *= skidSpeedMultiplierPerTick; rotationRate *= skidSpeedMultiplierPerTick; if (Speed < 0.02f) { Speed = 0f; } } }
protected override void TimeInterval(float deltaTime) { base.TimeInterval(deltaTime); if (base.Destroyed) { return; } if (!this.Flying && !this.Skidding) { return; } Vector3 vector = this.NextExactPosition(deltaTime); IntVec3 intVec = new IntVec3(vector); if (intVec != base.Position) { if (!intVec.InBounds(base.Map)) { this.Destroy(DestroyMode.Vanish); return; } if (this.def.mote.collide && intVec.Filled(base.Map)) { this.WallHit(); return; } } base.Position = intVec; this.exactPosition = vector; this.exactRotation += this.rotationRate * deltaTime; this.velocity += this.def.mote.acceleration * deltaTime; if (this.def.mote.speedPerTime != 0f) { this.Speed = Mathf.Max(this.Speed + this.def.mote.speedPerTime * deltaTime, 0f); } if (this.airTimeLeft > 0f) { this.airTimeLeft -= deltaTime; if (this.airTimeLeft < 0f) { this.airTimeLeft = 0f; } if (this.airTimeLeft <= 0f && !this.def.mote.landSound.NullOrUndefined()) { this.def.mote.landSound.PlayOneShot(new TargetInfo(base.Position, base.Map, false)); } } if (this.Skidding) { this.Speed *= this.skidSpeedMultiplierPerTick; this.rotationRate *= this.skidSpeedMultiplierPerTick; if (this.Speed < 0.02f) { this.Speed = 0f; } } }
private bool CellBoolDrawerGetBoolInt(int index) { IntVec3 c = CellIndicesUtility.IndexToCell(index, map.Size.x); if (c.Filled(map) || c.Fogged(map)) { return(false); } TerrainAffordanceDef affordance; return(TryGetAffordanceDefToDraw(TerrainAt(index), out affordance)); }
public override void Regenerate() { base.ClearSubMeshes(MeshParts.All); this.scats.RemoveAll((SectionLayer_TerrainScatter.Scatterable scat) => !scat.IsOnValidTerrain); int num = 0; TerrainDef[] topGrid = base.Map.terrainGrid.topGrid; CellRect cellRect = this.section.CellRect; CellIndices cellIndices = base.Map.cellIndices; for (int i = cellRect.minZ; i <= cellRect.maxZ; i++) { for (int j = cellRect.minX; j <= cellRect.maxX; j++) { if (topGrid[cellIndices.CellToIndex(j, i)].scatterType != null) { num++; } } } num /= 40; int num2 = 0; while (this.scats.Count < num && num2 < 200) { num2++; IntVec3 randomCell = this.section.CellRect.RandomCell; string terrScatType = base.Map.terrainGrid.TerrainAt(randomCell).scatterType; if (terrScatType != null && !randomCell.Filled(base.Map)) { ScatterableDef def2; if ((from def in DefDatabase <ScatterableDef> .AllDefs where def.scatterType == terrScatType select def).TryRandomElement(out def2)) { Vector3 loc = new Vector3((float)randomCell.x + Rand.Value, (float)randomCell.y, (float)randomCell.z + Rand.Value); SectionLayer_TerrainScatter.Scatterable scatterable = new SectionLayer_TerrainScatter.Scatterable(def2, loc, base.Map); this.scats.Add(scatterable); scatterable.PrintOnto(this); } } } for (int k = 0; k < this.scats.Count; k++) { this.scats[k].PrintOnto(this); } base.FinalizeMesh(MeshParts.All); }
public override void Regenerate() { ClearSubMeshes(MeshParts.All); scats.RemoveAll((Scatterable scat) => !scat.IsOnValidTerrain); int num = 0; TerrainDef[] topGrid = base.Map.terrainGrid.topGrid; CellRect cellRect = section.CellRect; CellIndices cellIndices = base.Map.cellIndices; for (int i = cellRect.minZ; i <= cellRect.maxZ; i++) { for (int j = cellRect.minX; j <= cellRect.maxX; j++) { if (topGrid[cellIndices.CellToIndex(j, i)].scatterType != null) { num++; } } } num /= 40; int num2 = 0; while (scats.Count < num && num2 < 200) { num2++; IntVec3 randomCell = section.CellRect.RandomCell; string terrScatType = base.Map.terrainGrid.TerrainAt(randomCell).scatterType; if (terrScatType != null && !randomCell.Filled(base.Map) && DefDatabase <ScatterableDef> .AllDefs.Where((ScatterableDef def) => def.scatterType == terrScatType).TryRandomElement(out var result)) { Scatterable scatterable = new Scatterable(loc: new Vector3((float)randomCell.x + Rand.Value, randomCell.y, (float)randomCell.z + Rand.Value), def: result, map: base.Map); scats.Add(scatterable); scatterable.PrintOnto(this); } } for (int k = 0; k < scats.Count; k++) { scats[k].PrintOnto(this); } FinalizeMesh(MeshParts.All); }