private HarvestResponse OnHarvest(HarvestRequest request, ICommandCallerInfo callerinfo) { var resourcesToGive = Mathf.Min(SimulationSettings.HarvestReturnQuantity, health.Data.currentHealth); health.AddCurrentHealthDelta(-resourcesToGive); return(new HarvestResponse(resourcesToGive)); }
public void HarvestFood(TreeBehaviour aTree) { // resNeed:每次想吃appetite数量的粮食live,如果快饱了,则仅吃饱为止,不多吃 var hungry = attrsWriter.Data.MaxFood - attrsWriter.Data.CurrentFood; var resNeed = ScriptableAnimalStats.appetite; if (hungry < ScriptableAnimalStats.appetite) { resNeed = hungry; } var request = new HarvestRequest() { Harvester = _entityId, ResourcesNeed = resNeed }; aTree.Harvest(request, OnHarvestFood); }
public void execute(GameSession gameSession, IByteBuffer buffer) { if (gameSession.Player.UsingNewClient) { return; } var cmd = new HarvestRequest(); cmd.readCommand(buffer); string itemHash = cmd.itemHash; var player = gameSession.Player; var resource = player.Spacemap.HashedObjects[itemHash]; if (resource != null) { if (player.Position.DistanceTo(resource.Position) > 200) { return; } var ore = resource as Ore; ore?.Collect(player); } }
public void Harvest(HarvestRequest request, Action <Harvestable.Harvest.ReceivedResponse> callback) { cmdSender.SendHarvestCommand(_entityId, request, callback); //Debug.Log("TreeBehaviour SendHarvestCommand Harvester<"+request.Harvester+"> Tree<"+_entityId.Id+"> Resource Need<"+request.ResourcesNeed+">"); }