mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
[#1251] Mutable variables are removed. For killing checking non players without alignments as well as with it.
This commit is contained in:
parent
75bbe619fd
commit
c22104ea56
@ -1670,11 +1670,11 @@ fn handle_kill_npcs(
|
|||||||
args: Vec<String>,
|
args: Vec<String>,
|
||||||
_action: &ChatCommand,
|
_action: &ChatCommand,
|
||||||
) -> CmdResult<()> {
|
) -> CmdResult<()> {
|
||||||
let mut kill_pets = false;
|
let kill_pets = if let Some(kill_option) = parse_args!(args, String) {
|
||||||
|
kill_option.contains("--also-pets")
|
||||||
if let Some(kill_option) = parse_args!(args, String) {
|
} else {
|
||||||
kill_pets = kill_option.contains("--also-pets");
|
false
|
||||||
}
|
};
|
||||||
|
|
||||||
let ecs = server.state.ecs();
|
let ecs = server.state.ecs();
|
||||||
let mut healths = ecs.write_storage::<comp::Health>();
|
let mut healths = ecs.write_storage::<comp::Health>();
|
||||||
@ -1682,21 +1682,15 @@ fn handle_kill_npcs(
|
|||||||
let alignments = ecs.read_storage::<comp::Alignment>();
|
let alignments = ecs.read_storage::<comp::Alignment>();
|
||||||
let mut count = 0;
|
let mut count = 0;
|
||||||
|
|
||||||
for (mut health, (), alignment) in (&mut healths, !&players, &alignments).join() {
|
for (mut health, (), alignment)
|
||||||
let mut should_kill = true;
|
in (&mut healths, !&players, alignments.maybe()).join() {
|
||||||
|
let should_kill = kill_pets ||
|
||||||
if !kill_pets {
|
if let Some(Alignment::Owned(owned)) = alignment {
|
||||||
match alignment {
|
ecs.entity_from_uid(owned.0)
|
||||||
Alignment::Owned(uid) => {
|
.map_or(true, |owner| !players.contains(owner))
|
||||||
if let Some(owner) = ecs.entity_from_uid(uid.0) {
|
} else {
|
||||||
if players.contains(owner) {
|
true
|
||||||
should_kill = false;
|
};
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_ => (),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if should_kill {
|
if should_kill {
|
||||||
count += 1;
|
count += 1;
|
||||||
|
Loading…
Reference in New Issue
Block a user