mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Merge branch 'coffee-compiler/fix_trade_with_everyone' into 'master'
Fix ability to send trade requests to every entity See merge request veloren/veloren!4549
This commit is contained in:
commit
b8feae67de
@ -64,6 +64,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- Text overflow and flickering in the crafting menu.
|
||||
- Crash when deleting entries from the server list.
|
||||
- Active buttons in repair equipment interface when missing requirements.
|
||||
- Ability to send trade requests to every entity.
|
||||
|
||||
## [0.16.0] - 2024-03-30
|
||||
|
||||
|
@ -19,8 +19,8 @@ use common::{
|
||||
inventory::slot::{EquipSlot, Slot},
|
||||
invite::InviteKind,
|
||||
item::{tool::ToolKind, ItemDesc},
|
||||
CharacterActivity, ChatType, Content, Fluid, InputKind, InventoryUpdateEvent, Pos,
|
||||
PresenceKind, Stats, UtteranceKind, Vel,
|
||||
Alignment, CharacterActivity, ChatType, Content, Fluid, InputKind, InventoryUpdateEvent,
|
||||
Pos, PresenceKind, Stats, UtteranceKind, Vel,
|
||||
},
|
||||
consts::MAX_MOUNT_RANGE,
|
||||
event::UpdateCharacterMetadata,
|
||||
@ -1133,8 +1133,26 @@ impl PlayState for SessionState {
|
||||
match interactable {
|
||||
Interactable::Block(_, _, _) => {},
|
||||
Interactable::Entity(entity) => {
|
||||
if let Some(uid) =
|
||||
client.state().ecs().uid_from_entity(*entity)
|
||||
let can_trade_to = client
|
||||
.state()
|
||||
.read_component_cloned::<Alignment>(*entity)
|
||||
.is_some_and(|a| match a {
|
||||
Alignment::Npc => true,
|
||||
Alignment::Owned(owner)
|
||||
if client.uid().is_some_and(
|
||||
|uid| owner == uid,
|
||||
) =>
|
||||
{
|
||||
true
|
||||
},
|
||||
_ => false,
|
||||
});
|
||||
|
||||
if can_trade_to
|
||||
&& let Some(uid) = client
|
||||
.state()
|
||||
.ecs()
|
||||
.uid_from_entity(*entity)
|
||||
{
|
||||
let name = client
|
||||
.player_list()
|
||||
@ -1149,12 +1167,14 @@ impl PlayState for SessionState {
|
||||
|e| e.name.to_owned(),
|
||||
)
|
||||
});
|
||||
|
||||
self.hud.new_message(ChatType::Meta.into_msg(
|
||||
Content::localized_with_args(
|
||||
"hud-trade-invite_sent",
|
||||
[("playername", name)],
|
||||
),
|
||||
));
|
||||
|
||||
client.send_invite(uid, InviteKind::Trade)
|
||||
};
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user