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 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 OnPoll(int value, int x, int y, int z, int pollPass) { bool hydration = SoilBlock.GetHydration(Terrain.ExtractData(value)); if (DetermineHydration(x, y, z, 3)) { if (!hydration) { m_toHydrate[new Point3(x, y, z)] = true; } } else if (hydration) { m_toHydrate[new Point3(x, y, z)] = false; } }
public bool DetermineHydrationHelper(int x, int y, int z, int steps) { int cellValueFast = base.SubsystemTerrain.Terrain.GetCellValueFast(x, y, z); int num = Terrain.ExtractContents(cellValueFast); int data = Terrain.ExtractData(cellValueFast); switch (num) { case 18: return(true); case 168: if (SoilBlock.GetHydration(data)) { return(DetermineHydration(x, y, z, steps)); } break; } if (num == 2) { return(DetermineHydration(x, y, z, steps)); } return(false); }
public void GrowPumpkin(int value, int x, int y, int z, int pollPass) { if (Terrain.ExtractLight(base.SubsystemTerrain.Terrain.GetCellValueFast(x, y + 1, z)) < 9) { return; } int data = Terrain.ExtractData(value); int size = BasePumpkinBlock.GetSize(data); if (BasePumpkinBlock.GetIsDead(data) || size >= 7) { return; } int cellValueFast = base.SubsystemTerrain.Terrain.GetCellValueFast(x, y - 1, z); int num = Terrain.ExtractContents(cellValueFast); int data2 = Terrain.ExtractData(cellValueFast); bool flag = num == 168 && SoilBlock.GetHydration(data2); int num2 = (num == 168) ? SoilBlock.GetNitrogen(data2) : 0; int num3 = 4; float num4 = 0.15f; if (num == 168) { num3--; num4 -= 0.05f; } if (num2 > 0) { num3--; num4 -= 0.05f; } if (flag) { num3--; num4 -= 0.05f; } if (pollPass % MathUtils.Max(num3, 1) == 0) { int data3 = BasePumpkinBlock.SetSize(data, MathUtils.Min(size + 1, 7)); if (m_random.Float(0f, 1f) < num4) { data3 = BasePumpkinBlock.SetIsDead(data3, isDead: true); } int value2 = Terrain.ReplaceData(value, data3); Replacement value3 = m_toReplace[new Point3(x, y, z)] = new Replacement { Value = value2, RequiredValue = value }; if (num == 168 && size + 1 == 7) { int data4 = SoilBlock.SetNitrogen(data2, MathUtils.Max(num2 - 3, 0)); int value4 = Terrain.ReplaceData(cellValueFast, data4); Dictionary <Point3, Replacement> toReplace = m_toReplace; Point3 key = new Point3(x, y - 1, z); value3 = new Replacement { Value = value4, RequiredValue = cellValueFast }; toReplace[key] = value3; } } }
public void GrowCotton(int value, int x, int y, int z, int pollPass) { if (Terrain.ExtractLight(base.SubsystemTerrain.Terrain.GetCellValueFast(x, y + 1, z)) < 9) { return; } int data = Terrain.ExtractData(value); int size = CottonBlock.GetSize(data); if (size >= 2) { return; } Replacement value3; if (CottonBlock.GetIsWild(data)) { if (size < 2) { int data2 = CottonBlock.SetSize(CottonBlock.SetIsWild(data, isWild: true), size + 1); int value2 = Terrain.ReplaceData(value, data2); Dictionary <Point3, Replacement> toReplace = m_toReplace; Point3 key = new Point3(x, y, z); value3 = new Replacement { Value = value2, RequiredValue = value }; toReplace[key] = value3; } return; } int cellValueFast = base.SubsystemTerrain.Terrain.GetCellValueFast(x, y - 1, z); if (Terrain.ExtractContents(cellValueFast) == 168) { int data3 = Terrain.ExtractData(cellValueFast); bool hydration = SoilBlock.GetHydration(data3); int nitrogen = SoilBlock.GetNitrogen(data3); int num = 6; float num2 = 0.8f; if (nitrogen > 0) { num -= 2; num2 -= 0.4f; } if (hydration) { num -= 2; num2 -= 0.4f; } if (pollPass % MathUtils.Max(num, 1) == 0) { int data4 = CottonBlock.SetSize(data, MathUtils.Min(size + 1, 2)); if (m_random.Float(0f, 1f) < num2 && size == 1) { data4 = CottonBlock.SetIsWild(data4, isWild: true); } int value4 = Terrain.ReplaceData(value, data4); value3 = (m_toReplace[new Point3(x, y, z)] = new Replacement { Value = value4, RequiredValue = value }); if (size + 1 == 2) { int data5 = SoilBlock.SetNitrogen(data3, MathUtils.Max(nitrogen - 1, 0)); int value5 = Terrain.ReplaceData(cellValueFast, data5); Dictionary <Point3, Replacement> toReplace2 = m_toReplace; Point3 key2 = new Point3(x, y - 1, z); value3 = new Replacement { Value = value5, RequiredValue = cellValueFast }; toReplace2[key2] = value3; } } } else { int value6 = Terrain.ReplaceData(value, CottonBlock.SetIsWild(data, isWild: true)); Dictionary <Point3, Replacement> toReplace3 = m_toReplace; Point3 key3 = new Point3(x, y, z); value3 = new Replacement { Value = value6, RequiredValue = value }; toReplace3[key3] = value3; } }