public void Activate(RobotInventory targetContainer, Character character) { var robot = _robotHelper.LoadRobotForCharacter(targetContainer.GetOrLoadParentEntity().Eid, character, true); robot.ThrowIfNull(ErrorCodes.NoRobotFound); robot.DynamicProperties.Update(k.tint, this.ED.Config.Tint); //Apply color robot.DynamicProperties.Update(k.decay, 255); //Reset Decay robot.Save(); }
public void Visit(RobotInventory inventory) { _error = inventory.CheckParentRobot(_character.Eid); if (_error != ErrorCodes.NoError) { return; } Visit((Container)inventory); }
protected override void OnAction(RobotInventory container) { var currentAmmo = Module.GetAmmo(); if (currentAmmo != null && currentAmmo.Definition != _ammoDefinition) { Module.UnequipAmmoToContainer(container); } if (_ammoDefinition == 0) { OnError(ErrorCodes.AmmoNotFound); return; } currentAmmo = Module.GetAmmo(); if (currentAmmo != null) { var n = (Module.AmmoCapacity - currentAmmo.Quantity).Clamp(0, Module.AmmoCapacity); if (n == 0) { return; } var q = container.RemoveItemByDefinition(currentAmmo.Definition, n); if (q == 0) { Module.OnError(ErrorCodes.AmmoNotFound); } currentAmmo.Quantity += q; if (currentAmmo.Quantity <= 0) { Repository.Delete(currentAmmo); Module.SetAmmo(null); return; } Module.SendAmmoUpdatePacketToPlayer(); } else { var newAmmo = (Ammo)container.GetAndRemoveItemByDefinition(_ammoDefinition, Module.AmmoCapacity); if (newAmmo == null) { OnError(ErrorCodes.AmmoNotFound); } Module.SetAmmo(newAmmo); } }
public void MoveItemToRallyPoint(string item) { if (!RobotInventory.Contains(item)) { if (!ItemLocations.ContainsKey(item)) { throw new Exception("Item not found"); } var itemLocation = ItemLocations[item]; MoveRobotToPoint(itemLocation); PickUpItem(item); } MoveRobotToPoint(RallyPoint); DropItem(item); }
private void UpdateProgess(Player player, RobotInventory container, int submittedQty, ItemInfo requestedItemInfo, PlayerItemProgress progress) { progress.quantity += submittedQty; if (progress.quantity >= requestedItemInfo.Quantity) { progress.index++; progress.quantity = 0; IncrementPlayerScore(player, 1); } progress.nextSubmitTime = DateTime.Now + _submitItemCooldown; container.SendUpdateToOwnerAsync(); if (progress.index >= _itemInfos.Count) { return; } SendProgressToPlayer(player.Character); }
public void DropItem(string item) { // Provide input for the program if (IntcodeProgramStatus.AwaitingInput.Equals(_programStatus)) { _inputProviderAutomated.AddInputValue("drop " + item); _inputProviderAutomated.AddInputValue(10); } // Run a loop of the program _programStatus = _computer.RunProgram(); // Process program output // Assumption: If there is new output, then the robot has // entered a room corresponding to the next robot position if (_outputIndex < _outputListener.Values.Count) { int numberOfNewOutputValues = _outputListener.Values.Count - _outputIndex; var latestOutput = string.Join("", _outputListener.Values .GetRange(_outputIndex, numberOfNewOutputValues) .Select(v => char.ConvertFromUtf32((int)v))); _outputIndex += numberOfNewOutputValues; var robotOutputResult = RobotOutputHelper.ProcessRobotOutput(latestOutput); if (!RobotOutputType.DroppedItem.Equals(robotOutputResult.Type) && IsAutomated) { throw new Exception("Failed to drop the item"); } RobotInventory.Remove(item); ExploredPoints[RobotPosition].Items.Add(item); ItemLocations.Add(item, RobotPosition); } _programLoopCount++; }
public void Visit(RobotInventory inventory) { inventory.SetMaxHealth(); }
public LootContainerProgressInfoPacketBuilder(RobotInventory robotInventory, LootContainer container, int maxCount) { _container = container; _robotInventory = robotInventory; _maxCount = maxCount; }
protected override void OnAction(RobotInventory container) { Module.UnequipAmmoToContainer(container); }
protected abstract void OnAction(RobotInventory container);
public void Visit(RobotInventory inventory) { inventory.GetItems().Any().ThrowIfTrue(ErrorCodes.RobotHasItemsInContainer); }