Exemple #1
0
    public static Block Load(System.IO.FileStream fs, Chunk c)
    {
        var b = new Block(c, new ChunkPos(fs.ReadByte(), fs.ReadByte(), fs.ReadByte()));

        if (fs.ReadByte() == 1)
        {
            b.extension = BlockExtension.Load(fs, b);
        }
        return(b);
    }
Exemple #2
0
 public void RebuildBlock(BlockMaterialsList bml, bool i_natural, bool compensateStructures, bool redrawCall)
 {
     if (extension == null)
     {
         extension = new BlockExtension(this, bml, i_natural, redrawCall);
     }
     else
     {
         extension.Rebuild(bml, i_natural, compensateStructures, redrawCall);
     }
 }
Exemple #3
0
    //private const byte SURFACE_MASK = (1 << Block.SURFACE_FACE_INDEX) + ( 1 << Block.UP_FACE_INDEX);

    public override bool Equals(object obj)
    {
        // Check for null values and compare run-time types.
        if (obj == null || GetType() != obj.GetType())
        {
            return(false);
        }

        BlockExtension be = (BlockExtension)obj;

        return(myBlock == be.myBlock && materialID == be.materialID && existingPlanesMask == be.existingPlanesMask);
    }
Exemple #4
0
 private void BuildBlock(IPlanable i_mainStructure)
 {
     if (i_mainStructure.IsStructure())
     {
         mainStructure           = (Structure)i_mainStructure;
         mainStructureIsABlocker = false;
     }
     else
     {
         extension = (BlockExtension)i_mainStructure;
     }
 }
Exemple #5
0
    public static BlockExtension Load(System.IO.FileStream fs, Block b)
    {
        var data = new byte[14];

        fs.Read(data, 0, data.Length);
        int  materialID = System.BitConverter.ToInt32(data, 0);
        bool isNatural  = data[4] == 1;
        var  be         = new BlockExtension(b, materialID, isNatural);

        be.existingPlanesMask = data[5];
        be.fossilsVolume      = System.BitConverter.ToSingle(data, 6);
        be.volume             = System.BitConverter.ToSingle(data, 10);
        be.LoadPlanesData(fs);
        return(be);
    }
Exemple #6
0
 public void ChangeMaterial(int m_id, bool naturalAffect, bool redrawCall)
 {
     if (m_id == PoolMaster.NO_MATERIAL_ID)
     {
         return;
     }
     if (extension == null)
     {
         extension = new BlockExtension(this, m_id, naturalAffect);
     }
     else
     {
         extension.ChangeMaterial(m_id, redrawCall);
     }
 }
Exemple #7
0
    public static bool TryToLoadBlock(System.IO.Stream fs, Chunk c, ref Block b)
    {
        b = new Block(c, new ChunkPos(fs.ReadByte(), fs.ReadByte(), fs.ReadByte()));
        var csize = Chunk.chunkSize;

        if (b.pos.x >= csize | b.pos.y >= csize | b.pos.z >= csize)
        {
            Debug.Log("block load error - wrong position");
            GameMaster.LoadingFail();
            return(false);
        }
        if (fs.ReadByte() == 1)
        {
            b.extension = BlockExtension.Load(fs, b);
        }
        return(true);
    }
Exemple #8
0
    public DigSite(Plane i_plane, bool work_is_dig, int startWorkers) : base(i_plane)
    {
        workObject = workplace.GetBlock().GetExtension();
        if (workObject == null)
        {
            StopWork(true);
            return;
        }
        dig = work_is_dig;
        if (i_plane.faceIndex == Block.SURFACE_FACE_INDEX | i_plane.faceIndex == Block.UP_FACE_INDEX)
        {
            if (dig)
            {
                sign = Object.Instantiate(Resources.Load <GameObject>("Prefs/DigSign")).GetComponent <WorksiteSign>();
            }
            else
            {
                sign = Object.Instantiate(Resources.Load <GameObject>("Prefs/PourInSign")).GetComponent <WorksiteSign>();
            }
            sign.transform.position = workplace.GetCenterPosition() + workplace.GetLookVector() * Block.QUAD_SIZE * 0.5f;
        }
        else
        {
            sign = Object.Instantiate(Resources.Load <GameObject>("Prefs/tunnelBuildingSign")).GetComponent <WorksiteSign>();
            sign.transform.position = workplace.GetCenterPosition();
            sign.transform.rotation = Quaternion.Euler(workplace.GetEulerRotationForQuad());
        }
        sign.worksite = this;

        int wom = workObject.materialID;

        if (workplace.materialID != wom)
        {
            workplace.ChangeMaterial(wom, true);
        }
        maxWorkersCount = 64;
        if (startWorkers != 0)
        {
            colony.SendWorkers(startWorkers, this);
        }
        gearsDamage = GameConstants.GEARS_DAMAGE_COEFFICIENT;
        workComplexityCoefficient = GameConstants.GetWorkComplexityCf(WorkType.Digging);
    }
Exemple #9
0
    public void CalculateOutput(float production, BlockExtension workObject, Storage storage)
    {
        if (workObject == null)
        {
            return;
        }
        ColonyController colony = GameMaster.realMaster.colonyController;
        int materialID          = workObject.materialID;

        if (workObject.GetFossilsVolume() > 0)
        {
            float v = Random.value - GameMaster.LUCK_COEFFICIENT;
            float m = 0;
            switch (materialID)
            {
            case ResourceType.STONE_ID:
                if (metalK_abundance >= v)
                {
                    m = metalK_abundance * production * (Random.value + 1 + GameMaster.LUCK_COEFFICIENT);
                    storage.AddResource(ResourceType.metal_K_ore, m); production -= m;
                }
                if (metalM_abundance >= v)
                {
                    m = metalM_abundance * production * (Random.value + 1 + GameMaster.LUCK_COEFFICIENT);
                    storage.AddResource(ResourceType.metal_M_ore, m); production -= m;
                }
                if (metalE_abundance >= v)
                {
                    m = metalE_abundance * production * (Random.value + 1 + GameMaster.LUCK_COEFFICIENT);
                    storage.AddResource(ResourceType.metal_E_ore, m); production -= m;
                }
                if (metalN_abundance >= v)
                {
                    m = metalN_abundance * production * (Random.value + 1 + GameMaster.LUCK_COEFFICIENT);
                    storage.AddResource(ResourceType.metal_N_ore, m); production -= m;
                }
                if (metalP_abundance >= v)
                {
                    m = metalP_abundance * production * (Random.value + 1 + GameMaster.LUCK_COEFFICIENT);
                    storage.AddResource(ResourceType.metal_P_ore, m); production -= m;
                }
                if (metalS_abundance >= v)
                {
                    m = metalS_abundance * production * (Random.value + 1 + GameMaster.LUCK_COEFFICIENT);
                    storage.AddResource(ResourceType.metal_S_ore, m); production -= m;
                }
                if (mineralF_abundance >= v)
                {
                    m = mineralF_abundance * production * (Random.value + 1 + GameMaster.LUCK_COEFFICIENT);
                    storage.AddResource(ResourceType.mineral_F, m); production -= m;
                }
                if (mineralL_abundance >= v)
                {
                    m = mineralL_abundance * production * (Random.value + 1 + GameMaster.LUCK_COEFFICIENT);
                    storage.AddResource(ResourceType.mineral_L, m); production -= m;
                }
                if (production > 0)
                {
                    colony.storage.AddResource(ResourceType.Stone, production);
                }
                break;

            case ResourceType.DIRT_ID:
                if (metalK_abundance >= v)
                {
                    m = metalK_abundance / 2f * production * (Random.value + 1 + GameMaster.LUCK_COEFFICIENT);
                    colony.storage.AddResource(ResourceType.metal_K_ore, m); production -= m;
                }
                if (metalP_abundance >= v)
                {
                    m = metalP_abundance / 2f * production * (Random.value + 1 + GameMaster.LUCK_COEFFICIENT);
                    colony.storage.AddResource(ResourceType.metal_P, m); production -= m;
                }
                if (mineralL_abundance >= v)
                {
                    m = mineralL_abundance / 2f * production * (Random.value + 1 + GameMaster.LUCK_COEFFICIENT);
                    colony.storage.AddResource(ResourceType.mineral_L, m); production -= m;
                }
                if (production > 0)
                {
                    colony.storage.AddResource(ResourceType.Dirt, production);
                }
                break;

            default:
                colony.storage.AddResource(ResourceType.GetResourceTypeById(materialID), production);
                break;
            }
            workObject.TakeFossilsVolume(production);
        }
        else           // no fossils
        {
            colony.storage.AddResource(ResourceType.GetResourceTypeById(materialID), production);
        }
    }
Exemple #10
0
 public Block(Chunk f_chunk, ChunkPos f_chunkPos, BlockMaterialsList bml, float i_volume_pc, bool i_natural, bool redrawCall) : this(f_chunk, f_chunkPos)
 {
     extension = new BlockExtension(this, bml, i_volume_pc, i_natural, redrawCall);
 }
Exemple #11
0
 public Block(Chunk f_chunk, ChunkPos f_chunkPos, int f_materialID, bool f_natural) : this(f_chunk, f_chunkPos)
 {
     extension = new BlockExtension(this, f_materialID, f_natural);
 }