//Copy ctor public Item(Item aOriginal) { this.objectName = aOriginal.objectName; this.mItemType = aOriginal.mItemType; this.mResourceType = aOriginal.mResourceType; this.mSprite = aOriginal.mSprite; this.itemAmount = aOriginal.itemAmount; }
override public void WorkUpdate() { if (workplace == null) { StopWork(true); return; } var strlist = workplace.GetStructuresList(); if (strlist == null) { if (diggingMission) { colony.RemoveWorksite(this); DigSite ds = new DigSite(workplace, true, 0); TransferWorkers(this, ds); if (showOnGUI) { ds.ShowOnGUI(); showOnGUI = false; } StopWork(true); } else { StopWork(true); } return; } else { workSpeed = colony.workspeed * workersCount * GameConstants.CLEARING_SPEED; workflow += workSpeed; colony.gears_coefficient -= gearsDamage * workSpeed; Structure s = strlist[0]; float workGained = 0; if (s.ID == Structure.PLANT_ID) { workGained = s.hp; (s as Plant).Harvest(false); } else { HarvestableResource hr = s as HarvestableResource; if (hr != null) { workGained = hr.resourceCount; hr.Harvest(); } else { s.ApplyDamage(workflow); workGained = workflow; } } workflow -= workGained; actionLabel = Localization.GetActionLabel(LocalizationActionLabels.CleanInProgress) + " (" + Localization.GetPhrase(LocalizedPhrase.ObjectsLeft) + " :" + strlist.Count.ToString() + ")"; } }
override protected void Dry() { GameObject g = Instantiate(Resources.Load <GameObject>("Lifeforms/DeadTree")) as GameObject; g.transform.localScale = transform.localScale; HarvestableResource hr = g.GetComponent <HarvestableResource>(); hr.SetResources(ResourceType.Lumber, CalculateLumberCount()); hr.SetBasement(basement, new PixelPosByte(innerPosition.x, innerPosition.z)); }
void LabourResult() { int i = 0; bool resourcesFound = false; List <Structure> strs = workObject.surfaceObjects; while (i < strs.Count & workflow > 0) { switch (strs[i].id) { case Structure.PLANT_ID: Plant p = strs[i] as Plant; if (p != null) { byte hstage = p.GetHarvestableStage(); if (hstage != 255 & p.stage >= hstage) { p.Harvest(); resourcesFound = true; workflow--; } } break; case Structure.CONTAINER_ID: HarvestableResource hr = strs[i] as HarvestableResource; if (hr != null) { hr.Harvest(); resourcesFound = true; workflow--; } break; case Structure.RESOURCE_STICK_ID: ScalableHarvestableResource shr = strs[i] as ScalableHarvestableResource; if (shr != null) { shr.Harvest(); resourcesFound = true; workflow--; } break; } i++; } if (resourcesFound) { destructionTimer = GameMaster.LABOUR_TICK * 10; } }
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); }
public static HarvestableResource LoadContainer(System.IO.Stream fs, Plane sblock) { var data = new byte[STRUCTURE_SERIALIZER_LENGTH + CONTAINER_SERIALIZER_LENGTH]; fs.Read(data, 0, data.Length); int containerStartIndex = STRUCTURE_SERIALIZER_LENGTH; ushort modelId = System.BitConverter.ToUInt16(data, containerStartIndex + 8); ResourceType resType = ResourceType.GetResourceTypeById(System.BitConverter.ToInt32(data, containerStartIndex)); float count = System.BitConverter.ToSingle(data, containerStartIndex + 4); HarvestableResource hr = ConstructContainer((ContainerModelType)modelId, resType, count); hr.modelRotation = data[2]; hr.indestructible = (data[3] == 1); hr.SetBasement(sblock, new PixelPosByte(data[0], data[1])); hr.hp = System.BitConverter.ToSingle(data, 4); hr.maxHp = System.BitConverter.ToSingle(data, 8); return(hr); }
protected override void LabourResult(int iterations) { if (iterations < 1) { return; } workflow -= iterations; while (iterations > 0) { iterations--; Structure s = workplace.GetRandomStructure(); if (s == null) { INLINE_FinishWorkSequence(); return; } else { if (s.ID == Structure.PLANT_ID) { (s as Plant).Harvest(false); } else { HarvestableResource hr = s as HarvestableResource; if (hr != null) { hr.Harvest(); } else { s.ApplyDamage(DAMAGE_PER_TICK); } } } } actionLabel = Localization.GetActionLabel(LocalizationActionLabels.CleanInProgress) + " (" + Localization.GetPhrase(LocalizedPhrase.ObjectsLeft) + " :" + workplace.structuresCount.ToString() + ")"; }
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; } }
public virtual bool ConsumeResource(HarvestableResource aResource) { if (currentBuildingState == BuildingState.Finished || (WoodRequired <= 0 && StoneRequired <= 0)) { return(false); } if (aResource.gameObject.GetComponent <Tree>() != null) { Destroy(aResource.gameObject); currentWood++; CheckBuld(); if (onResourceReceived != null) { onResourceReceived(); } return(true); } else if (aResource.gameObject.GetComponent <Rock>() != null) { Destroy(aResource.gameObject); currentStone++; CheckBuld(); if (onResourceReceived != null) { onResourceReceived(); } return(true); } return(false); }
public void PickupItem() { if (!IsFiring) { if (!IsHoldingItem && !IsHoldingPlayer && NearbyPlayer != null) { NearbyPlayer.Hold(this); CurrentHeldPlayer = NearbyPlayer; } else { if (NearbyResources.Count > 0) { HarvestableResource nearestResource = NearbyResources[0]; for (int i = 1; i < NearbyResources.Count; i++) { float smallestDistance = Vector3.Distance(nearestResource.transform.position, this.transform.position); float nextDistance = Vector3.Distance(NearbyResources[i].transform.position, this.transform.position); if (nextDistance < smallestDistance && !nearestResource.IsHeld) { nearestResource = NearbyResources[i]; } } if (nearestResource != null) { nearestResource.Pickup(this); NearbyResources.Remove(nearestResource); CurrentHeldResource = nearestResource; } } } } }
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); }
// public const int MAX_WORKERS = 32 override public void WorkUpdate() { if (workObject == null) { StopWork(); return; } if (workObject.surfaceObjects.Count == 0) { Chunk ch = workObject.myChunk; destroyed = true; // чтобы скрипт игнорировал StopWork при удалении блока if (workObject.type != BlockType.Cave) { ch.DeleteBlock(workObject.pos); } else { (workObject as CaveBlock).DestroySurface(); } destroyed = false; // включаем обратно, чтобы удаление прошло нормально int x = workObject.pos.x, y = workObject.pos.y, z = workObject.pos.z; workObject = null; if (diggingMission) { Block basement = ch.GetBlock(x, y - 1, z); if (basement == null || basement.type != BlockType.Cube) { StopWork(); } else { DigSite ds = basement.gameObject.AddComponent <DigSite>(); TransferWorkers(this, ds); ds.Set(basement as CubeBlock, true); if (showOnGUI) { ds.ShowOnGUI(); showOnGUI = false; } StopWork(); } } return; } else { workflow += workSpeed; Structure s = workObject.surfaceObjects[0]; float workGained = 0; if (s.id == Structure.PLANT_ID) { workGained = s.hp; (s as Plant).Harvest(); } else { HarvestableResource hr = s as HarvestableResource; if (hr != null) { workGained = hr.resourceCount; hr.Harvest(); } else { s.ApplyDamage(workflow); workGained = workflow; } } workflow -= workGained; actionLabel = Localization.GetActionLabel(LocalizationActionLabels.CleanInProgress) + " (" + workObject.surfaceObjects.Count.ToString() + ' ' + Localization.GetPhrase(LocalizedPhrase.ObjectsLeft) + ")"; } }
override public void WorkUpdate() { if (workplace == null) { StopWork(true); } if (workersCount > 0) { workSpeed = colony.workspeed * workersCount * GameConstants.GATHERING_SPEED; workflow += workSpeed; colony.gears_coefficient -= gearsDamage * workSpeed; if (workflow >= 1f) { int i = 0; bool resourcesFound = false; List <Structure> strs = workplace.GetStructuresList(); if (strs != null) { while (i < strs.Count & workflow > 0) { switch (strs[i].ID) { case Structure.PLANT_ID: Plant p = strs[i] as Plant; if (p != null) { p.Harvest(false); resourcesFound = true; workflow--; } break; case Structure.CONTAINER_ID: HarvestableResource hr = strs[i] as HarvestableResource; if (hr != null) { hr.Harvest(); resourcesFound = true; workflow--; } break; case Structure.RESOURCE_STICK_ID: ScalableHarvestableResource shr = strs[i] as ScalableHarvestableResource; if (shr != null) { shr.Harvest(); resourcesFound = true; workflow--; } break; } i++; } if (resourcesFound) { destructionTimer = GameMaster.LABOUR_TICK * 10; } } } } else { workSpeed = 0f; } destructionTimer -= GameMaster.LABOUR_TICK; if (destructionTimer <= 0) { StopWork(true); } }
public void SpreadMinerals(SurfaceBlock surface) { if (surface == null) { return; } int maxObjectsCount = SurfaceBlock.INNER_RESOLUTION * SurfaceBlock.INNER_RESOLUTION / 2, positionsLeft; List <PixelPosByte> positions = surface.GetRandomCells(maxObjectsCount); if (positions.Count == 0) { return; } maxObjectsCount = positions.Count; positionsLeft = maxObjectsCount; List <HarvestableResource> allBoulders = new List <HarvestableResource>(); int containersCount = 0; if (Random.value < metalK_abundance * 10) { containersCount = (int)(maxObjectsCount * GameMaster.geologyModule.metalK_abundance * Random.value); if (containersCount != 0) { int i = 0; while (i < containersCount && positionsLeft > 0) { HarvestableResource hr = Structure.GetStructureByID(Structure.CONTAINER_ID) as HarvestableResource; hr.SetResources(ResourceType.metal_K_ore, 1 + Random.value * 100 * metalK_abundance); allBoulders.Add(hr); positionsLeft--; i++; } } } if (Random.value < metalM_abundance * 10 && positionsLeft > 0) { containersCount = (int)(maxObjectsCount * GameMaster.geologyModule.metalM_abundance * Random.value); if (containersCount != 0) { int i = 0; while (i < containersCount && positionsLeft > 0) { HarvestableResource hr = Structure.GetStructureByID(Structure.CONTAINER_ID) as HarvestableResource; hr.SetResources(ResourceType.metal_M_ore, 1 + Random.value * 100 * metalM_abundance); allBoulders.Add(hr); positionsLeft--; i++; } } } if (Random.value < metalE_abundance * 10 && positionsLeft > 0) { containersCount = (int)(maxObjectsCount * GameMaster.geologyModule.metalE_abundance * Random.value); if (containersCount != 0) { int i = 0; while (i < containersCount && positionsLeft > 0) { HarvestableResource hr = Structure.GetStructureByID(Structure.CONTAINER_ID) as HarvestableResource; hr.SetResources(ResourceType.metal_E_ore, 1 + Random.value * 100 * metalE_abundance); allBoulders.Add(hr); positionsLeft--; i++; } } } if (Random.value < metalN_abundance * 10 && positionsLeft > 0) { containersCount = (int)(maxObjectsCount * GameMaster.geologyModule.metalN_abundance * Random.value); if (containersCount != 0) { int i = 0; while (i < containersCount && positionsLeft > 0) { HarvestableResource hr = Structure.GetStructureByID(Structure.CONTAINER_ID) as HarvestableResource; hr.SetResources(ResourceType.metal_N_ore, 1 + Random.value * 100 * metalN_abundance); allBoulders.Add(hr); positionsLeft--; i++; } } } if (Random.value < metalP_abundance * 10 && positionsLeft > 0) { containersCount = (int)(maxObjectsCount * GameMaster.geologyModule.metalP_abundance * Random.value); if (containersCount != 0) { int i = 0; while (i < containersCount && positionsLeft > 0) { HarvestableResource hr = Structure.GetStructureByID(Structure.CONTAINER_ID) as HarvestableResource; hr.SetResources(ResourceType.metal_P_ore, 1 + Random.value * 100 * metalP_abundance); allBoulders.Add(hr); positionsLeft--; i++; } } } if (Random.value < metalS_abundance * 10 && positionsLeft > 0) { containersCount = (int)(maxObjectsCount * GameMaster.geologyModule.metalS_abundance * Random.value); if (containersCount != 0) { int i = 0; while (i < containersCount && positionsLeft > 0) { HarvestableResource hr = Structure.GetStructureByID(Structure.CONTAINER_ID) as HarvestableResource; hr.SetResources(ResourceType.metal_S_ore, 1 + Random.value * 100 * metalS_abundance); allBoulders.Add(hr); positionsLeft--; i++; } } } if (Random.value < mineralF_abundance * 4 && positionsLeft > 0) { containersCount = (int)(maxObjectsCount * GameMaster.geologyModule.mineralF_abundance * Random.value); if (containersCount != 0) { int i = 0; while (i < containersCount && positionsLeft > 0) { HarvestableResource hr = Structure.GetStructureByID(Structure.CONTAINER_ID) as HarvestableResource; hr.SetResources(ResourceType.mineral_F, 1 + Random.value * 100 * mineralF_abundance); allBoulders.Add(hr); positionsLeft--; i++; } } } if (Random.value < mineralL_abundance * 4 && positionsLeft > 0) { containersCount = (int)(maxObjectsCount * GameMaster.geologyModule.mineralL_abundance * Random.value); if (containersCount != 0) { int i = 0; while (i < containersCount && positionsLeft > 0) { HarvestableResource hr = Structure.GetStructureByID(Structure.CONTAINER_ID) as HarvestableResource; hr.SetResources(ResourceType.mineral_L, 1 + Random.value * 100 * mineralL_abundance); allBoulders.Add(hr); positionsLeft--; i++; } } } if (allBoulders.Count > 0) { for (int n = 0; n < allBoulders.Count; n++) { allBoulders[n].SetBasement(surface, positions[n]); } } maxObjectsCount = SurfaceBlock.INNER_RESOLUTION * SurfaceBlock.INNER_RESOLUTION - surface.surfaceObjects.Count; maxObjectsCount /= 2; maxObjectsCount = (int)(maxObjectsCount * Random.value); if (maxObjectsCount > 0) { int count = 0; if (surface.material_id == ResourceType.STONE_ID) { count = (int)(maxObjectsCount * (0.05f + Random.value * 0.05f)); } else { count = (int)(Random.value * 0.08f); } List <PixelPosByte> points = surface.GetRandomCells(count); if (points.Count > 0) { foreach (PixelPosByte p in points) { HarvestableResource hr = Structure.GetStructureByID(Structure.CONTAINER_ID) as HarvestableResource; hr.SetResources(ResourceType.Stone, 4 + Random.value * 10); hr.SetBasement(surface, p); } } } }
/// <summary> /// /// </summary> /// <param name="character"></param> /// <param name="harvestableResource"></param> /// <param name="duration"></param> public GameHarvestAction(CharacterEntity character, HarvestableResource harvestableResource, int duration) : base(GameActionTypeEnum.SKILL_HARVEST, character, duration) { HarvestableResource = harvestableResource; }
public void AddLifepowerAndCalculate(int count) { lifepower += count; int existingPlantsCount = 0; if (myBlock.cellsStatus != 0) { foreach (Structure s in myBlock.surfaceObjects) { if (s is Plant) { existingPlantsCount++; } } } if (lifepower > 2 * LIFEPOWER_TO_PREPARE) { float freeEnergy = lifepower - 2 * LIFEPOWER_TO_PREPARE; int treesCount = (int)(Random.value * 10 + 4); int i = 0; List <PixelPosByte> positions = myBlock.GetRandomCells(treesCount); if (treesCount > positions.Count) { treesCount = positions.Count; } int lifepowerDosis = (int)(freeEnergy / (treesCount + existingPlantsCount)); if (treesCount != 0) { while (i < treesCount & freeEnergy > 0 & myBlock.cellsStatus != 1) { int plantID = Plant.TREE_OAK_ID; int ld = (int)(lifepowerDosis * (0.3f + Random.value)); if (ld > freeEnergy) { lifepower += freeEnergy; break; } byte maxStage = OakTree.MAX_STAGE; float maxEnergy = OakTree.GetLifepowerLevelForStage(maxStage); byte getStage = (byte)(ld / maxEnergy * maxStage); if (getStage > maxStage) { getStage = maxStage; } if (getStage == maxStage & Random.value > 0.7f) { getStage--; } if (Random.value > 0.1f) { Plant p = Plant.GetNewPlant(plantID); p.SetBasement(myBlock, positions[i]); p.AddLifepower(ld); p.SetStage(getStage); freeEnergy -= (Plant.GetCreateCost(plantID) + ld); } else { HarvestableResource hr = Structure.GetStructureByID(Structure.CONTAINER_ID) as HarvestableResource; hr.SetResources(ResourceType.Food, 10); hr.SetBasement(myBlock, positions[i]); freeEnergy -= BERRY_BUSH_LIFECOST; } i++; } } if (existingPlantsCount != 0 & freeEnergy >= lifepowerDosis) { i = 0; Plant p = null; for (; i < myBlock.surfaceObjects.Count; i++) { p = myBlock.surfaceObjects[i] as Plant; if (p != null) { p.AddLifepower(lifepowerDosis); freeEnergy -= lifepowerDosis; if (freeEnergy <= 0) { break; } } } } lifepower += freeEnergy; } progress = Mathf.Clamp(lifepower / LIFEPOWER_TO_PREPARE, 0, 1); byte stage = (byte)(Mathf.RoundToInt(progress / 0.2f)); prevStage = stage; SetGrassTexture(stage); }
public void SpreadMinerals(Plane[] planes) { int res = PlaneExtension.INNER_RESOLUTION; int maxObjectsCount = res * res / 2, positionsLeft; PlaneExtension pe; foreach (var p in planes) { pe = p.FORCED_GetExtension(); List <PixelPosByte> positions = pe.GetRandomCells(maxObjectsCount); if (positions.Count == 0) { return; } maxObjectsCount = positions.Count; positionsLeft = maxObjectsCount; List <HarvestableResource> allBoulders = new List <HarvestableResource>(); int containersCount = 0; if (Random.value < metalK_abundance * 10) { containersCount = (int)(maxObjectsCount * GameMaster.geologyModule.metalK_abundance * Random.value); if (containersCount != 0) { int i = 0; while (i < containersCount && positionsLeft > 0) { HarvestableResource hr = HarvestableResource.ConstructContainer(ContainerModelType.Boulder, ResourceType.metal_K_ore, 1 + Random.value * 100 * metalK_abundance); allBoulders.Add(hr); positionsLeft--; i++; } } } if (Random.value < metalM_abundance * 10 && positionsLeft > 0) { containersCount = (int)(maxObjectsCount * GameMaster.geologyModule.metalM_abundance * Random.value); if (containersCount != 0) { int i = 0; while (i < containersCount && positionsLeft > 0) { HarvestableResource hr = HarvestableResource.ConstructContainer(ContainerModelType.Boulder, ResourceType.metal_M_ore, 1 + Random.value * 100 * metalM_abundance); allBoulders.Add(hr); positionsLeft--; i++; } } } if (Random.value < metalE_abundance * 10 && positionsLeft > 0) { containersCount = (int)(maxObjectsCount * GameMaster.geologyModule.metalE_abundance * Random.value); if (containersCount != 0) { int i = 0; while (i < containersCount && positionsLeft > 0) { HarvestableResource hr = HarvestableResource.ConstructContainer(ContainerModelType.Boulder, ResourceType.metal_M_ore, 1 + Random.value * 100 * metalE_abundance); allBoulders.Add(hr); positionsLeft--; i++; } } } if (Random.value < metalN_abundance * 10 && positionsLeft > 0) { containersCount = (int)(maxObjectsCount * GameMaster.geologyModule.metalN_abundance * Random.value); if (containersCount != 0) { int i = 0; while (i < containersCount && positionsLeft > 0) { HarvestableResource hr = HarvestableResource.ConstructContainer(ContainerModelType.Boulder, ResourceType.metal_N_ore, 1 + Random.value * 100 * metalN_abundance); allBoulders.Add(hr); positionsLeft--; i++; } } } if (Random.value < metalP_abundance * 10 && positionsLeft > 0) { containersCount = (int)(maxObjectsCount * GameMaster.geologyModule.metalP_abundance * Random.value); if (containersCount != 0) { int i = 0; while (i < containersCount && positionsLeft > 0) { HarvestableResource hr = HarvestableResource.ConstructContainer(ContainerModelType.Boulder, ResourceType.metal_P_ore, 1 + Random.value * 100 * metalP_abundance); allBoulders.Add(hr); positionsLeft--; i++; } } } if (Random.value < metalS_abundance * 10 && positionsLeft > 0) { containersCount = (int)(maxObjectsCount * GameMaster.geologyModule.metalS_abundance * Random.value); if (containersCount != 0) { int i = 0; while (i < containersCount && positionsLeft > 0) { HarvestableResource hr = HarvestableResource.ConstructContainer(ContainerModelType.Boulder, ResourceType.metal_S_ore, 1 + Random.value * 100 * metalS_abundance); allBoulders.Add(hr); positionsLeft--; i++; } } } if (Random.value < mineralF_abundance * 4 && positionsLeft > 0) { containersCount = (int)(maxObjectsCount * GameMaster.geologyModule.mineralF_abundance * Random.value); if (containersCount != 0) { int i = 0; while (i < containersCount && positionsLeft > 0) { HarvestableResource hr = HarvestableResource.ConstructContainer(ContainerModelType.Pile, ResourceType.mineral_F, 1 + Random.value * 100 * mineralF_abundance); allBoulders.Add(hr); positionsLeft--; i++; } } } if (Random.value < mineralL_abundance * 4 && positionsLeft > 0) { containersCount = (int)(maxObjectsCount * GameMaster.geologyModule.mineralL_abundance * Random.value); if (containersCount != 0) { int i = 0; while (i < containersCount && positionsLeft > 0) { HarvestableResource hr = HarvestableResource.ConstructContainer(ContainerModelType.Pile, ResourceType.mineral_L, 1 + Random.value * 100 * mineralL_abundance); allBoulders.Add(hr); positionsLeft--; i++; } } } if (allBoulders.Count > 0) { for (int n = 0; n < allBoulders.Count; n++) { allBoulders[n].SetBasement(p, positions[n]); } } maxObjectsCount = res * res - pe.GetStructuresCount(); maxObjectsCount /= 2; maxObjectsCount = (int)(maxObjectsCount * Random.value); if (maxObjectsCount > 0) { int count = 0; if (p.materialID == ResourceType.STONE_ID) { count = (int)(maxObjectsCount * (0.05f + Random.value * 0.05f)); } else { count = (int)(Random.value * 0.08f); } List <PixelPosByte> points = pe.GetRandomCells(count); if (points.Count > 0) { foreach (PixelPosByte pos in points) { HarvestableResource hr = HarvestableResource.ConstructContainer(ContainerModelType.Boulder, ResourceType.Stone, 4 + Random.value * 10); hr.SetBasement(p, pos); } } } } }
protected override void LabourResult(int iterations) { if (iterations < 1) { return; } workflow -= iterations; int i = 0; bool resourcesFound = false; List <Structure> strs = workplace.GetStructuresList(); if (strs != null) { while (i < strs.Count & iterations > 0) { if (strs[i] == null) { i++; continue; } else { iterations--; switch (strs[i].ID) { case Structure.PLANT_ID: Plant p = strs[i] as Plant; if (p != null) { p.Harvest(false); resourcesFound = true; } break; case Structure.CONTAINER_ID: HarvestableResource hr = strs[i] as HarvestableResource; if (hr != null) { hr.Harvest(); resourcesFound = true; } break; case Structure.RESOURCE_STICK_ID: ScalableHarvestableResource shr = strs[i] as ScalableHarvestableResource; if (shr != null) { shr.Harvest(); resourcesFound = true; } break; } i++; } } if (resourcesFound) { destructionTimer = GameMaster.LABOUR_TICK * 10; } } }