Пример #1
0
        public override int SetDamage(int value, int damage)
        {
            int num = Terrain.ExtractData(value);

            num = ((num & -65537) | ((damage & 1) << 16));
            return(Terrain.ReplaceData(value, num));
        }
Пример #2
0
        public override int SetDamage(int value, int damage)
        {
            int num = Terrain.ExtractData(value);

            num = ((num & -3841) | ((damage & 0xF) << 8));
            return(Terrain.ReplaceData(value, num));
        }
Пример #3
0
 public void OnItemHarvested(int x, int y, int z, int blockValue, ref BlockDropValue dropValue, ref int newBlockValue)
 {
     if (RemainCount <= 0)
     {
         dropValue.Value = Terrain.ReplaceData(Terrain.ReplaceLight(blockValue, 0), Terrain.ExtractData(blockValue) | 16384);
     }
 }
Пример #4
0
        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 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 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);
        }
Пример #7
0
        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);
            }
        }
Пример #8
0
 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();
     }
 }
Пример #9
0
 public virtual IEnumerable <int> GetCreativeValues()
 {
     if (DefaultCreativeData >= 0)
     {
         yield return(Terrain.ReplaceContents(Terrain.ReplaceData(0, DefaultCreativeData), BlockIndex));
     }
 }
        public bool SetCellOnFire(int x, int y, int z, float fireExpandability)
        {
            int cellValue = base.SubsystemTerrain.Terrain.GetCellValue(x, y, z);
            int num       = Terrain.ExtractContents(cellValue);

            if (BlocksManager.Blocks[num].FireDuration == 0f)
            {
                return(false);
            }
            bool result = false;

            for (int i = 0; i < 5; i++)
            {
                Point3 point      = CellFace.FaceToPoint3(i);
                int    cellValue2 = base.SubsystemTerrain.Terrain.GetCellValue(x + point.X, y + point.Y, z + point.Z);
                int    num2       = Terrain.ExtractContents(cellValue2);
                if (num2 == 0 || num2 == 104 || num2 == 61)
                {
                    int num3 = (num2 == 104) ? Terrain.ExtractData(cellValue2) : 0;
                    int num4 = CellFace.OppositeFace(i);
                    num3     |= ((1 << num4) & 0xF);
                    cellValue = Terrain.ReplaceData(Terrain.ReplaceContents(0, 104), num3);
                    AddFire(x + point.X, y + point.Y, z + point.Z, fireExpandability);
                    base.SubsystemTerrain.ChangeCell(x + point.X, y + point.Y, z + point.Z, cellValue);
                    result = true;
                }
            }
            return(result);
        }
Пример #11
0
        public override BlockPlacementData GetPlacementValue(SubsystemTerrain subsystemTerrain, ComponentMiner componentMiner, int value, TerrainRaycastResult raycastResult)
        {
            int value2 = 0;

            if (raycastResult.CellFace.Face == 0)
            {
                value2 = Terrain.ReplaceData(Terrain.ReplaceContents(0, 121), 0);
            }
            if (raycastResult.CellFace.Face == 1)
            {
                value2 = Terrain.ReplaceData(Terrain.ReplaceContents(0, 121), 1);
            }
            if (raycastResult.CellFace.Face == 2)
            {
                value2 = Terrain.ReplaceData(Terrain.ReplaceContents(0, 121), 2);
            }
            if (raycastResult.CellFace.Face == 3)
            {
                value2 = Terrain.ReplaceData(Terrain.ReplaceContents(0, 121), 3);
            }
            BlockPlacementData result = default(BlockPlacementData);

            result.Value    = value2;
            result.CellFace = raycastResult.CellFace;
            return(result);
        }
Пример #12
0
        public override BlockPlacementData GetPlacementValue(SubsystemTerrain subsystemTerrain, ComponentMiner componentMiner, int value, TerrainRaycastResult raycastResult)
        {
            Vector3 forward = Matrix.CreateFromQuaternion(componentMiner.ComponentCreature.ComponentCreatureModel.EyeRotation).Forward;
            float   num     = Vector3.Dot(forward, Vector3.UnitZ);
            float   num2    = Vector3.Dot(forward, Vector3.UnitX);
            float   num3    = Vector3.Dot(forward, -Vector3.UnitZ);
            float   num4    = Vector3.Dot(forward, -Vector3.UnitX);
            int     data    = 0;

            if (num == MathUtils.Max(num, num2, num3, num4))
            {
                data = 0;
            }
            else if (num2 == MathUtils.Max(num, num2, num3, num4))
            {
                data = 1;
            }
            else if (num3 == MathUtils.Max(num, num2, num3, num4))
            {
                data = 2;
            }
            else if (num4 == MathUtils.Max(num, num2, num3, num4))
            {
                data = 3;
            }
            BlockPlacementData result = default(BlockPlacementData);

            result.Value    = Terrain.ReplaceData(Terrain.ReplaceContents(0, 132), data);
            result.CellFace = raycastResult.CellFace;
            return(result);
        }
Пример #13
0
        public override BlockPlacementData GetPlacementValue(SubsystemTerrain subsystemTerrain, ComponentMiner componentMiner, int value, TerrainRaycastResult raycastResult)
        {
            int  rotation;
            bool upsideDown;

            if (raycastResult.CellFace.Face < 4)
            {
                rotation   = raycastResult.CellFace.Face;
                upsideDown = (raycastResult.HitPoint().Y - (float)raycastResult.CellFace.Y > 0.5f);
            }
            else
            {
                Vector3 forward = Matrix.CreateFromQuaternion(componentMiner.ComponentCreature.ComponentCreatureModel.EyeRotation).Forward;
                float   num     = Vector3.Dot(forward, Vector3.UnitZ);
                float   num2    = Vector3.Dot(forward, Vector3.UnitX);
                float   num3    = Vector3.Dot(forward, -Vector3.UnitZ);
                float   num4    = Vector3.Dot(forward, -Vector3.UnitX);
                rotation   = ((num == MathUtils.Max(num, num2, num3, num4)) ? 2 : ((num2 == MathUtils.Max(num, num2, num3, num4)) ? 3 : ((num3 != MathUtils.Max(num, num2, num3, num4)) ? ((num4 == MathUtils.Max(num, num2, num3, num4)) ? 1 : 0) : 0)));
                upsideDown = (raycastResult.CellFace.Face == 5);
            }
            int data = SetOpen(SetRotation(SetUpsideDown(0, upsideDown), rotation), open: false);
            BlockPlacementData result = default(BlockPlacementData);

            result.Value    = Terrain.ReplaceData(Terrain.ReplaceContents(0, BlockIndex), data);
            result.CellFace = raycastResult.CellFace;
            return(result);
        }
        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);
        }
Пример #15
0
        public static int SetWireFacesBitmask(int value, int bitmask)
        {
            int num = Terrain.ExtractData(value);

            num &= -64;
            num |= (bitmask & 0x3F);
            return(Terrain.ReplaceData(Terrain.ReplaceContents(value, 133), num));
        }
Пример #16
0
 public static BlockPlacementData GetPlacementValue(int index, ComponentMiner componentMiner, int value, TerrainRaycastResult raycastResult)
 {
     return(new BlockPlacementData
     {
         Value = Terrain.ReplaceData(value, Terrain.ExtractData(value) & -229377 | Utils.GetDirectionXZ(componentMiner) << 15 | index),
         CellFace = raycastResult.CellFace
     });
 }
Пример #17
0
        public override BlockPlacementData GetPlacementValue(SubsystemTerrain subsystemTerrain, ComponentMiner componentMiner, int value, TerrainRaycastResult raycastResult)
        {
            BlockPlacementData result = default(BlockPlacementData);

            result.Value    = Terrain.ReplaceData(Terrain.ReplaceContents(0, BlockIndex), 0);
            result.CellFace = raycastResult.CellFace;
            return(result);
        }
Пример #18
0
        public override int SetDamage(int value, int damage)
        {
            int num = Terrain.ExtractData(value);

            num &= -65281;
            num |= MathUtils.Clamp(damage, 0, 255) << 8;
            return(Terrain.ReplaceData(value, num));
        }
Пример #19
0
        public virtual int SetDamage(int value, int damage)
        {
            int num = Terrain.ExtractData(value);

            num &= 0xF;
            num |= MathUtils.Clamp(damage, 0, 4095) << 4;
            return(Terrain.ReplaceData(value, num));
        }
Пример #20
0
 public override BlockPlacementData GetDigValue(SubsystemTerrain subsystemTerrain, ComponentMiner componentMiner, int value, int toolValue, TerrainRaycastResult raycastResult)
 {
     return(new BlockPlacementData
     {
         Value = (Terrain.ExtractData(value) & 65536) != 0 ? Terrain.ReplaceData(MagmaBlock.Index
                                                                                 , FluidBlock.SetIsTop(FluidBlock.SetLevel(0, 4), toolValue == MagmaBucketBlock.Index)) : 0,
         CellFace = raycastResult.CellFace
     });
 }
Пример #21
0
        public override BlockPlacementData GetPlacementValue(SubsystemTerrain subsystemTerrain, ComponentMiner componentMiner, int value, TerrainRaycastResult raycastResult)
        {
            int data = SetMountingFace(SetSpikesState(Terrain.ExtractData(value), spikesState: true), raycastResult.CellFace.Face);
            BlockPlacementData result = default(BlockPlacementData);

            result.Value    = Terrain.ReplaceData(value, data);
            result.CellFace = raycastResult.CellFace;
            return(result);
        }
Пример #22
0
 public override void GetDropValues(SubsystemTerrain subsystemTerrain, int oldValue, int newValue, int toolLevel, List <BlockDropValue> dropValues, out bool showDebris)
 {
     showDebris = DestructionDebrisScale > 0f;
     dropValues.Add(new BlockDropValue
     {
         Value = Terrain.ReplaceLight(Terrain.ReplaceData(oldValue, SetDirection(SetHeatLevel(Terrain.ExtractData(oldValue), 0), 0)), 0),
         Count = 1
     });
 }
Пример #23
0
        public override BlockPlacementData GetPlacementValue(SubsystemTerrain subsystemTerrain, ComponentMiner componentMiner, int value, TerrainRaycastResult raycastResult)
        {
            Vector3 forward = Matrix.CreateFromQuaternion(componentMiner.ComponentCreature.ComponentCreatureModel.EyeRotation).Forward;
            float   num     = Vector3.Dot(forward, Vector3.UnitZ);
            float   num2    = Vector3.Dot(forward, Vector3.UnitX);
            float   num3    = Vector3.Dot(forward, -Vector3.UnitZ);
            float   num4    = Vector3.Dot(forward, -Vector3.UnitX);
            int     num5    = 0;

            if (num == MathUtils.Max(num, num2, num3, num4))
            {
                num5 = 2;
            }
            else if (num2 == MathUtils.Max(num, num2, num3, num4))
            {
                num5 = 3;
            }
            else if (num3 == MathUtils.Max(num, num2, num3, num4))
            {
                num5 = 0;
            }
            else if (num4 == MathUtils.Max(num, num2, num3, num4))
            {
                num5 = 1;
            }
            Point3 point       = CellFace.FaceToPoint3(raycastResult.CellFace.Face);
            int    num6        = raycastResult.CellFace.X + point.X;
            int    y           = raycastResult.CellFace.Y + point.Y;
            int    num7        = raycastResult.CellFace.Z + point.Z;
            bool   rightHanded = true;

            switch (num5)
            {
            case 0:
                rightHanded = BlocksManager.Blocks[subsystemTerrain.Terrain.GetCellContents(num6 - 1, y, num7)].IsTransparent;
                break;

            case 1:
                rightHanded = BlocksManager.Blocks[subsystemTerrain.Terrain.GetCellContents(num6, y, num7 + 1)].IsTransparent;
                break;

            case 2:
                rightHanded = BlocksManager.Blocks[subsystemTerrain.Terrain.GetCellContents(num6 + 1, y, num7)].IsTransparent;
                break;

            case 3:
                rightHanded = BlocksManager.Blocks[subsystemTerrain.Terrain.GetCellContents(num6, y, num7 - 1)].IsTransparent;
                break;
            }
            int data = SetRightHanded(SetOpen(SetRotation(0, num5), open: false), rightHanded);
            BlockPlacementData result = default(BlockPlacementData);

            result.Value    = Terrain.ReplaceData(Terrain.ReplaceContents(0, BlockIndex), data);
            result.CellFace = raycastResult.CellFace;
            return(result);
        }
Пример #24
0
        public override IEnumerable <int> GetCreativeValues()
        {
            var arr = new int[64];

            for (int i = 0; i < 64; i++)
            {
                arr[i] = Terrain.ReplaceData(Index, i >> 4 | (i & 15) << 13);
            }
            return(arr);
        }
        public override void OnItemHarvested(int x, int y, int z, int blockValue, ref BlockDropValue dropValue, ref int newBlockValue)
        {
            T blockData = GetBlockData(new Point3(x, y, z));

            if (blockData != null)
            {
                int num = FindFreeItemId();
                m_itemsData.Add(num, (T)blockData.Copy());
                dropValue.Value = Terrain.ReplaceData(dropValue.Value, num);
            }
        }
        public override void OnNeighborBlockChanged(int x, int y, int z, int neighborX, int neighborY, int neighborZ)
        {
            int num = Terrain.ExtractData(base.SubsystemTerrain.Terrain.GetCellValue(x, y, z));

            if ((num & 1) != 0 && BlocksManager.Blocks[base.SubsystemTerrain.Terrain.GetCellContents(x, y, z + 1)].FireDuration == 0f)
            {
                num &= -2;
            }
            if ((num & 2) != 0 && BlocksManager.Blocks[base.SubsystemTerrain.Terrain.GetCellContents(x + 1, y, z)].FireDuration == 0f)
            {
                num &= -3;
            }
            if ((num & 4) != 0 && BlocksManager.Blocks[base.SubsystemTerrain.Terrain.GetCellContents(x, y, z - 1)].FireDuration == 0f)
            {
                num &= -5;
            }
            if ((num & 8) != 0 && BlocksManager.Blocks[base.SubsystemTerrain.Terrain.GetCellContents(x - 1, y, z)].FireDuration == 0f)
            {
                num &= -9;
            }
            if (m_fireData.TryGetValue(new Point3(x, y, z), out FireData value))
            {
                if ((num & 1) != 0 && neighborX == x && neighborY == y && neighborZ == z + 1)
                {
                    InitializeFireDataTime(value, 0);
                }
                if ((num & 2) != 0 && neighborX == x + 1 && neighborY == y && neighborZ == z)
                {
                    InitializeFireDataTime(value, 1);
                }
                if ((num & 4) != 0 && neighborX == x && neighborY == y && neighborZ == z - 1)
                {
                    InitializeFireDataTime(value, 2);
                }
                if ((num & 8) != 0 && neighborX == x - 1 && neighborY == y && neighborZ == z)
                {
                    InitializeFireDataTime(value, 3);
                }
                if (num == 0 && neighborX == x && neighborY == y - 1 && neighborZ == z)
                {
                    InitializeFireDataTime(value, 5);
                }
            }
            int contents = 104;

            if (num == 0 && BlocksManager.Blocks[base.SubsystemTerrain.Terrain.GetCellContents(x, y - 1, z)].FireDuration == 0f)
            {
                contents = 0;
            }
            int value2 = Terrain.ReplaceData(Terrain.ReplaceContents(0, contents), num);

            base.SubsystemTerrain.ChangeCell(x, y, z, value2);
        }
Пример #27
0
        public override IEnumerable <int> GetCreativeValues()
        {
            var arr = new int[15 * (16 + 1)];
            int i;

            for (i = 0; i < 15; i++)
            {
                arr[i] = Terrain.ReplaceData(Index, i << 5);
            }
            for (i = 0; i < 15 * 16; i++)
            {
                arr[i + 15] = Terrain.ReplaceData(Index, i << 1 | 1);
            }
            return(arr);
        }
Пример #28
0
        public void GrowFlower(int value, int x, int y, int z, int pollPass)
        {
            int data = Terrain.ExtractData(value);

            if (FlowerBlock.GetIsSmall(data) && Terrain.ExtractLight(base.SubsystemTerrain.Terrain.GetCellValueFast(x, y + 1, z)) >= 9)
            {
                int data2  = FlowerBlock.SetIsSmall(data, isSmall: false);
                int value2 = Terrain.ReplaceData(value, data2);
                m_toReplace[new Point3(x, y, z)] = new Replacement
                {
                    Value         = value2,
                    RequiredValue = value
                };
            }
        }
Пример #29
0
        public bool OpenCloseDoor(int x, int y, int z, bool open)
        {
            int cellValue = base.SubsystemTerrain.Terrain.GetCellValue(x, y, z);
            int num       = Terrain.ExtractContents(cellValue);

            if (BlocksManager.Blocks[num] is DoorBlock)
            {
                int data  = DoorBlock.SetOpen(Terrain.ExtractData(cellValue), open);
                int value = Terrain.ReplaceData(cellValue, data);
                base.SubsystemTerrain.ChangeCell(x, y, z, value);
                string name = open ? "Audio/Doors/DoorOpen" : "Audio/Doors/DoorClose";
                base.SubsystemTerrain.Project.FindSubsystem <SubsystemAudio>(throwOnError: true).PlaySound(name, 0.7f, m_random.Float(-0.1f, 0.1f), new Vector3(x, y, z), 4f, autoDelay: true);
                return(true);
            }
            return(false);
        }
Пример #30
0
        public void UpdateIsTop(int value, int x, int y, int z)
        {
            Terrain terrain = base.SubsystemTerrain.Terrain;

            if (y < 255)
            {
                TerrainChunk chunkAtCell = terrain.GetChunkAtCell(x, z);
                if (chunkAtCell != null)
                {
                    int  num      = TerrainChunk.CalculateCellIndex(x & 0xF, y, z & 0xF);
                    int  contents = Terrain.ExtractContents(chunkAtCell.GetCellValueFast(num + 1));
                    int  data     = Terrain.ExtractData(value);
                    bool isTop    = !m_fluidBlock.IsTheSameFluid(contents);
                    chunkAtCell.SetCellValueFast(num, Terrain.ReplaceData(value, FluidBlock.SetIsTop(data, isTop)));
                }
            }
        }