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() + ")"; } }
public void PourInCube() { if (chosenCube == null || chosenCube.excavatingStatus == 0) { return; } else { DigSite ds = chosenCube.gameObject.AddComponent <DigSite>(); ds.Set(chosenCube, false); ds.ShowOnGUI(); } }
private void INLINE_FinishWorkSequence() { 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); } }
public void DigCube() { if (chosenCube == null) { return; } else { if (faceIndex == 4) { SurfaceBlock sb = chosenCube.myChunk.GetBlock(chosenCube.pos.x, chosenCube.pos.y + 1, chosenCube.pos.z) as SurfaceBlock; if (sb == null) { DigSite ds = chosenCube.gameObject.AddComponent <DigSite>(); ds.Set(chosenCube, true); workingObserver = ds.ShowOnGUI(); // вообще они должны сами в конце цепочки устанавливать здесь workingObserver, не? } else { CleanSite cs = chosenCube.gameObject.AddComponent <CleanSite>(); cs.Set(sb, true); workingObserver = cs.ShowOnGUI(); } } else { if (faceIndex < 4) { TunnelBuildingSite tbs = chosenCube.gameObject.AddComponent <TunnelBuildingSite>(); tbs.Set(chosenCube); tbs.CreateSign(faceIndex); workingObserver = tbs.ShowOnGUI(); } } } }
// 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) + ")"; } }