Changeset 25243
- Timestamp:
- Apr 12, 2021, 2:50:17 PM (3 years ago)
- Location:
- ps/trunk/binaries/data/mods/public/simulation/components
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
ps/trunk/binaries/data/mods/public/simulation/components/ResourceGatherer.js
r25235 r25243 331 331 332 332 /** 333 * @param {number} target - The entity ID of the target to check.334 * @return {boolean} - Whether we can gather from the target.335 */336 ResourceGatherer.prototype.CanGather = function(target)337 {338 return this.GetTargetGatherRate(target) > 0;339 };340 341 /**342 333 * Returns whether this unit can carry more of the given type of resource. 343 334 * (This ignores whether the unit is actually able to gather that -
ps/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
r25240 r25243 559 559 560 560 "Order.ReturnResource": function(msg) { 561 let cmpResourceGatherer = Engine.QueryInterface(this.entity, IID_ResourceGatherer); 562 if (this.CheckTargetRange(msg.data.target, IID_ResourceGatherer) && 563 this.CanReturnResource(msg.data.target, true, cmpResourceGatherer)) 564 { 565 cmpResourceGatherer.CommitResources(msg.data.target); 566 this.SetDefaultAnimationVariant(); 567 568 // Our next order should always be a Gather, 569 // so just switch back to that order. 570 this.FinishOrder(); 571 } 561 if (this.CheckTargetRange(msg.data.target, IID_ResourceGatherer)) 562 this.SetNextState("RETURNRESOURCE.DROPPINGRESOURCES"); 572 563 else if (this.AbleToMove()) 573 this.SetNextState(" INDIVIDUAL.RETURNRESOURCE.APPROACHING");564 this.SetNextState("RETURNRESOURCE.APPROACHING"); 574 565 else 575 566 return this.FinishOrder(); … … 2438 2429 2439 2430 "MovementUpdate": function(msg) { 2440 // If we failed, the GATHERING timer will handle finding a valid resource.2441 2431 if (msg.likelyFailure || msg.obstructed && this.RelaxedMaxRangeCheck(this.order.data, this.DefaultRelaxedMaxRange) || 2442 2432 this.CheckRange(this.order.data)) 2443 this.SetNextState(" GATHERING");2433 this.SetNextState(""); 2444 2434 }, 2445 2435 }, … … 2558 2548 initPos = { 'x': pos.X, 'z': pos.Z }; 2559 2549 else if (!nearbyResource) 2560 nearbyResource = this.FindNearbyResource(new Vector2D(initPos. X, initPos.Z), filter);2550 nearbyResource = this.FindNearbyResource(new Vector2D(initPos.), filter); 2561 2551 2562 2552 if (nearbyResource) … … 2728 2718 this.SetDefaultAnimationVariant(); 2729 2719 2730 // Our next order should always be a Gather,2731 // so just switch back to that order.2732 2720 this.FinishOrder(); 2733 2721 return true; … … 4319 4307 if (!this.CanGather(ent) || !this.CheckTargetVisible(ent)) 4320 4308 return false; 4321 let cmpResourceSupply = Engine.QueryInterface(ent, IID_ResourceSupply);4322 let type = cmpResourceSupply.GetType();4323 let amount = cmpResourceSupply.GetCurrentAmount();4324 4309 4325 4310 let template = cmpTemplateManager.GetCurrentTemplateName(ent); … … 4327 4312 template = template.slice(9); 4328 4313 4329 return amount > 0 && cmpResourceSupply.IsAvailableTo(this.entity) && filter(ent, type, template); 4314 let cmpResourceSupply = Engine.QueryInterface(ent, IID_ResourceSupply); 4315 let type = cmpResourceSupply.GetType(); 4316 return cmpResourceSupply.IsAvailableTo(this.entity) && filter(ent, type, template); 4330 4317 }); 4331 4318 };
Note:
See TracChangeset
for help on using the changeset viewer.