override public void SetBasement(SurfaceBlock b, PixelPosByte pos)
    {
        if (hireCost == -1)
        {
            ResetToDefaults_Static_RecruitingCenter();
        }
        bool movement = false;

        if (basement != null)
        {
            movement = true;
        }
        if (b == null)
        {
            return;
        }
        SetBuildingData(b, pos);
        if (!subscribedToUpdate)
        {
            GameMaster.realMaster.labourUpdateEvent += LabourUpdate;
            subscribedToUpdate = true;
        }
        colonyController = GameMaster.colonyController;
        if (!movement) // здание не создавалось, а было перенесено
        {
            Crew.AddCrewSlots(CREW_SLOTS_FOR_BUILDING);
            progress = 0;
        }
    }
Example #2
0
    override public void SetBasement(Plane b, PixelPosByte pos)
    {
        if (b == null)
        {
            return;
        }
        SetBuildingData(b, pos);
        var master = GameMaster.realMaster;

        if (!subscribedToUpdate)
        {
            master.everydayUpdate += EverydayUpdate;
            subscribedToUpdate     = true;
        }
        if (hotels == null)
        {
            hotels = new List <Hotel>();
            hotels.Add(this);
        }
        else
        {
            if (!hotels.Contains(this))
            {
                hotels.Add(this);
            }
        }
        colony = master.colonyController;

        if (!GameMaster.loading)
        {
            IPlanableSupportClass.AddBlockRepresentation(this, basement, ref myBlock, true);
        }
    }
Example #3
0
    override public void SetBasement(Plane b, PixelPosByte pos)
    {
        if (b == null)
        {
            return;
        }
        basement    = b;
        surfaceRect = new SurfaceRect(pos.x, pos.y, surfaceRect.size);
        if (spriter == null && modelHolder == null)
        {
            SetModel();
        }
        b.AddStructure(this);

        if (!typeRegistered)
        {
            GameMaster.realMaster.mainChunk.InitializeNature().RegisterNewLifeform(type);
            typeRegistered = true;
        }

        if (!subscribedToVisibilityEvent)
        {
            basement.visibilityChangedEvent += this.SetVisibility;
            subscribedToVisibilityEvent      = true;
            oaksCount++;
        }
    }
Example #4
0
 override public void SetBasement(Plane b, PixelPosByte pos)
 {
     if (b == null)
     {
         return;
     }
     SetWorkbuildingData(b, pos);
     if (current != null)
     {
         if (current != null)
         {
             current.Annihilate(true, true, false);
         }
     }
     else
     {
         AddToResetList(typeof(XStation));
     }
     current = this;
     if (!indicatorPrepared)
     {
         PrepareIndicator();
         cityMarker.parent.gameObject.SetActive(false);
         markerEnabled = false;
     }
 }
Example #5
0
 public void ClearCell(PixelPosByte cellPos, Content c)
 {
     if (cellsStatus == 0)
     {
         return;
     }
     if (map[cellPos.x, cellPos.y] == c)
     {
         map[cellPos.x, cellPos.y] = Content.Empty;
         bool isEmpty = true;
         foreach (Content con in map)
         {
             if (con != Content.Empty)
             {
                 isEmpty = false; break;
             }
         }
         if (isEmpty)
         {
             cellsStatus = 0;
         }
         else
         {
             cellsStatus = -1;
         }
     }
 }
Example #6
0
 override public void SetBasement(Plane b, PixelPosByte pos)
 {
     if (b == null)
     {
         return;
     }
     SetBuildingData(b, pos);
     if (!subscribedToUpdate)
     {
         GameMaster.realMaster.everydayUpdate += EverydayUpdate;
         subscribedToUpdate = true;
         if (hotels != null)
         {
             hotels.Add(this);
         }
         else
         {
             hotels = new List <Hotel>()
             {
                 this
             }
         };
     }
     if (!GameMaster.loading)
     {
         IPlanableSupportClass.AddBlockRepresentation(this, basement, ref myBlock, true);
     }
 }
Example #7
0
 public override void SetBasement(SurfaceBlock b, PixelPosByte pos)
 {
     if (b == null)
     {
         return;
     }
     PrepareHouse(b, pos);
     if (level > 3)
     {
         if (rooftop == null)
         {
             rooftop = Instantiate(Resources.Load <GameObject>("Structures/HQ_rooftop"));
             rooftop.transform.parent        = transform.GetChild(0);
             rooftop.transform.localPosition = Vector3.up * (level - 3) * Block.QUAD_SIZE;
         }
         if (level > 4)
         {
             int i = 5;
             while (i <= level)
             {
                 b.myChunk.BlockByStructure(b.pos.x, (byte)(b.pos.y + i - 4), b.pos.z, this);
                 GameObject addon = Instantiate(Resources.Load <GameObject>("Structures/HQ_Addon"));
                 addon.transform.parent        = transform.GetChild(0);
                 addon.transform.localPosition = Vector3.zero + (i - 3.5f) * Vector3.up * Block.QUAD_SIZE;
                 addon.transform.localRotation = transform.GetChild(0).localRotation;
                 i++;
             }
             BoxCollider bc = transform.GetChild(0).GetComponent <BoxCollider>();
             bc.center = Vector3.up * (level - 3) * Block.QUAD_SIZE / 2f;
             bc.size   = new Vector3(Block.QUAD_SIZE, (level - 3) * Block.QUAD_SIZE, Block.QUAD_SIZE);
         }
     }
     colony = GameMaster.colonyController;
     colony.SetHQ(this);
 }
    override public void SetBasement(Plane b, PixelPosByte pos)
    {
        if (b == null)
        {
            return;
        }
        if (current != null)
        {
            var c = current;
            current = null;
            c.Annihilate(true, true, false);
        }
        SetWorkbuildingData(b, pos);
        if (!subscribedToUpdate)
        {
            GameMaster.realMaster.labourUpdateEvent += LabourUpdate;
            subscribedToUpdate = true;
        }
        var observer = colony.observer;

        if (observer != null && !observer.activeFastButtons.Contains(ID))
        {
            observer.AddFastButton(this);
        }
        current = this;
    }
Example #9
0
    protected void PrepareHouse(SurfaceBlock b, PixelPosByte pos)
    {
        SetBuildingData(b, pos);
        GameMaster.colonyController.AddHousing(this);
        switch (id)
        {
        case LANDED_ZEPPELIN_ID: housing = 10; break;

        case HQ_2_ID: housing = 30; break;

        case HQ_3_ID: housing = 40; break;

        case HQ_4_ID: housing = 45; break;

        case HOUSE_0_ID: housing = 2; break;

        case HOUSE_1_ID: housing = 10; break;

        case HOUSE_2_ID: housing = 50; break;

        case HOUSE_3_ID: housing = 100; break;

        case HOUSE_5_ID: housing = 800; break;
        }
    }
 override public void SetBasement(Plane b, PixelPosByte pos)
 {
     base.SetBasement(b, pos);
     if (ringSprite == null)
     {
         var g = new GameObject("ringSprite");
         ringSprite               = g.transform;
         ringSprite.parent        = transform;
         ringSprite.localPosition = Vector3.up * 1.5f;
         ringSprite.localRotation = Quaternion.Euler(90f, 0f, 0f);
         g.AddComponent <SpriteRenderer>();
     }
     if (artifacts == null)
     {
         artifacts = new Artifact[MAX_ARTIFACTS_COUNT];
     }
     else
     {
         RecalculateAffection();
     }
     if (!GameMaster.loading)
     {
         b.myChunk.CreateBlocker(b.GetLookingPosition(), this, false, false);
     }
     else
     {
         if (!subscribedToRestoreBlockersEvent)
         {
             GameMaster.realMaster.blockersRestoreEvent += RestoreBlockers;
             subscribedToRestoreBlockersEvent            = true;
         }
     }
 }
Example #11
0
    override public void SetBasement(SurfaceBlock b, PixelPosByte pos)
    {
        if (b == null)
        {
            return;
        }
        SetBuildingData(b, pos);
        Transform modelTransform = transform.GetChild(0);

        if (basement.pos.z == 0)
        {
            modelTransform.transform.localRotation = Quaternion.Euler(0, 180, 0);
        }
        else
        {
            if (basement.pos.z != Chunk.CHUNK_SIZE - 1)
            {
                if (basement.pos.x == 0)
                {
                    modelTransform.transform.localRotation = Quaternion.Euler(0, -90, 0);
                }
                else
                {
                    if (basement.pos.x == Chunk.CHUNK_SIZE - 1)
                    {
                        modelTransform.transform.localRotation = Quaternion.Euler(0, 90, 0);
                    }
                }
            }
        }
        hangarsCount++;
    }
Example #12
0
    public override void SetBasement(Plane b, PixelPosByte pos)
    {
        if (b == null)
        {
            return;
        }
        colony = GameMaster.realMaster.colonyController;
        if (colony == null)
        {
            colony = GameMaster.realMaster.gameObject.AddComponent <ColonyController>();
            colony.Prepare();
        }
        colony.SetHQ(this);

        SetBuildingData(b, pos);
        maxHp = 1000 * level;
        hp    = maxHp;

        if (level > 3)
        {
            if (!GameMaster.loading)
            {
                SetBlockers();
            }
            else
            {
                if (!subscribedToRestoreBlockersEvent)
                {
                    GameMaster.realMaster.blockersRestoreEvent += RestoreBlockers;
                    subscribedToRestoreBlockersEvent            = true;
                }
            }
        }
    }
Example #13
0
 override public void SetBasement(SurfaceBlock b, PixelPosByte pos)
 {
     if (b == null)
     {
         return;
     }
     //#setStructureData
     basement      = b;
     innerPosition = new SurfaceRect(pos.x, pos.y, innerPosition.size);
     if (model == null)
     {
         SetModel();
     }
     b.AddStructure(this);
     // isbasement check deleted
     //---
     if (!addedToClassList)
     {
         corns.Add(this);
         addedToClassList = true;
         if (((existingPlantsMask >> CROP_CORN_ID) & 1) != 1)
         {
             int val = 1;
             val = val << CROP_CORN_ID;
             existingPlantsMask += val;
         }
     }
 }
Example #14
0
    public static Vector3 GetLocalPosition(PixelPosByte cellPos)
    {
        float res = BlockSurface.INNER_RESOLUTION;
        float a = cellPos.x, b = cellPos.y;

        return(new Vector3((a / res - 0.5f) * Block.QUAD_SIZE + Block.QUAD_SIZE / res / 2f, 0, (b / res - 0.5f) * Block.QUAD_SIZE + Block.QUAD_SIZE / res / 2f));
    }
Example #15
0
 public override void SetBasement(Plane b, PixelPosByte pos)
 {
     if (b == null)
     {
         return;
     }
     //#set house data
     SetBuildingData(b, pos);
     GameMaster.realMaster.colonyController.AddHousing(this);
     if (ID == HOUSING_MAST_6_ID)
     {
         if (!GameMaster.loading)
         {
             SetBlockersForHousingMast();
         }
         else
         {
             if (!subscribedToRestoreBlockersUpdate)
             {
                 GameMaster.realMaster.blockersRestoreEvent += RestoreBlockers;
                 subscribedToRestoreBlockersUpdate           = true;
             }
         }
     }
     //#
 }
Example #16
0
 override public void SetBasement(SurfaceBlock b, PixelPosByte pos)
 {
     if (b == null)
     {
         return;
     }
     SetBuildingData(b, pos);
 }
Example #17
0
 virtual public void SetBasement(SurfaceBlock b, PixelPosByte pos)
 {
     if (b == null)
     {
         return;
     }
     SetStructureData(b, pos);
 }
Example #18
0
 override public void SetBasement(Plane b, PixelPosByte pos)
 {
     if (b == null)
     {
         return;
     }
     SetWorkbuildingData(b, pos);
 }
Example #19
0
 override public void SetBasement(SurfaceBlock b, PixelPosByte pos)
 {
     if (b == null)
     {
         return;
     }
     PrepareMultiblockStructure(b, pos);
 }
Example #20
0
 public override void SetBasement(SurfaceBlock b, PixelPosByte pos)
 {
     if (b == null)
     {
         return;
     }
     PrepareHouse(b, pos);
 }
Example #21
0
 override public void SetBasement(SurfaceBlock b, PixelPosByte pos)
 {
     if (b == null)
     {
         return;
     }
     SetBuildingData(b, pos);
     GameMaster.colonyController.storage.AddWarehouse(this);
 }
Example #22
0
 override public void SetBasement(Plane b, PixelPosByte pos)
 {
     if (b == null)
     {
         return;
     }
     SetBuildingData(b, pos);
     AddonCheckRequest(b.pos);
 }
Example #23
0
 override public void SetBasement(Plane b, PixelPosByte pos)
 {
     if (b == null)
     {
         return;
     }
     SetBuildingData(b, pos);
     //copy to Gardens.cs
 }
Example #24
0
    override public void LevelUp(bool returnToUI)
    {
        if (upgradedIndex == -1)
        {
            return;
        }
        if (!GameMaster.realMaster.weNeedNoResources)
        {
            ResourceContainer[] cost = GetUpgradeCost();
            if (!colony.storage.CheckBuildPossibilityAndCollectIfPossible(cost))
            {
                AnnouncementCanvasController.NotEnoughResourcesAnnounce();
                return;
            }
        }
        Factory upgraded = GetStructureByID(upgradedIndex) as Factory;

        upgraded.Prepare();
        PixelPosByte setPos = new PixelPosByte(surfaceRect.x, surfaceRect.z);

        if (upgraded.surfaceRect.size == 16)
        {
            setPos = new PixelPosByte(0, 0);
        }
        int workers = workersCount;

        workersCount = 0;
        if (upgraded.rotate90only & (modelRotation % 2 != 0))
        {
            upgraded.modelRotation = (byte)(modelRotation - 1);
        }
        else
        {
            upgraded.modelRotation = modelRotation;
        }
        //
        upgraded.SetRecipe(recipe);
        upgraded.productionMode        = productionMode;
        upgraded.productionModeValue   = productionModeValue;
        upgraded.workPaused            = workPaused;
        upgraded.workflow              = workflow;
        upgraded.inputResourcesBuffer  = inputResourcesBuffer; inputResourcesBuffer = 0;
        upgraded.outputResourcesBuffer = outputResourcesBuffer; outputResourcesBuffer = 0;
        //
        upgraded.SetBasement(basement, setPos);
        upgraded.AddWorkers(workers);
        if (isActive)
        {
            upgraded.SetActivationStatus(true, true);
        }
        if (returnToUI)
        {
            upgraded.ShowOnGUI();
        }
        GameMaster.realMaster.eventTracker?.BuildingUpgraded(this);
    }
Example #25
0
 public override void SetBasement(Plane b, PixelPosByte pos)
 {
     if (b == null)
     {
         return;
     }
     //#set house data
     SetBuildingData(b, pos);
     GameMaster.realMaster.colonyController.AddHousing(this);
 }
Example #26
0
 public override void SetBasement(SurfaceBlock b, PixelPosByte pos)
 {
     if (b == null)
     {
         return;
     }
     SetBuildingData(b, pos);
     coverage = 0;
     GameMaster.colonyController.AddHospital(this);
 }
Example #27
0
 protected void SetBuildingData(Plane b, PixelPosByte pos)
 {
     SetStructureData(b, pos);
     isActive = true;
     if (energySurplus != 0 | energyCapacity > 0)
     {
         GameMaster.realMaster.colonyController.AddToPowerGrid(this);
         connectedToPowerGrid = true;
     }
 }
Example #28
0
    public override void SetBasement(Plane b, PixelPosByte pos)
    {
        base.SetBasement(b, pos);
        gm      = GameMaster.geologyModule;
        storage = GameMaster.realMaster.colonyController.storage;
        var em = GameMaster.realMaster.environmentMaster;

        richness = em.envRichness;
        em.environmentChangingEvent += EnvironmentUpdate;
    }
Example #29
0
 override public void SetBasement(SurfaceBlock b, PixelPosByte pos)
 {
     if (b == null)
     {
         return;
     }
     SetStructureData(b, pos);
     transform.GetChild(0).localScale = new Vector3(1, 0, 1);
     //if (isBasement) basement.myChunk.chunkUpdateSubscribers_structures.Add(this);
 }
Example #30
0
 override public void SetBasement(SurfaceBlock b, PixelPosByte pos)
 {
     if (b == null)
     {
         return;
     }
     SetStructureData(b, pos);
     (myRenderer as LineRenderer).SetPosition(0, transform.position);
     (myRenderer as LineRenderer).SetPosition(1, transform.position + Vector3.up * startSize);
 }