public void AddPassenderDestination(GlobalStructureList aGlobalStructureList, int aVesselId, PlayerInfo aPlayer) { var FoundEntity = SearchEntity(aGlobalStructureList, aVesselId); if (FoundEntity == null) { return; } var RelativePos = GetVector3(aPlayer.pos) - GetVector3(FoundEntity.Data.pos); var NormRot = GetVector3(aPlayer.rot) - GetVector3(FoundEntity.Data.rot); var EntityRot = GetMatrix4x4(GetVector3(FoundEntity.Data.rot)).Transpose(); RelativePos = Vector3.Transform(RelativePos, EntityRot); RelativePos = new Vector3(RelativePos.X, ((float)Math.Round(RelativePos.Y + 1.9) - 1), RelativePos.Z); var Target = Configuration.Current.PassengersDestinations.FirstOrDefault(P => P.PassengerId == aPlayer.entityId); if (Target == null) { Configuration.Current.PassengersDestinations.Add(Target = new TeleporterRoute()); } Target.PassengerId = aPlayer.entityId; Target.PassengerName = aPlayer.playerName; Target.Destination = new TeleporterData() { Id = aVesselId, Position = RelativePos, Rotation = NormRot }; Configuration.Current.PassengersDestinations = Configuration.Current.PassengersDestinations.OrderBy(T => T.PassengerName).ToList(); }
public void AddRoute(GlobalStructureList aGlobalStructureList, TeleporterPermission aPermission, int aSourceId, int aTargetId, PlayerInfo aPlayer) { var FoundEntity = SearchEntity(aGlobalStructureList, aSourceId); if (FoundEntity == null) { return; } var FoundRoute = TeleporterRoutes.FirstOrDefault(R => R.Permission == aPermission && IsPermissionGranted(R, aPlayer) && ((R.A.Id == aSourceId && R.B.Id == aTargetId) || (R.B.Id == aSourceId && R.A.Id == aTargetId))); var RelativePos = GetVector3(aPlayer.pos) - GetVector3(FoundEntity.Data.pos); var NormRot = GetVector3(aPlayer.rot) - GetVector3(FoundEntity.Data.rot); var EntityRot = GetMatrix4x4(GetVector3(FoundEntity.Data.rot)).Transpose(); RelativePos = Vector3.Transform(RelativePos, EntityRot); RelativePos = new Vector3(RelativePos.X, ((float)Math.Round(RelativePos.Y + 1.9) - 1), RelativePos.Z); if (FoundRoute == null) { TeleporterRoutes.Add(FoundRoute = new TeleporterRoute() { Permission = aPermission, PermissionId = aPermission == TeleporterPermission.PublicAccess ? 0 : aPermission == TeleporterPermission.FactionAccess ? aPlayer.factionId : aPermission == TeleporterPermission.PrivateAccess ? aPlayer.entityId : 0, A = new TeleporterData() { Id = aSourceId, Position = RelativePos, Rotation = NormRot }, B = new TeleporterData() { Id = aTargetId } }); TeleporterRoutes = TeleporterRoutes.OrderBy(T => T.Permission).ToList(); } else if (FoundRoute.A.Id == aSourceId && FoundRoute.B.Id == aTargetId) { FoundRoute.Permission = aPermission; FoundRoute.A.Position = RelativePos; FoundRoute.A.Rotation = NormRot; } else if (FoundRoute.A.Id == aTargetId && FoundRoute.B.Id == aSourceId) { FoundRoute.Permission = aPermission; FoundRoute.B.Position = RelativePos; FoundRoute.B.Rotation = NormRot; } }
bool IsPermissionGranted(TeleporterRoute aRoute, PlayerInfo aPlayer) { return(aRoute.Permission == TeleporterPermission.PublicAccess ? true : aRoute.Permission == TeleporterPermission.FactionAccess ? aRoute.PermissionId == aPlayer.factionId : aRoute.Permission == TeleporterPermission.PrivateAccess ? aRoute.PermissionId == aPlayer.entityId : false); }