public static Player ToPlayerOrGetOwnerPlayer(this IZone zone, Unit unit) { if (zone == null || unit == null) { return(null); } var player = unit as Player; if (player != null) { return(player); } return(zone.GetPlayer(unit.GetOwnerAsCharacter())); }
/// <summary> /// This occurs when aoe kills the npc. /// Background task that searches for the related missionguid and sumbits the kill for that specific player /// </summary> private void SearchForMissionOwnerAndSubmitKill(IZone zone, Unit killerUnit) { var missionGuid = GetMissionGuid(); var missionOwner = MissionHelper.FindMissionOwnerByGuid(missionGuid); var missionOwnerPlayer = zone.GetPlayer(missionOwner); if (missionOwnerPlayer == null) { //the owner is not this zone //address the mission plugin directly var info = new Dictionary <string, object> { { k.characterID, missionOwner.Id }, { k.guid, missionGuid.ToString() }, { k.type, MissionTargetType.kill_definition }, { k.definition, ED.Definition }, { k.increase, 1 }, { k.zoneID, zone.Id }, { k.position, killerUnit.CurrentPosition } }; if (killerUnit is Player killerPlayer && killerPlayer.Character.Id != missionOwner.Id) { info[k.assistingCharacterID] = killerPlayer.Character.Id; } Task.Run(() => { MissionHelper.MissionProcessor.NpcGotKilledInAway(missionOwner, missionGuid, info); }); return; } //local enqueue, this is the proper player, we can skip gang EnqueueKill(missionOwnerPlayer, killerUnit); }
public static bool TryGetPlayer(this IZone zone, Character character, out Player player) { player = zone.GetPlayer(character); return(player != null); }
public static Player GetPlayerOrThrow(this IZone zone, Character character) { return(zone.GetPlayer(character).ThrowIfNull(ErrorCodes.PlayerNotFound)); }