void SelectObject(GameObject GO, SelectObjectFilter Filter = SelectObjectFilter.All, bool final = false) { SelectionData SD = new SelectionData(); SD._Object = GO.GetComponent <SelectableObject>(); if (!SD.IsValid()) { SD._Object = GO.GetComponentInParent <SelectableObject>(); if (!SD.IsValid()) { return; } } SD._Worker = GO.GetComponent <Worker>(); SD._Vehicle = GO.GetComponent <Vehicle>(); if (Filter == SelectObjectFilter.Workers) { if (!SD.IsWorker() && !SD.IsVehicle()) { return; } } SD._Building = GO.GetComponentInParent <Building>(); SD._Rock = GO.GetComponentInParent <RockScript>(); if (SD.ShouldBeCulled()) { if (!CPU_FOW.Get().MultiSampleFOW(GO.transform.position, MSSampleDistance)) { return; } } SD._Object.SetSelectionState(true); if (final && SD.IsWorker() && ShouldPlaySound()) { SD._Worker.PlaySelectionSound(); } if (final && SD.IsVehicle() && ShouldPlaySound()) { SD._Vehicle.PlaySelectionSound(); } CurrentSelectionObjects.Add(SD); }
void ExecuteOrder(UnitTask.TaskType t, SelectionData SD) { if (SD.IsWorker()) { WorkerExecute(t, SD); } else if (SD.IsVehicle()) { VehicleExecute(t, SD); } }
void SelectUI() { if (!HasSelection()) { return; } SelectionData Single = CurrentSelectionObjects[0]; if (Single.IsWorker()) { if (_hit.transform.tag == TagLibrary.HQ_TAG) { //RadialMenuScript.instance.ShowToolOptions(Single._Worker, _hit.transform.position); if (_hit.transform.GetComponent <Tile>() != null || _hit.transform.GetComponent <HQTileTagScript>() != null) { ExecuteOrderOnAll(UnitTask.TaskType.Walk); } } else if (_hit.transform.tag == TagLibrary.VEHICLE_TAG) { if (!_hit.transform.GetComponent <Vehicle>().GetOccupied()) { RadialMenuScript.instance.ShowEmptyVehicleOptions(Single._Worker, _hit.transform.GetComponent <Vehicle>()); } } else if (_hit.transform.tag == TagLibrary.WORKER_TAG) { Worker worker = _hit.transform.gameObject.GetComponentInParent <Worker>(); List <Worker> workers = new List <Worker>(); for (int i = 0; i < CurrentSelectionObjects.Count; i++) { workers.Add(CurrentSelectionObjects[i]._Worker); } RadialMenuScript.instance.ShowWorkerOptions(workers, worker); } else { ExecuteOrderOnAll(UnitTask.TaskType.Walk); } } else { switch (_hit.transform.tag) { case TagLibrary.ROCK_TAG: RockScript rock = _hit.transform.gameObject.GetComponentInParent <RockScript>(); RadialMenuScript.instance.ShowRockOptions(rock); break; case TagLibrary.RUBBLE_TAG: RubbleScript rubble = _hit.transform.gameObject.GetComponentInParent <RubbleScript>(); RadialMenuScript.instance.ShowRubbleOptions(rubble); break; case TagLibrary.MONSTER_TAG: Monster monster = _hit.transform.GetComponentInParent <Monster>(); RadialMenuScript.instance.ShowEnemyOptions(monster); break; case TagLibrary.HQ_TAG: HQ hq = _hit.transform.GetComponentInParent <HQ>(); RadialMenuScript.instance.ShowHQOptions(hq); break; case TagLibrary.OUTPOST_TAG: Outpost outpost = _hit.transform.GetComponentInParent <Outpost>(); RadialMenuScript.instance.ShowOutpostOptions(outpost); break; case TagLibrary.GARAGE_TAG: Garage garage = _hit.transform.GetComponentInParent <Garage>(); RadialMenuScript.instance.ShowGarageOptions(garage); break; case TagLibrary.GEN_TAG: case TagLibrary.SKIP_TAG: case TagLibrary.BLOCK_TAG: case TagLibrary.TURRET_TAG: case TagLibrary.POWERGEN_TAG: Building building = _hit.transform.GetComponentInParent <Building>(); RadialMenuScript.instance.ShowBuildingOptions(building); break; case TagLibrary.ORE_TAG: Ore ore = _hit.transform.GetComponentInParent <Ore>(); RadialMenuScript.instance.ShowResourceOptionsOre(ore); break; case TagLibrary.ENERGYCRYSTAL_TAG: EnergyCrystal energyCrystal = _hit.transform.GetComponentInParent <EnergyCrystal>(); RadialMenuScript.instance.ShowResourceOptionsEnergyCrystal(energyCrystal); break; case TagLibrary.VEHICLE_TAG: Vehicle vehicle = _hit.transform.GetComponent <Vehicle>(); if (vehicle.GetOccupied()) { RadialMenuScript.instance.ShowVehicleOptions(_hit.transform.GetComponent <Vehicle>()); } else { RadialMenuScript.instance.ShowEmptyVehicleOptions(null, _hit.transform.GetComponent <Vehicle>()); } break; case TagLibrary.BURN_TAG: MushroomCluster mushroomCluster = _hit.transform.GetComponentInParent <MushroomCluster>(); RadialMenuScript.instance.ShowMushroomOptions(mushroomCluster); break; } } if (!Single.IsWorker()) { ClearSelectedObjects(false); } SetMode(CurrentSelectionMode.RadialMenu); }