protected virtual LambdaExpression ClassMap() { DetermineAssignments(); var input = CurrentJob.InputParameter; var output = CurrentJob.OutputParameter; _ = Expression.Label(CurrentJob.Output, "_return"); var nullCheck = Expression.NotEqual(input, Expression.Constant(null, input.Type)); var ctorResolver = GetConstructorResolver(); var ctor = CurrentJob.GetConstructor(ctorResolver); var newInstance = Expression.Assign(output, Expression.Coalesce(output, ctor)); Expression body; if (Tracking.ContainsKey(CurrentJob.Input) && Tracking[CurrentJob.Input]) { body = GetCacheBlock(newInstance, nullCheck); } else { body = Expression.Block( Expression.IfThen(nullCheck, Expression.Block(new Expression[] { newInstance }.Concat(CurrentJob.GetAssignments()))), output ); } return(Expression.Lambda(body, input, output, CurrentJob.CacheParameter)); }
private void ProcessUnflattenProperties(MemberExpression member, string memberFullName, MemberInfo[] processedMembers) { foreach (var prop in member.Type.GetRuntimeProperties()) { if (!prop.IsPublic()) { continue; } if (processedMembers.Contains(prop)) { if (prop.PropertyType.IsClass() && prop.PropertyType != typeof(string)) { ProcessUnflattenProperties(GetMember(member, prop.Name) as MemberExpression, memberFullName + prop.Name, processedMembers); } continue; } if (!(GetMember(member, prop.Name) is MemberExpression outputMember)) { continue; } var inputMember = GetMember(CurrentJob.InputParameter, memberFullName + prop.Name); if (inputMember == null) { UnFlatten(outputMember); continue; } CurrentJob.AssignTo(outputMember, inputMember); } }
private void UnFlatten(MemberExpression member) { if (member.Type.IsConstructedGenericType && typeof(IEnumerable).IsAssignableFrom(member.Type)) { return; } var processedMembers = new MemberInfo[] { }; var buildedTypes = new List <Type>(); var memberFullName = string.Concat(member.ToString().Split('.').Skip(1)); var constructors = member.Type.GetConstructors(); if (constructors.Any()) { var ctorResolver = GetConstructorResolver(); var ctor = ctorResolver.Resolve(CurrentJob.InputParameter, member, memberFullName); if (ctor != null) { CurrentJob.AssignTo(member, ctor); processedMembers = ctorResolver.GetProcessedMembers(); buildedTypes.Add(member.Type); } else { return; } } ProcessUnflattenProperties(member, memberFullName, processedMembers); }
public void placeStopDown() { if (Items[0].GetComponent <Collectable>().CollectableType == CollectableType.Stops) { TaskObject.GetComponent <Construction_Script>().Contained_Stops++; System_Script.CollectableStops.Remove(Items[0]); var index = TaskObject.GetComponent <Construction_Script>().Workerlist_Stops.IndexOf(this.gameObject); Items[0].transform.rotation = TaskObject.GetComponent <Construction_Script>().RequiredStopsListPoints[index].transform.rotation; Items[0].transform.eulerAngles += new Vector3(0, 180, 0); Items[0].transform.position = new Vector3(Items[0].transform.position.x, 0.1f, Items[0].transform.position.z); TaskObject.GetComponent <Construction_Script>().RequiredStopsListPoints.RemoveAt(index); TaskObject.GetComponent <Construction_Script>().aquiredObj.Add(Items[0]); Items[0].GetComponent <Collectable>().MakeStatic(); Items[0].GetComponent <Animation>().Play("Open"); } Items.Clear(); CurrentTask = CurrentJob.Nothing; TaskChassis = TaskChassis.Nothing; ItemType = CollectableType.Nothing; }
private BehaviourTreeStatus TransferStockToJob_Action() { // Debug.Log("TransferStockToJob_Action"); // If we're not carrying anything, nothing to do. if (this.Inventory == null || this.Inventory.StackSize == 0) { return(BehaviourTreeStatus.Success); } // Only drop what we're carrying if it is what the job wants. if (CurrentJob.NeedsMaterial(Inventory) == 0) { return(BehaviourTreeStatus.Success); } // Debug.Log("TransferStockToJob_Action is transfering stock to job."); // We are at the jobsite, so drop the Inventory. World.Instance.InventoryManager.TransferInventory(CurrentJob, Inventory); CurrentJob.DoWork(0); // This will call all the cbJobWorked callbacks if (Inventory.StackSize == 0) { Inventory = null; } else { Debug.LogError("Character is still carrying Inventory, which shouldn't be the case."); Inventory = null; } // Once the stock is dropped, we're available for work return(BehaviourTreeStatus.Success); }
private BehaviourTreeStatus PickUpStock_Action() { //Debug.Log("PickUpStock_Action"); // Quickly check to see if the job still needs the stuff we're stood on, in case someone else has already taken it there. if (CurrentJob.HasAllMaterial()) { return(BehaviourTreeStatus.Success); } // We should be standing on the stuff we were looking for, but check again just to be sure. // TODO: someone else migh have nicked this stuff already. Should we "reserve" distant stock as soon as we decide we're going to go and get it? if (CurrentTile.Inventory != null && (CurrentJob.CanTakeFromStockpile || CurrentTile.Furniture == null || CurrentTile.Furniture.IsStockpile() == false) && (CurrentJob.NeedsMaterial(CurrentTile.Inventory) != 0)) { // The materials we need are right where we're stood! World.Instance.InventoryManager.TransferInventory( character: this, source: CurrentTile.Inventory, qty: CurrentJob.NeedsMaterial(CurrentTile.Inventory)); // We've picked up what we need, so wait for further orders. return(BehaviourTreeStatus.Success); } return(BehaviourTreeStatus.Failure); }
public override string ToString() { var builder = new StringBuilder(); builder.AppendLine($"Id is: {Id} \n"); builder.AppendLine($"Name is: {Name} \n"); builder.AppendLine($"Photo is: {Photo} \n"); builder.AppendLine($"Link is: {Link} \n"); builder.AppendLine($"Langs is: {string.Join(", ", Languages)} \n"); builder.AppendLine($"Intrests is: {string.Join(", ", Interests)} \n"); builder.AppendLine($"Wants is: {string.Join(", ", Wants)} \n"); builder.AppendLine($"Haves is: {string.Join(", ", Haves)} \n"); builder.AppendLine($"Job is: {CurrentJob.ToString()}"); foreach (var education in Educations) { builder.AppendLine(education.ToString()); } foreach (var work in Works) { builder.AppendLine(work.ToString()); } return(builder.ToString()); }
private void InitView() { if (CurrentJob != null) { CurrentJob.SetCheckToSpecs(CurrentSpecs); } lblSection.Text = String.Format("{0}→{1}({2})", CurrentSpecs.Seciton, CurrentSpecs.CheckPosition, CurrentSpecs.CheckMethod); Text = String.Format("{2}.{0}→{1}", CurrentSpecs.Seciton, CurrentSpecs.CheckPosition, CurrentSpecs.Sequence); txtBarCode.Text = CurrentSpecs.BarCode; lvMain.Items.Clear(); foreach (SpecsDetail detail in CurrentSpecs.Items) { ListViewItem item = new ListViewItem(detail.CheckDetail); //item.SubItems.Add(detail.CheckMethod); item.SubItems.Add(detail.SpecifiedSizeHeight); item.SubItems.Add(detail.KnockPosition); if (detail.isDone) { item.ForeColor = System.Drawing.Color.Blue; item.Checked = detail.isChecked; } else { item.Checked = true; } item.Tag = detail.ID; lvMain.Items.Add(item); } }
public void PickUpCollectable() { CurrentTask = CurrentJob.CarringCollectable; TaskObject.GetComponent <Collectable>().CollectedCart = CollectionSpace; Items.Add(TaskObject); ItemType = TaskObject.GetComponent <Collectable>().CollectableType; FindNearestCollectableDropOff(); }
public IPoint CreatePoint() { if (Parent == null) { return(CurrentJob.CreatePoint(0)); } return(CurrentJob.CreatePoint(Parent.From)); }
private void btnSave_Click(object sender, EventArgs e) { CurrentSpecs.IsCheckAll = true; foreach (ListViewItem item in lvMain.Items) { SpecsDetail detail = CurrentSpecs.FindByID(Int32.Parse(item.Tag.ToString())); detail.isChecked = item.Checked; if (!detail.isChecked) { CurrentSpecs.IsCheckAll = false; } } //JobDetail jobdetail = CurrentJob.FindBySpecsID(CurrentSpecs.ID); JobDetail jobdetail = CurrentJob.findByBarCode(CurrentSpecs.BarCode); if (jobdetail == null) { jobdetail = new JobDetail(); } jobdetail.JobID = CurrentJob.ID; jobdetail.SpecsID = CurrentSpecs.ID; jobdetail.CheckTime = DateTime.Now; jobdetail.isChecked = CurrentSpecs.IsCheckAll; jobdetail.CheckDetailList = CurrentSpecs.CheckDetailList; jobdetail.BarCode = CurrentSpecs.BarCode; CurrentJob.Items.Add(jobdetail); if (jobdetail.ID == 0) { jobdetail.ID = DbFactory.JobDetailInsert(jobdetail); CurrentJob.CheckPosition += 1; } else { DbFactory.JobDetailUpdate(jobdetail); } //DbFactory.SaveJob(CurrentJob); if (AppHelper.IsLockOnCheck == false) { Specs spec = DbFactory.FindBySequence(CurrentSpecs.Sequence + 1, CurrentJob.IsFull); if (spec != null) { CurrentSpecs = spec; InitView(); } else { //work done. MessageBox.Show("已经检查到最大序号!"); } } else { InitView(); } }
public void SetToDefault() { CurrentTask = CurrentJob.Nothing; DistFromJob = float.MaxValue; TaskChassis = TaskChassis.Nothing; TaskObject = null; Vehicle = null; UnSelectable = false; this.GetComponent <NavMeshAgent>().enabled = true; }
private BehaviourTreeStatus DoWork_Action(float deltaTime) { // Debug.Log("DoWork_Action"); // If there isn't a current job, that probably means while this step was running, the job was completed. if (CurrentJob == null) { if (DebugAi) { Debug.Log(Name + ": DoWork returning success"); } return(BehaviourTreeStatus.Success); } // TODO: Not sure if we need to check this - that should've been handled by the preceeding actions. Can jobs move by themselves? var rangeToJob = 0; if (CurrentTile == CurrentJob.Tile) { // We're stood on the Job site. rangeToJob = 0; } if (_path != null) { // We're stood close enough to the job site. rangeToJob = _path.Length(); } // If we're too far from the job site, something went wrong. if (rangeToJob > CurrentJob.MinRange) { if (DebugAi) { Debug.Log(Name + ": DoWork returning failure"); } return(BehaviourTreeStatus.Failure); } // Debug.LogFormat("DoWork_Action working job \"{3}\" at [{0},{1}] ({2:F2})", CurrentTile.X, CurrentTile.Y, CurrentJob.JobTime, CurrentJob.Name); CurrentState = State.WorkingJob; // Set dest to current, just in case it was the proximity-check that got us here. DestinationTile = CurrentTile; _path = null; // Do some work. CurrentJob.DoWork(deltaTime); if (DebugAi) { Debug.Log(Name + ": DoWork returning running"); } return(BehaviourTreeStatus.Running); }
private void ProcessRequests() { while (IsRunning || m_jobQueue.Count > 0) { try { CurrentJob = m_jobQueue.Take(m_cancelSource.Token); } catch (ObjectDisposedException e) { // If we see this whilst not running then it may be due to a race where this thread checks // IsRunning after the stopping thread sets it to false and disposes of the cancellation source. if (IsRunning) { throw e; } else { m_log.DebugFormat("[JobEngine] {0} stopping ignoring {1} jobs in queue", Name, m_jobQueue.Count); break; } } catch (OperationCanceledException) { break; } if (LogLevel >= 1) { m_log.DebugFormat("[{0}]: Processing job {1}", LoggingName, CurrentJob.Name); } try { CurrentJob.Action(); } catch (Exception e) { m_log.Error( string.Format( "[{0}]: Job {1} failed, continuing. Exception ", LoggingName, CurrentJob.Name), e); } if (LogLevel >= 1) { m_log.DebugFormat("[{0}]: Processed job {1}", LoggingName, CurrentJob.Name); } CurrentJob = null; } Watchdog.RemoveThread(false); m_finishedProcessingAfterStop.Set(); }
public void MessageDelivered() { AudioManager.PlayOneShot("job_deliver"); ++delivered_jobs; GameManager.scene.ui_manager.updateUIText(delivered_jobs); current_job = CurrentJob.COLLECTING; SpawnMessage(); }
private void Assign(PropertyInfo prop, Expression inputMember, MemberExpression outputMember) { foreach (var resolver in GetResolvers()) { var result = resolver.Resolve(inputMember, outputMember); if (result != null) { CurrentJob.AssignTo(prop, result); break; } } }
public void MessageCollected() { AudioManager.PlayOneShot("job_pickup"); current_job = CurrentJob.DELIVERING; var pos = delivery_points[Random.Range(0, delivery_points.Count)].position; var clone = Instantiate(delivery_point_prefab, pos, Quaternion.identity); current_destination = clone.GetComponent <DeliveryPoint>(); GameManager.scene.pigeon.SetDestination(current_destination); }
private async void RunJob() { var result = await CurrentJob.Run(); if (result is JobFailureResult) { CurrentJob.JobDescriptor.Status = "Failed"; DisplayJobStatus(); } CurrentJob = null; }
void GetState() { var client = new RestClient(opArgs.Server); var request = new RestRequest("/api/job", Method.GET); request.AddHeader("X-Api-Key", opArgs.ApiKey); IRestResponse response = client.Execute(request); CurrentJob currentJob = null; if (response.StatusCode == HttpStatusCode.OK) { currentJob = SimpleJson.SimpleJson.DeserializeObject <CurrentJob>(response.Content); } if (currentJob.state == "Operational") { upload.IsEnabled = true; print.IsEnabled = true; remove.IsEnabled = true; openOp.IsEnabled = true; refresh.Visibility = Visibility.Hidden; status.Content = "OctoPrint is ready to start printing."; } else if (currentJob.state == "Printing") { upload.IsEnabled = true; print.IsEnabled = false; remove.IsEnabled = true; openOp.IsEnabled = true; refresh.Visibility = Visibility.Visible; status.Content = "OctoPrint is currently printing."; } else if (currentJob.state == "Cancelling") { upload.IsEnabled = true; print.IsEnabled = false; remove.IsEnabled = true; openOp.IsEnabled = true; refresh.Visibility = Visibility.Visible; status.Content = "OctoPrint is canceling a print."; } else { status.Content = "OctoPrint is offline or there is a invalid parameter."; } }
private BehaviourTreeStatus GetNextJob_Action(float deltaTime) { //Debug.Log("GetNextJob_Action"); _timeSinceLastJobSearch += deltaTime; if (_timeSinceLastJobSearch < TimeBetweenJobSearches) { if (DebugAi) { Debug.Log(Name + ": GetNextJob returning failure"); } return(BehaviourTreeStatus.Failure); } // If there are no jobs, just fail. if (World.Instance.JobQueue.Count() == 0) { if (DebugAi) { Debug.Log(Name + ": GetNextJob returning failure"); } return(BehaviourTreeStatus.Failure); } CurrentJob = World.Instance.JobQueue.TakeFirstJobFromQueue(); // Try to get a job to do, if that fais, return a failure if (CurrentJob == null) { if (DebugAi) { Debug.Log(Name + ": GetNextJob returning failure"); } return(BehaviourTreeStatus.Failure); } Debug.LogFormat("{0} got new job {1} at [{2},{3}]", Name, CurrentJob.Name, CurrentJob.Tile.X, CurrentJob.Tile.Y); if (CurrentJob.Furniture != null) { CurrentJob.Furniture.WorkingCharacter = this; } CurrentJob.RegisterOnJobStoppedCallback(OnJobStopped); if (DebugAi) { Debug.Log(Name + ": GetNextJob returning success"); } return(BehaviourTreeStatus.Success); }
public void Die(bool spawnCorpse) { if (spawnCorpse) { Instantiate(corpsePrefab, transform.position, transform.rotation); } else { Instantiate(gravestone, transform.position, Quaternion.identity); } MinionManager.Instance.RemoveMinion(this); CurrentJob?.CancelJob(); Destroy(gameObject); }
private bool JobHasAllNeedMaterials_Condition() { if (CurrentJob.HasAllMaterial()) { if (DebugAi) { Debug.Log(this.Name + ": job has all materials"); } return(true); } if (DebugAi) { Debug.Log(this.Name + ": job need materials"); } return(false); }
private void InitView() { isInInitView = true; try { //Boolean isSaved = false; if (CurrentJob != null) { //CurrentJobDetail = CurrentJob.findByBarCode(CurrentSpecs.BarCode) ; //isSaved = CurrentJobDetail!= null; CurrentJob.SetCheckToSpecs(CurrentSpecs); } lblSection.Text = String.Format("{0}→{1}({2})", CurrentSpecs.Seciton, CurrentSpecs.CheckPosition, CurrentSpecs.CheckMethod); Text = String.Format("{2}.{0}→{1}", CurrentSpecs.Seciton, CurrentSpecs.CheckPosition, CurrentSpecs.Sequence); txtBarCode.Text = CurrentSpecs.BarCode; lblDesc.Text = Lookup.Description(CurrentSpecs.BarCode); lvMain.Items.Clear(); foreach (SpecsDetail detail in CurrentSpecs.Items) { ListViewItem item = new ListViewItem(detail.CheckDetail); //item.SubItems.Add(detail.CheckMethod); //item.SubItems.Add(detail.SpecifiedSizeHeight); //item.SubItems.Add(detail.KnockPosition); if (detail.isDone) //if (isSaved) { item.ForeColor = System.Drawing.Color.Blue; item.Checked = detail.isChecked; } else { item.Checked = true; } item.Tag = detail.ID; lvMain.Items.Add(item); } txtBarCode.SelectAll(); txtBarCode.Focus(); } finally { isInInitView = false; } }
//put crystal away public void PutCollectableDownAtBase() { if (CurrentTask != CurrentJob.ConstructionWorker) { // used for collection of resources if (Items[0].GetComponent <Collectable>().CollectableType == CollectableType.Crystal) { SystemSrpt.CrystalsCollectedCart++; TaskChassis = TaskChassis.GatherCrystals; } if (Items[0].GetComponent <Collectable>().CollectableType == CollectableType.Ore) { SystemSrpt.OreCollectedCart++; TaskChassis = TaskChassis.GatherOre; } Destroy(Items[0]); } else { // used for building if (Items[0].GetComponent <Collectable>().CollectableType == CollectableType.Ore) { TaskObject.GetComponent <Construction_Script>().Contained_Ore++; } if (Items[0].GetComponent <Collectable>().CollectableType == CollectableType.Crystal) { TaskObject.GetComponent <Construction_Script>().Contained_Crystal++; } TaskObject.GetComponent <Construction_Script>().aquiredObj.Add(Items[0]); Items[0].GetComponent <Collectable>().MakeStatic(); } if (Items.Count > 0) { Items.Clear(); CurrentTask = CurrentJob.Nothing; TaskChassis = TaskChassis.Nothing; } }
private bool IsCarryingMaterials_Condition() { if (Inventory != null) { if (CurrentJob.NeedsMaterial(Inventory) > 0) { // We are carrying at least some of what the current job needs, so take it to the job site. if (DebugAi) { Debug.Log(this.Name + ": I have the materials the job needs"); } return(true); } } if (DebugAi) { Debug.Log(this.Name + ": I need materials for this job"); } return(false); }
private void SaveBackgroundWorker_DoWork(object sender, DoWorkEventArgs e) { if (CurrentJob.ID == 0) { saveError = CurrentJob.Insert(); } else { saveError = CurrentJob.Update(); } if (saveError == DatabaseError.NoError) { _jobState = JobState.Saved; } else { _jobState = JobState.SaveError; } }
static void ProcessJobThread() { while (true) { CurrentJob = null; if (suspend_count > 0) { Task.Delay(10); continue; } lock (this_mutex) { if (disposed) { Log.Debug("execution thread destroyed, dispose requested"); return; } try { CurrentJob = heap.Pop(); } catch (InvalidOperationException) { Debug("execution thread destroyed, no more jobs scheduled"); job_thread = null; return; } } try { Debug("Job started ({0})", CurrentJob); OnJobStarted(CurrentJob); CurrentJob.Run(); Debug("Job ended ({0})", CurrentJob); OnJobFinished(CurrentJob); } catch (Exception e) { Debug("Job threw an unhandled exception: {0}", e); } } }
private IEnumerator GameTick() { while (true) { yield return(new WaitForSeconds(m_updateTick)); if (m_taskQueue.Count > 0) { if (CurrentJob == null) { CurrentJob = m_taskQueue.Peek(); CurrentJob.OnStart(this); } else { m_taskQueue.Peek().OnUpdate(this); } } else { LookForAJob(); } } }
public void RandomAttack() { CurrentJob.AttackPatterns(); }
public void StartDriverProcess() { CurrentTask = CurrentJob.WalkingToVehicle; DistFromJob = float.MaxValue; }