예제 #1
0
    override public void Annihilate(bool clearFromSurface, bool returnResources, bool leaveRuins)
    {
        if (destroyed | GameMaster.sceneClearing)
        {
            return;
        }
        else
        {
            destroyed = true;
        }
        PrepareStructureForDestruction(clearFromSurface, returnResources, leaveRuins);
        if (basement != null)
        {
            basement.myChunk.GetNature().RemoveLifesource(this);
            basement.ChangeMaterial(ResourceType.DIRT_ID, true);
            if (GameMaster.realMaster.gameMode != GameMode.Editor)
            {
                switch (ID)
                {
                case TREE_OF_LIFE_ID:
                {
                    HarvestableResource hr = HarvestableResource.ConstructContainer(ContainerModelType.DeadTreeOfLife, ResourceType.Lumber, 5000);
                    hr.SetModelRotation(modelRotation);
                    hr.SetBasement(basement, new PixelPosByte(hr.surfaceRect.x, hr.surfaceRect.z));
                    break;
                }

                case LIFESTONE_ID:
                {
                    HarvestableResource hr = HarvestableResource.ConstructContainer(ContainerModelType.DeadLifestone, ResourceType.Stone, 5000);
                    hr.SetModelRotation(modelRotation);
                    hr.SetBasement(basement, new PixelPosByte(hr.surfaceRect.x, hr.surfaceRect.z));
                    break;
                }
                }
            }
            if (dependentBlocks != null)
            {
                basement.myChunk.ClearBlocksList(this, dependentBlocks, true);
            }
        }
        if (subscribedToRestoreBlockersUpdate)
        {
            GameMaster.realMaster.blockersRestoreEvent -= RestoreBlockers;
            subscribedToRestoreBlockersUpdate           = false;
        }
        Destroy(gameObject);
    }
예제 #2
0
파일: OakTree.cs 프로젝트: Hengle/VoxelGame
 override public void Dry(bool sendMessageToGrassland)
 {
     if (!sendMessageToGrassland)
     {
         basement?.RemoveStructure(this);
     }
     if (stage > TRANSIT_STAGE)
     {
         ContainerModelType cmtype;
         if (stage == 4)
         {
             cmtype = ContainerModelType.DeadOak4;
         }
         else
         {
             if (stage == 5)
             {
                 cmtype = ContainerModelType.DeadOak5;
             }
             else
             {
                 cmtype = ContainerModelType.DeadOak6;
             }
         }
         HarvestableResource hr = HarvestableResource.ConstructContainer(cmtype, ResourceType.Lumber, CountLumber() * GameMaster.realMaster.environmentMaster.environmentalConditions);
         hr.SetModelRotation(modelRotation);
         hr.SetBasement(basement, new PixelPosByte(surfaceRect.x, surfaceRect.z));
         // спрайтовый LOD?
     }
     else
     {
         Structure s = GetStructureByID(DRYED_PLANT_ID);
         s.SetBasement(basement, new PixelPosByte(surfaceRect.x, surfaceRect.z));
         StructureTimer st = s.gameObject.AddComponent <StructureTimer>();
         st.timer = 5;
     }
 }
예제 #3
0
    override public void Annihilate(StructureAnnihilationOrder order)
    {
        if (destroyed | GameMaster.sceneClearing)
        {
            return;
        }
        else
        {
            destroyed = true;
        }
        PrepareStructureForDestruction(order);
        if (basement != null && order.doSpecialChecks)
        {
            Chunk    chunk = basement.myChunk;
            ChunkPos cpos  = basement.pos;
            Plane    p;
            void CheckAndUnblock(in ChunkPos position)
            {
                Block bx = chunk.GetBlock(position);

                if (bx != null && bx.TryGetPlane(Block.UP_FACE_INDEX, out p))
                {
                    p.UnblockFromStructure(this);
                }
            }

            ChunkPos cpos2 = new ChunkPos(cpos.x - 1, cpos.y, cpos.z + 1); if (cpos2.isOkay)
            {
                CheckAndUnblock(cpos2);
            }
            cpos2 = new ChunkPos(cpos.x, cpos.y, cpos.z + 1); if (cpos2.isOkay)
            {
                CheckAndUnblock(cpos2);
            }
            cpos2 = new ChunkPos(cpos.x + 1, cpos.y, cpos.z + 1); if (cpos2.isOkay)
            {
                CheckAndUnblock(cpos2);
            }
            cpos2 = new ChunkPos(cpos.x - 1, cpos.y, cpos.z); if (cpos2.isOkay)
            {
                CheckAndUnblock(cpos2);
            }
            cpos2 = new ChunkPos(cpos.x + 1, cpos.y, cpos.z); if (cpos2.isOkay)
            {
                CheckAndUnblock(cpos2);
            }
            cpos2 = new ChunkPos(cpos.x - 1, cpos.y, cpos.z - 1); if (cpos2.isOkay)
            {
                CheckAndUnblock(cpos2);
            }
            cpos2 = new ChunkPos(cpos.x, cpos.y, cpos.z - 1); if (cpos2.isOkay)
            {
                CheckAndUnblock(cpos2);
            }
            cpos2 = new ChunkPos(cpos.x + 1, cpos.y, cpos.z - 1); if (cpos2.isOkay)
            {
                CheckAndUnblock(cpos2);
            }

            basement.myChunk.InitializeNature().RemoveLifesource(this);
            basement.ChangeMaterial(ResourceType.DIRT_ID, true);
            if (GameMaster.realMaster.gameMode != GameMode.Editor)
            {
                switch (ID)
                {
                case TREE_OF_LIFE_ID:
                {
                    HarvestableResource hr = HarvestableResource.ConstructContainer(ContainerModelType.DeadTreeOfLife, ResourceType.Lumber, 5000);
                    hr.SetModelRotation(modelRotation);
                    hr.SetBasement(basement, new PixelPosByte(hr.surfaceRect.x, hr.surfaceRect.z));
                    break;
                }

                case LIFESTONE_ID:
                {
                    HarvestableResource hr = HarvestableResource.ConstructContainer(ContainerModelType.DeadLifestone, ResourceType.Stone, 5000);
                    hr.SetModelRotation(modelRotation);
                    hr.SetBasement(basement, new PixelPosByte(hr.surfaceRect.x, hr.surfaceRect.z));
                    break;
                }
                }
            }
            if (dependentBlocks != null)
            {
                basement.myChunk.ClearBlockersList(this, dependentBlocks, true);
            }
        }
        if (subscribedToRestoreBlockersUpdate)
        {
            GameMaster.realMaster.blockersRestoreEvent -= RestoreBlockers;
            subscribedToRestoreBlockersUpdate           = false;
        }
        Destroy(gameObject);
    }