public override void Update() { int value = m_subsystemTerrain.Terrain.GetCellValue(m_componentBlockEntity.Coordinates.X, m_componentBlockEntity.Coordinates.Y, m_componentBlockEntity.Coordinates.Z); int data = Terrain.ExtractData(value); if (m_dispenseButton.IsClicked) { data = DispenserBlock.SetMode(data, DispenserBlock.Mode.Dispense); value = Terrain.ReplaceData(value, data); m_subsystemTerrain.ChangeCell(m_componentBlockEntity.Coordinates.X, m_componentBlockEntity.Coordinates.Y, m_componentBlockEntity.Coordinates.Z, value); } if (m_shootButton.IsClicked) { data = DispenserBlock.SetMode(data, DispenserBlock.Mode.Shoot); value = Terrain.ReplaceData(value, data); m_subsystemTerrain.ChangeCell(m_componentBlockEntity.Coordinates.X, m_componentBlockEntity.Coordinates.Y, m_componentBlockEntity.Coordinates.Z, value); } if (m_acceptsDropsBox.IsClicked) { data = DispenserBlock.SetAcceptsDrops(data, !DispenserBlock.GetAcceptsDrops(data)); value = Terrain.ReplaceData(value, data); m_subsystemTerrain.ChangeCell(m_componentBlockEntity.Coordinates.X, m_componentBlockEntity.Coordinates.Y, m_componentBlockEntity.Coordinates.Z, value); } DispenserBlock.Mode mode = DispenserBlock.GetMode(data); m_dispenseButton.IsChecked = (mode == DispenserBlock.Mode.Dispense); m_shootButton.IsChecked = (mode == DispenserBlock.Mode.Shoot); m_acceptsDropsBox.IsChecked = DispenserBlock.GetAcceptsDrops(data); if (!m_componentDispenser.IsAddedToProject) { base.ParentWidget.Children.Remove(this); } }
public override IEnumerable <CraftingRecipe> GetProceduralCraftingRecipes() { int isDead = 0; while (isDead <= 1) { int num; for (int rot = 0; rot <= 1; rot = num) { CraftingRecipe craftingRecipe = new CraftingRecipe { ResultCount = 1, ResultValue = 251, RequiredHeatLevel = 1f, Description = "еКБ©до╧ожЮ" }; int data = BasePumpkinBlock.SetIsDead(BasePumpkinBlock.SetSize(0, 7), isDead != 0); int value = SetDamage(Terrain.MakeBlockValue(131, 0, data), rot); craftingRecipe.Ingredients[0] = "pumpkin:" + Terrain.ExtractData(value).ToString(CultureInfo.InvariantCulture); craftingRecipe.Ingredients[1] = "waterbucket"; yield return(craftingRecipe); num = rot + 1; } num = isDead + 1; isDead = num; } }
public override int SetDamage(int value, int damage) { int num = Terrain.ExtractData(value); num = ((num & -3841) | ((damage & 0xF) << 8)); return(Terrain.ReplaceData(value, num)); }
public override void OnNeighborBlockChanged(int x, int y, int z, int neighborX, int neighborY, int neighborZ) { int cellValue = base.SubsystemTerrain.Terrain.GetCellValue(x, y, z); int num = Terrain.ExtractContents(cellValue); Block obj = BlocksManager.Blocks[num]; int data = Terrain.ExtractData(cellValue); if (obj is TrapdoorBlock) { int rotation = TrapdoorBlock.GetRotation(data); bool upsideDown = TrapdoorBlock.GetUpsideDown(data); bool flag = false; Point3 point = CellFace.FaceToPoint3(rotation); int cellContents = base.SubsystemTerrain.Terrain.GetCellContents(x - point.X, y - point.Y, z - point.Z); flag |= !BlocksManager.Blocks[cellContents].IsTransparent; if (upsideDown) { int cellContents2 = base.SubsystemTerrain.Terrain.GetCellContents(x, y + 1, z); flag |= !BlocksManager.Blocks[cellContents2].IsTransparent; int cellContents3 = base.SubsystemTerrain.Terrain.GetCellContents(x - point.X, y - point.Y + 1, z - point.Z); flag |= !BlocksManager.Blocks[cellContents3].IsTransparent; } else { int cellContents4 = base.SubsystemTerrain.Terrain.GetCellContents(x, y - 1, z); flag |= !BlocksManager.Blocks[cellContents4].IsTransparent; int cellContents5 = base.SubsystemTerrain.Terrain.GetCellContents(x - point.X, y - point.Y - 1, z - point.Z); flag |= !BlocksManager.Blocks[cellContents5].IsTransparent; } if (!flag) { base.SubsystemTerrain.DestroyCell(0, x, y, z, 0, noDrop: false, noParticleSystem: false); } } }
public override void DrawBlock(PrimitivesRenderer3D primitivesRenderer, int value, Color color, float size, ref Matrix matrix, DrawBlockEnvironmentData environmentData) { int data = Terrain.ExtractData(value); color *= SubsystemPalette.GetFabricColor(environmentData, GetColor(data)); BlocksManager.DrawCubeBlock(primitivesRenderer, value, new Vector3(size, 0.0625f * size, size), ref matrix, color, color, environmentData); }
public override void OnCollide(CellFace cellFace, float velocity, ComponentBody componentBody) { int data = Terrain.ExtractData(base.SubsystemTerrain.Terrain.GetCellValue(cellFace.X, cellFace.Y, cellFace.Z)); if (!SpikedPlankBlock.GetSpikesState(data)) { return; } int mountingFace = SpikedPlankBlock.GetMountingFace(data); if (cellFace.Face != mountingFace) { return; } ComponentCreature componentCreature = componentBody.Entity.FindComponent <ComponentCreature>(); if (componentCreature != null) { m_lastInjuryTimes.TryGetValue(componentCreature, out double value); if (m_subsystemTime.GameTime - value > 1.0) { m_lastInjuryTimes[componentCreature] = m_subsystemTime.GameTime; componentCreature.ComponentHealth.Injure(0.1f, null, ignoreInvulnerability: false, "Spiked by a trap"); } } }
public override void GenerateTerrainVertices(BlockGeometryGenerator generator, TerrainGeometry geometry, int value, int x, int y, int z) { int num = Terrain.ExtractData(value) & 0x1F; generator.GenerateMeshVertices(this, x, y, z, m_blockMeshes[num], Color.White, null, geometry.SubsetOpaque); generator.GenerateWireVertices(value, x, y, z, GetFace(value), m_centerBoxSize, Vector2.Zero, geometry.SubsetOpaque); }
public override bool OnEditInventoryItem(IInventory inventory, int slotIndex, ComponentPlayer componentPlayer) { int value1 = inventory.GetSlotValue(slotIndex); int count = inventory.GetSlotCount(slotIndex); int id = Terrain.ExtractData(value1); var commandBlockData = GetItemData(id); if (commandBlockData != null) { commandBlockData = (CommandData)commandBlockData.Copy(); } else { commandBlockData = new CommandData(); } DialogsManager.ShowDialog(componentPlayer.View.GameWidget, new TextBoxDialog("enter a one-line command", commandBlockData.Command, 300, delegate(string result) { commandBlockData.Command = result; var data = StoreItemDataAtUniqueId(commandBlockData); var value = Terrain.ReplaceData(value1, data); inventory.RemoveSlotItems(slotIndex, count); inventory.AddSlotItems(slotIndex, value, 1); })); return(true); }
public override void Update() { int slotValue = m_inventory.GetSlotValue(m_slotIndex); int slotCount = m_inventory.GetSlotCount(m_slotIndex); if (Terrain.ExtractContents(slotValue) == 212 && slotCount > 0) { switch (MusketBlock.GetLoadState(Terrain.ExtractData(slotValue))) { case MusketBlock.LoadState.Empty: m_instructionsLabel.Text = "Load gunpowder"; break; case MusketBlock.LoadState.Gunpowder: m_instructionsLabel.Text = "Load cotton wad"; break; case MusketBlock.LoadState.Wad: m_instructionsLabel.Text = "Load bullet"; break; case MusketBlock.LoadState.Loaded: m_instructionsLabel.Text = "Ready to fire"; break; default: m_instructionsLabel.Text = string.Empty; break; } } else { base.ParentWidget.Children.Remove(this); } }
public override string GetDisplayName(SubsystemTerrain subsystemTerrain, int value) { int data = Terrain.ExtractData(value); int color = GetColor(data); return(LanguageControl.Get("LedBlock", color) + LanguageControl.GetBlock(string.Format("{0}:{1}", GetType().Name, data.ToString()), "DisplayName")); }
public override bool Simulate() { int num = base.SubsystemElectricity.CircuitStep - m_lastChangeCircuitStep; float num2 = 0f; foreach (ElectricConnection connection in base.Connections) { if (connection.ConnectorType != ElectricConnectorType.Output && connection.NeighborConnectorType != 0) { num2 = MathUtils.Max(num2, connection.NeighborElectricElement.GetOutputVoltage(connection.NeighborConnectorFace)); } } int intensity = m_intensity; m_intensity = MathUtils.Clamp((int)MathUtils.Round((num2 - 0.5f) * 30f), 0, 15); if (m_intensity != intensity) { m_lastChangeCircuitStep = base.SubsystemElectricity.CircuitStep; } if (num >= 10) { CellFace cellFace = base.CellFaces[0]; int cellValue = base.SubsystemElectricity.SubsystemTerrain.Terrain.GetCellValue(cellFace.X, cellFace.Y, cellFace.Z); int data = LightbulbBlock.SetLightIntensity(Terrain.ExtractData(cellValue), m_intensity); int value = Terrain.ReplaceData(cellValue, data); base.SubsystemElectricity.SubsystemTerrain.ChangeCell(cellFace.X, cellFace.Y, cellFace.Z, value); } else { base.SubsystemElectricity.QueueElectricElementForSimulation(this, base.SubsystemElectricity.CircuitStep + 10 - num); } return(false); }
protected string FindSmeltingRecipe(float heatLevel) { if (heatLevel < 100f) { return(null); } string text = null; for (int i = 0; i < m_furnaceSize; i++) { int slotValue = GetSlotValue(i); int num = Terrain.ExtractContents(slotValue); int num2 = Terrain.ExtractData(slotValue); if (GetSlotCount(i) > 0) { if (num == WaterBucketBlock.Index) { text = "bucket"; } } } if (text != null) { Slot slot = m_slots[ResultSlotIndex]; if (slot.Count != 0 && (90 != slot.Value || slot.Count >= 40)) { text = null; } } return(text); }
public bool IsCollapseSupportBlock(int value) { int num = Terrain.ExtractContents(value); if (num != 0) { int data = Terrain.ExtractData(value); Block block = BlocksManager.Blocks[num]; if (block is TrapdoorBlock) { if (TrapdoorBlock.GetUpsideDown(data)) { return(!TrapdoorBlock.GetOpen(data)); } return(false); } if (block.BlockIndex == 238) { return(true); } if (block.IsFaceTransparent(base.SubsystemTerrain, 4, value)) { return(block is SoilBlock); } return(true); } return(false); }
public void Dispense() { Point3 coordinates = m_componentBlockEntity.Coordinates; int data = Terrain.ExtractData(m_subsystemTerrain.Terrain.GetCellValue(coordinates.X, coordinates.Y, coordinates.Z)); int direction = DispenserBlock.GetDirection(data); DispenserBlock.Mode mode = DispenserBlock.GetMode(data); int num = 0; int slotValue; while (true) { if (num < SlotsCount) { slotValue = GetSlotValue(num); int slotCount = GetSlotCount(num); if (slotValue != 0 && slotCount > 0) { break; } num++; continue; } return; } int num2 = RemoveSlotItems(num, 1); for (int i = 0; i < num2; i++) { DispenseItem(coordinates, direction, slotValue, mode); } }
public override bool OnHitAsProjectile(CellFace?cellFace, ComponentBody componentBody, WorldItem worldItem) { BulletBlock.BulletType bulletType = BulletBlock.GetBulletType(Terrain.ExtractData(worldItem.Value)); bool result = true; if (cellFace.HasValue) { int cellValue = m_subsystemTerrain.Terrain.GetCellValue(cellFace.Value.X, cellFace.Value.Y, cellFace.Value.Z); int num = Terrain.ExtractContents(cellValue); Block obj = BlocksManager.Blocks[num]; if (worldItem.Velocity.Length() > 30f) { m_subsystemExplosions.TryExplodeBlock(cellFace.Value.X, cellFace.Value.Y, cellFace.Value.Z, cellValue); } if (obj.Density >= 1.5f && worldItem.Velocity.Length() > 30f) { float num2 = 1f; float minDistance = 8f; if (bulletType == BulletBlock.BulletType.BuckshotBall) { num2 = 0.25f; minDistance = 4f; } if (m_random.Float(0f, 1f) < num2) { m_subsystemAudio.PlayRandomSound("Audio/Ricochets", 1f, m_random.Float(-0.2f, 0.2f), new Vector3(cellFace.Value.X, cellFace.Value.Y, cellFace.Value.Z), minDistance, autoDelay: true); result = false; } } } return(result); }
public void GarbageCollectItems(ReadOnlyList <ScannedItemData> allExistingItems) { HashSet <int> hashSet = new HashSet <int>(); foreach (ScannedItemData item in allExistingItems) { if (Terrain.ExtractContents(item.Value) == m_contents) { hashSet.Add(Terrain.ExtractData(item.Value)); } } List <int> list = new List <int>(); foreach (KeyValuePair <int, T> itemsDatum in m_itemsData) { if (!hashSet.Contains(itemsDatum.Key)) { list.Add(itemsDatum.Key); } } foreach (int item2 in list) { m_itemsData.Remove(item2); } }
public override bool OnUse(Ray3 ray, ComponentMiner componentMiner) { TerrainRaycastResult?terrainRaycastResult = componentMiner.Raycast <TerrainRaycastResult>(ray, RaycastMode.Interaction); if (terrainRaycastResult.HasValue && terrainRaycastResult.Value.CellFace.Face == 4) { int y = terrainRaycastResult.Value.CellFace.Y; for (int i = terrainRaycastResult.Value.CellFace.X - 1; i <= terrainRaycastResult.Value.CellFace.X + 1; i++) { for (int j = terrainRaycastResult.Value.CellFace.Z - 1; j <= terrainRaycastResult.Value.CellFace.Z + 1; j++) { int cellValue = m_subsystemTerrain.Terrain.GetCellValue(i, y, j); if (Terrain.ExtractContents(cellValue) == 168) { int data = SoilBlock.SetNitrogen(Terrain.ExtractData(cellValue), 3); int value = Terrain.ReplaceData(cellValue, data); m_subsystemTerrain.ChangeCell(i, y, j, value); } } } m_subsystemAudio.PlayRandomSound("Audio/Impacts/Dirt", 0.5f, 0f, new Vector3(terrainRaycastResult.Value.CellFace.X, terrainRaycastResult.Value.CellFace.Y, terrainRaycastResult.Value.CellFace.Z), 3f, autoDelay: true); Vector3 position = new Vector3((float)terrainRaycastResult.Value.CellFace.X + 0.5f, (float)terrainRaycastResult.Value.CellFace.Y + 1.5f, (float)terrainRaycastResult.Value.CellFace.Z + 0.5f); Block block = BlocksManager.Blocks[Terrain.ExtractContents(componentMiner.ActiveBlockValue)]; m_subsystemParticles.AddParticleSystem(block.CreateDebrisParticleSystem(m_subsystemTerrain, position, componentMiner.ActiveBlockValue, 1.25f)); componentMiner.RemoveActiveTool(1); return(true); } return(false); }
public override void OnNeighborBlockChanged(int x, int y, int z, int neighborX, int neighborY, int neighborZ) { int cellValueFast = base.SubsystemTerrain.Terrain.GetCellValueFast(x, y, z); int num = Terrain.ExtractContents(cellValueFast); int data = Terrain.ExtractData(cellValueFast); Block block = BlocksManager.Blocks[num]; if (block is AttachedSignBlock) { Point3 point = CellFace.FaceToPoint3(AttachedSignBlock.GetFace(data)); int x2 = x - point.X; int y2 = y - point.Y; int z2 = z - point.Z; int cellContents = base.SubsystemTerrain.Terrain.GetCellContents(x2, y2, z2); if (!BlocksManager.Blocks[cellContents].IsCollidable) { base.SubsystemTerrain.DestroyCell(0, x, y, z, 0, noDrop: false, noParticleSystem: false); } } else if (block is PostedSignBlock) { int num2 = PostedSignBlock.GetHanging(data) ? base.SubsystemTerrain.Terrain.GetCellContents(x, y + 1, z) : base.SubsystemTerrain.Terrain.GetCellContents(x, y - 1, z); if (!BlocksManager.Blocks[num2].IsCollidable) { base.SubsystemTerrain.DestroyCell(0, x, y, z, 0, noDrop: false, noParticleSystem: false); } } }
public override void OnAdded() { CellFace cellFace = base.CellFaces[0]; int data = Terrain.ExtractData(base.SubsystemElectricity.SubsystemTerrain.Terrain.GetCellValue(cellFace.X, cellFace.Y, cellFace.Z)); int mountingFace = FourLedBlock.GetMountingFace(data); m_color = LedBlock.LedColors[FourLedBlock.GetColor(data)]; for (int i = 0; i < 4; i++) { int num = (i % 2 == 0) ? 1 : (-1); int num2 = (i / 2 == 0) ? 1 : (-1); Vector3 v = new Vector3((float)cellFace.X + 0.5f, (float)cellFace.Y + 0.5f, (float)cellFace.Z + 0.5f); Vector3 vector = CellFace.FaceToVector3(mountingFace); Vector3 vector2 = (mountingFace < 4) ? Vector3.UnitY : Vector3.UnitX; Vector3 vector3 = Vector3.Cross(vector, vector2); m_glowPoints[i] = m_subsystemGlow.AddGlowPoint(); m_glowPoints[i].Position = v - 0.4375f * CellFace.FaceToVector3(mountingFace) + 0.25f * vector3 * num + 0.25f * vector2 * num2; m_glowPoints[i].Forward = vector; m_glowPoints[i].Up = vector2; m_glowPoints[i].Right = vector3; m_glowPoints[i].Color = Color.Transparent; m_glowPoints[i].Size = 0.26f; m_glowPoints[i].FarSize = 0.26f; m_glowPoints[i].FarDistance = 1f; m_glowPoints[i].Type = GlowPointType.Square; } }
public override void DrawBlock(PrimitivesRenderer3D primitivesRenderer, int value, Color color, float size, ref Matrix matrix, DrawBlockEnvironmentData environmentData) { int bulletType = (int)GetBulletType(Terrain.ExtractData(value)); float size2 = (bulletType >= 0 && bulletType < m_sizes.Length) ? (size * m_sizes[bulletType]) : size; BlocksManager.DrawFlatBlock(primitivesRenderer, value, size2, ref matrix, null, color, isEmissive: false, environmentData); }
public void Update(float dt) { if (m_subsystemTime.PeriodicGameTimeEvent(2.5, 0.0)) { foreach (Point3 key2 in m_toDegrade.Keys) { if (base.SubsystemTerrain.Terrain.GetCellContents(key2.X, key2.Y, key2.Z) == 168) { int cellValue = base.SubsystemTerrain.Terrain.GetCellValue(key2.X, key2.Y, key2.Z); base.SubsystemTerrain.ChangeCell(key2.X, key2.Y, key2.Z, Terrain.ReplaceContents(cellValue, 2)); } } m_toDegrade.Clear(); } if (m_subsystemTime.PeriodicGameTimeEvent(10.0, 0.0)) { foreach (KeyValuePair <Point3, bool> item in m_toHydrate) { Point3 key = item.Key; bool value = item.Value; int cellValue2 = base.SubsystemTerrain.Terrain.GetCellValue(key.X, key.Y, key.Z); if (Terrain.ExtractContents(cellValue2) == 168) { int data = SoilBlock.SetHydration(Terrain.ExtractData(cellValue2), value); int value2 = Terrain.ReplaceData(cellValue2, data); base.SubsystemTerrain.ChangeCell(key.X, key.Y, key.Z, value2); } } m_toHydrate.Clear(); } }
public bool AddFuel(int x, int y, int z, int value, int count) { if (Terrain.ExtractData(base.SubsystemTerrain.Terrain.GetCellValue(x, y, z)) > 0) { int num = Terrain.ExtractContents(value); Block block = BlocksManager.Blocks[num]; if (base.Project.FindSubsystem <SubsystemExplosions>(throwOnError: true).TryExplodeBlock(x, y, z, value)) { return(true); } if (block is SnowBlock || block is SnowballBlock || block is IceBlock) { return(ResizeCampfire(x, y, z, -1, playSound: true)); } if (block.FuelHeatLevel > 0f) { float num2 = (float)count * MathUtils.Min(block.FuelFireDuration, 20f) / 5f; int num3 = (int)num2; float num4 = num2 - (float)num3; if (m_random.Float(0f, 1f) < num4) { num3++; } if (num3 > 0) { return(ResizeCampfire(x, y, z, num3, playSound: true)); } return(true); } } return(false); }
public override void GenerateTerrainVertices(BlockGeometryGenerator generator, TerrainGeometry geometry, int value, int x, int y, int z) { int data = Terrain.ExtractData(value); Color fabricColor = SubsystemPalette.GetFabricColor(generator, GetColor(data)); generator.GenerateCubeVertices(this, value, x, y, z, 0.0625f, 0.0625f, 0.0625f, 0.0625f, fabricColor, fabricColor, fabricColor, fabricColor, fabricColor, -1, geometry.OpaqueSubsetsByFace); }
public bool ResizeCampfire(int x, int y, int z, int steps, bool playSound) { int cellValue = base.SubsystemTerrain.Terrain.GetCellValue(x, y, z); int num = Terrain.ExtractData(cellValue); if (num > 0) { int num2 = MathUtils.Clamp(num + steps, 0, 15); if (num2 != num) { int value = Terrain.ReplaceData(cellValue, num2); base.SubsystemTerrain.ChangeCell(x, y, z, value); if (playSound) { if (steps >= 0) { m_subsystemAmbientSounds.SubsystemAudio.PlaySound("Audio/BlockPlaced", 1f, 0f, new Vector3(x, y, z), 3f, autoDelay: false); } else { m_subsystemAmbientSounds.SubsystemAudio.PlayRandomSound("Audio/Sizzles", 1f, 0f, new Vector3(x, y, z), 3f, autoDelay: true); } } return(true); } } return(false); }
public override BlockDebrisParticleSystem CreateDebrisParticleSystem(SubsystemTerrain subsystemTerrain, Vector3 position, int value, float strength) { int data = Terrain.ExtractData(value); Color fabricColor = SubsystemPalette.GetFabricColor(subsystemTerrain, GetColor(data)); return(new BlockDebrisParticleSystem(subsystemTerrain, position, strength, DestructionDebrisScale, fabricColor, DefaultTextureSlot)); }
public override BlockPlacementData GetPlacementValue(SubsystemTerrain subsystemTerrain, ComponentMiner componentMiner, int value, TerrainRaycastResult raycastResult) { int num = Terrain.ExtractContents(value); int data = Terrain.ExtractData(value); int num2 = Terrain.ExtractContents(raycastResult.Value); int data2 = Terrain.ExtractData(raycastResult.Value); BlockPlacementData result; if (num2 == num && ((GetIsTop(data2) && raycastResult.CellFace.Face == 5) || (!GetIsTop(data2) && raycastResult.CellFace.Face == 4))) { int value2 = Terrain.MakeBlockValue(m_fullBlockIndex, 0, 0); IPaintableBlock paintableBlock = BlocksManager.Blocks[m_fullBlockIndex] as IPaintableBlock; if (paintableBlock != null) { int?color = GetColor(data); value2 = paintableBlock.Paint(subsystemTerrain, value2, color); } CellFace cellFace = raycastResult.CellFace; cellFace.Point -= CellFace.FaceToPoint3(cellFace.Face); result = default(BlockPlacementData); result.Value = value2; result.CellFace = cellFace; return(result); } bool isTop = (raycastResult.CellFace.Face >= 4) ? (raycastResult.CellFace.Face == 5) : (raycastResult.HitPoint().Y - (float)raycastResult.CellFace.Y > 0.5f); result = default(BlockPlacementData); result.Value = Terrain.MakeBlockValue(BlockIndex, 0, SetIsTop(data, isTop)); result.CellFace = raycastResult.CellFace; return(result); }
public float?GetSurfaceHeight(int x, int y, int z, out FluidBlock surfaceFluidBlock) { if (y >= 0 && y < 255) { TerrainChunk chunkAtCell = base.SubsystemTerrain.Terrain.GetChunkAtCell(x, z); if (chunkAtCell != null) { int num = TerrainChunk.CalculateCellIndex(x & 0xF, 0, z & 0xF); while (y < 255) { int num2 = Terrain.ExtractContents(chunkAtCell.GetCellValueFast(num + y + 1)); if (BlocksManager.FluidBlocks[num2] == null) { int cellValueFast = chunkAtCell.GetCellValueFast(num + y); int num3 = Terrain.ExtractContents(cellValueFast); FluidBlock fluidBlock = BlocksManager.FluidBlocks[num3]; if (fluidBlock != null) { surfaceFluidBlock = fluidBlock; int level = FluidBlock.GetLevel(Terrain.ExtractData(cellValueFast)); return((float)y + surfaceFluidBlock.GetLevelHeight(level)); } surfaceFluidBlock = null; return(null); } y++; } } } surfaceFluidBlock = null; return(null); }
public void MovingBlocksCollidedWithTerrain(IMovingBlockSet movingBlockSet, Point3 p) { if (!(movingBlockSet.Id == "Piston")) { return; } Point3 point = (Point3)movingBlockSet.Tag; int cellValue = m_subsystemTerrain.Terrain.GetCellValue(point.X, point.Y, point.Z); if (Terrain.ExtractContents(cellValue) != 237) { return; } Point3 point2 = CellFace.FaceToPoint3(PistonBlock.GetFace(Terrain.ExtractData(cellValue))); int num = p.X * point2.X + p.Y * point2.Y + p.Z * point2.Z; int num2 = point.X * point2.X + point.Y * point2.Y + point.Z * point2.Z; if (num > num2) { if (IsBlockBlocking(base.SubsystemTerrain.Terrain.GetCellValue(p.X, p.Y, p.Z))) { movingBlockSet.Stop(); } else { base.SubsystemTerrain.DestroyCell(0, p.X, p.Y, p.Z, 0, noDrop: false, noParticleSystem: false); } } }
public void Dispense() { Point3 coordinates = m_componentBlockEntity.Coordinates; int data = Terrain.ExtractData(Utils.Terrain.GetCellValue(coordinates.X, coordinates.Y, coordinates.Z)); int direction = FourDirectionalBlock.GetDirection(Utils.Terrain.GetCellValue(coordinates.X, coordinates.Y, coordinates.Z)); Driller(coordinates, direction); int num = 0; int slotValue; while (true) { if (num >= SlotsCount - 1) { return; } slotValue = GetSlotValue(num); int slotCount = GetSlotCount(num); if (slotValue != 0 && slotCount > 0) { break; } num++; } MachineMode mode = DrillerBlock.GetMode(data); if (mode == MachineMode.Shoot) { int num2 = RemoveSlotItems(num, 1); for (int i = 0; i < num2; i++) { DispenseItem(coordinates, direction, slotValue, mode); } } }
public override void OnHitByProjectile(CellFace cellFace, WorldItem worldItem) { if (worldItem.ToRemove) { return; } ComponentBlockEntity blockEntity = m_subsystemBlockEntities.GetBlockEntity(cellFace.X, cellFace.Y, cellFace.Z); if (blockEntity != null && DispenserBlock.GetAcceptsDrops(Terrain.ExtractData(m_subsystemTerrain.Terrain.GetCellValue(cellFace.X, cellFace.Y, cellFace.Z)))) { ComponentDispenser inventory = blockEntity.Entity.FindComponent <ComponentDispenser>(throwOnError: true); Pickable pickable = worldItem as Pickable; int num = pickable?.Count ?? 1; int num2 = ComponentInventoryBase.AcquireItems(inventory, worldItem.Value, num); if (num2 < num) { m_subsystemAudio.PlaySound("Audio/PickableCollected", 1f, 0f, worldItem.Position, 3f, autoDelay: true); } if (num2 <= 0) { worldItem.ToRemove = true; } else if (pickable != null) { pickable.Count = num2; } } }